SA-MP Forums Archive
how to define 'tmp' and 'strtok' - 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: how to define 'tmp' and 'strtok' (/showthread.php?tid=235902)



how to define 'tmp' and 'strtok' - [EDT]AmanSingh123 - 06.03.2011

hey im getting these errors-

C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(530) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(530) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(531) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(532) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(533) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(533) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(534) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(535) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


8 Errors.




-----------------

and heres the script that it comes from-


if(strcmp(cmdtext, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}


Re: how to define 'tmp' and 'strtok' - Stigg - 06.03.2011

Try adding this somewhere in your script.

Код:
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}



Re: how to define 'tmp' and 'strtok' - Serbish - 06.03.2011

&

pawn Код:
new tmp[128];
on top of the ' OnPlayerCommandText ' callback.


Re: how to define 'tmp' and 'strtok' - Stigg - 06.03.2011

Quote:
Originally Posted by Serbish
Посмотреть сообщение
&

pawn Код:
new tmp[128];
on top of the ' OnPlayerCommandText ' callback.
Thanks, i forgot that.