SA-MP Forums Archive
strtok probem - 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: strtok probem (/showthread.php?tid=249228)



strtok probem - RenisiL - 17.04.2011

I don't understand, hm..

Код:
	new cmd[255], idx;
	cmd = strtok(cmdtext, idx);
	if(strcmp(cmdtext, "/car", true, 10) == 0)
	{

		new String[200];
		new tmp[256];
		new Float:x, Float:y, Float:z;
        tmp = strtok(cmdtext, idx);
  	    if( ArTuriMasina[ playerid ] == true ) DestroyVehicle( PlayersVehicle[playerid] ), ArTuriMasina[ playerid ] = false;
		if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "INFO: /car [Maљinos Pavadinimas]");

		new vehicle = ModelID(tmp);
		if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COLOR_RED, "INFO: Tokios maљinos nėra");


		new Float:a;
		GetPlayerFacingAngle(playerid, a);
		GetPlayerPos(playerid, x, y, z);

		if(IsPlayerInAnyVehicle(playerid) == 1)
		{
			XY(playerid, x, y, 10);
		}
		else
		{
			XY(playerid, x, y, 5);
		}


	    PlayersVehicle[playerid] = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
		PutPlayerInVehicle( playerid,  PlayersVehicle[playerid], 0 );

        ArTuriMasina[ playerid ] = true;

		format(String, sizeof(String), "INFO: Tu susikūriai maљiną %s", VNames[vehicle - 400]);
		SendClientMessage(playerid, COLOR_GREEN, String);
		return 1;
	}
Код:
C:\Documents and Settings\Administrator\Desktop\DriftWorld\DriftWorld\gamemodes\Dw.pwn(648) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: strtok probem - itachi4x4 - 17.04.2011

Which line is it?


Re: strtok probem - iJumbo - 17.04.2011

line 648 is?


Re: strtok probem - Mean - 17.04.2011

Some strtoks are screwed, and you need to use 255 size, you cannot use 10. So
pawn Код:
new cmd[ 255 ], idx;



Re: strtok probem - RenisiL - 17.04.2011

cmd = strtok(cmdtext, idx);


Re: strtok probem - RenisiL - 17.04.2011

I use 300 Array size


Re: strtok probem - Gh0sT_ - 17.04.2011

Damn, use zcmd & sscanf