SA-MP Forums Archive
Error, But i dont know how to fix - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Error, But i dont know how to fix (/showthread.php?tid=94527)



Error, But i dont know how to fix - GforceNL - 30.08.2009

Hi all,
I have a error and i dont know how to fix :S

Код:
 error 047: array sizes do not match, or destination array is too small
the line:
Код:
	cmd = strtok(cmdtext, idx);
Does somebody knows how to fix it please help me



Re: Error, But i dont know how to fix - James_Alex - 30.08.2009

can you show us your cmd and idx sources ?


Re: Error, But i dont know how to fix - DeathOnaStick - 30.08.2009

The problem has be in a Array. That means you have to look for variables that are like this:

Код:
new MyArray[9] [3];
The compiler says it should be too small, so you have to look for the problem, where the array gets an index or a value.


Re: Error, But i dont know how to fix - GforceNL - 30.08.2009

Quote:
Originally Posted by ► James_Alex
can you show us your cmd and idx sources ?
sure the command:
Код:
	new string[256];
 	dcmd(login,5,cmdtext);
 	dcmd(register,8,cmdtext);
	new cmd[128], tmp[128], idx;
	cmd = strtok(cmdtext, idx);
	if(!strcmp("/job", cmd, true)) if(Logged[playerid] == 1)
	{
	tmp = strtok(cmdtext, idx);
	if (!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[ ! ] USAGE: /job <JobName>") && SendClientMessage(playerid,COLOR_WHITE,"[ ! ] List of jobs: cop, swat, robber");
	if (!strcmp("cop", tmp, true)) if(IsPlayerJob(playerid) == 1)
	{
	 	if(GetPlayerMoney(playerid) <= 25) return SendClientMessage(playerid,COLOR_RED,"[ ! ] Not enough Money! You need 2000!");
	GivePlayerMoney(playerid, -2000);
	RemovePlayerJob(playerid);
	SetPlayerJob(playerid,2);
	SendClientMessage(playerid,TEAM_COP_COLOR,"[ ! ] Cheif of police: Welcome to officer son !");
	SendClientMessage(playerid,ADMIN_MSG,"[ ! ] You are kicked for ( PLEASE RESTART GAME :) )");
	Kick(playerid);
	return 1;
	}



Re: Error, But i dont know how to fix - Jefff - 30.08.2009

Try
Код:
new cmd[256]



Re: Error, But i dont know how to fix - MenaceX^ - 30.08.2009

Quote:
Originally Posted by Jefff
Try
Код:
new cmd[256]
God what's this useless post for?
You are misleading him and also his pawn will crash because you missed a ; in the array.
Change the string size to 128.


Re: Error, But i dont know how to fix - GforceNL - 30.08.2009

Quote:
Originally Posted by Jefff
Try
Код:
new cmd[256]
thnx The error is gone




Re: Error, But i dont know how to fix - DeathOnaStick - 30.08.2009

Quote:
Originally Posted by MenaceX^
God what's this useless post for?
You are misleading him and also his pawn will crash because you missed a ; in the array.
Change the string size to 128.
Not true. The string has nothing to do with the error. The error is about the array cmd, like he told you before. it was too small, so:
Код:
new cmd[256];
should work very well.

but the problem is solved though