SA-MP Forums Archive
error 047: array sizes do not match, or destination array is too small - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 047: array sizes do not match, or destination array is too small (/showthread.php?tid=626858)



error 047: array sizes do not match, or destination array is too small - Mijata - 21.01.2017

PHP код:
new pInfo[MAX_PLAYERS][PlayerInfo],
------> 
Jstring[512]
,
JLstring[500],
LevelName[30],LevelColor[20],
Specid[MAX_PLAYERS],playerIP[16],
aka[256],Cmdstr[128],CTMSG[128],
AdmName[24],VLstring[850]; 



Re: error 047: array sizes do not match, or destination array is too small - GhostHacker9 - 21.01.2017

Where you use it? Most probably you passing it to a function or intializing to another one which have smaller size.


Re: error 047: array sizes do not match, or destination array is too small - iLearner - 21.01.2017

Error lines please?


Re: error 047: array sizes do not match, or destination array is too small - Mijata - 21.01.2017

This line
Quote:

ChatMessages[MAX_CHAT_MSGS_STORE-1] = Jstring;

and this
Quote:

Reports[MAX_REPORTS_STORE-1] = Jstring;




Re: error 047: array sizes do not match, or destination array is too small - GhostHacker9 - 21.01.2017

Quote:
Originally Posted by Mijata
Посмотреть сообщение
This line

and this
The arrays have no matching size. You can either format both of the strings or use string functions like strcpy to copy string values.


Re: error 047: array sizes do not match, or destination array is too small - iLearner - 21.01.2017

Format em

Edit: late


Re: error 047: array sizes do not match, or destination array is too small - Mijata - 21.01.2017

Quote:

public StoreChatLine(playerid,text[])
{
for(new i = 0; i < MAX_CHAT_MSGS_STORE-1; i++)
ChatMessages[i] = ChatMessages[i+1];
format(Jstring,sizeof(Jstring),"%s(ID: %d): %s",GetName(playerid),playerid,text);
ChatMessages[MAX_CHAT_MSGS_STORE-1] = Jstring;
}

public StoreReport(playerid,reported,reason[])
{
new hour,minute,second;
gettime(hour,minute,second);
for(new i = 0; i < MAX_REPORTS_STORE-1; i++)
Reports[i] = Reports[i+1];
format(Jstring,sizeof(Jstring),"%d:%d:%d - %s(ID: %d) Has Reported %s(ID: %d) |{FF0000} REASON: %s ",hour,minute,second,GetName(playerid),playerid,Ge tName(reported),reported,reason);
Reports[MAX_REPORTS_STORE-1] = Jstring;
}

Under that publics are errors


Re: error 047: array sizes do not match, or destination array is too small - X337 - 21.01.2017

You need to format them, you can use strcat or format.
Код:
#if !defined strcpy // to copy a string
	#define strcpy(%0,%1) \
		strcat((%0[0] = '\0', %0), %1)
#endif

public StoreChatLine(playerid,text[])
{
	for(new i = 0; i < MAX_CHAT_MSGS_STORE-1; i++)
		strcpy(ChatMessages[i], ChatMessages[i+1]);
	format(Jstring,sizeof(Jstring),"%s(ID: %d): %s",GetName(playerid),playerid,text);
	strcpy(ChatMessages[MAX_CHAT_MSGS_STORE-1], Jstring);
}

public StoreReport(playerid,reported,reason[])
{
	new hour,minute,second;
	gettime(hour,minute,second);
	for(new i = 0; i < MAX_REPORTS_STORE-1; i++)
		strcpy(Reports[i], Reports[i+1]);
	format(Jstring,sizeof(Jstring),"%d:%d:%d - %s(ID: %d) Has Reported %s(ID: %d) |{FF0000} REASON: %s ",hour,minute,second,GetName(playerid),playerid,Ge tName(reported),reported,reason);
	strcpy(Reports[MAX_REPORTS_STORE-1], Jstring);
}



Re: error 047: array sizes do not match, or destination array is too small - Mijata - 21.01.2017

fixed