[HELP] with command - 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: [HELP] with command (
/showthread.php?tid=381010)
[HELP] with command -
scottygraham1990 - 27.09.2012
i keep getting 3 errors with this command i have just got and i would like to know how in can fix it thx for any help
here are the errors
Код:
C:\Users\Scott\Desktop\Utopia City FreeRoam\gamemodes\UtopiaCityFreeRoam.pwn(529) : error 017: undefined symbol "strtok"
C:\Users\Scott\Desktop\Utopia City FreeRoam\gamemodes\UtopiaCityFreeRoam.pwn(529) : error 033: array must be indexed (variable "tmp2")
C:\Users\Scott\Desktop\Utopia City FreeRoam\gamemodes\UtopiaCityFreeRoam.pwn(531) : error 017: undefined symbol "IsNumeric"
C:\Users\Scott\Desktop\Utopia City FreeRoam\gamemodes\UtopiaCityFreeRoam.pwn(529) : warning 203: symbol is never used: "Index"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
here is the command
pawn Код:
if(!strcmp(cmdtext, "/spray", true))
{
new tmp[256],tmp2[256],Index; tmp = strtok(cmdtext,Index), tmp2 = strtok(cmdtext,Index);
if(!strlen(tmp)||!(strval(tmp) >= 0 && strval(tmp) <= 126)||
!IsNumeric(tmp)||!IsNumeric(tmp2)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /spray <Color 1> (<Color 2>)");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"ERROR: you must be in a vehicle.");
if(!strlen(tmp2)) tmp2 = tmp;
new string[256],name[24]; GetPlayerName(playerid,name,24);
format(string,256,"you have changed your vehicle colours to: [%d %d]",strval(tmp),strval(tmp2));
return ChangeVehicleColor(GetPlayerVehicleID(playerid),strval(tmp),strval(tmp2));
}
Re: [HELP] with command -
mamorunl - 28.09.2012
Well, this is quite some time ago.. It appears you do not have the strtok stock included in your gamemode. You can find it either on the wiki or on these forums.
Also, the way you have set up this command wouldn't work either as strtok works with a variable called cmd and not with cmdtext anymore.
Might I suggest a different command processor to make things easier for you and then especially together with sscanf. It will be a totally different world!
Re: [HELP] with command -
CROSS_Hunter - 28.09.2012
At the end of your script
pawn Код:
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;
}