How to fix this error - 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 fix this error (
/showthread.php?tid=219891)
How to fix this error -
Gotti_ - 02.02.2011
I found this somewhere at sa:mp forums
Quote:
if(!strcmp(cmd, "/vec", true))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0x33CCFFAA, "Use: /vec [voertuig ID]");
return 1;
}
new vecid = strval(tmp);
if(vecid >= 400 && vecid <= 611)
{
new Float X, Float Y, Float Z, Float: pA;
GetPlayerPos(playerid, pX, pY, pZ); GetPlayerFacingAngle(playerid, pA);
CreateVehicle(vecid, pX, pY, pZ, pA, -1, -1, 900);
SendClientMessage(playerid, 0x33CCFFAA, string);
return 1;
}
else
{
SendClientMessage(playerid, 0x33CCFFAA, "Wrong vehicle ID");
}
return 1;
}
|
And i fixed 3 errors with corols but i dunno how to fix this
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(1265) : error 017: undefined symbol "cmd"
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(1267) : error 017: undefined symbol "tmp"
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(1267) : error 017: undefined symbol "strtok"
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(126

: error 017: undefined symbol "tmp"
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(1273) : error 017: undefined symbol "tmp"
E:\Gymkhana Freeroam\gamemodes\gymkhana11.pwn(1283) : error 017: undefined symbol "string"
Help pls
AW: How to fix this error -
!Phoenix! - 02.02.2011
"undefined symbol" means that the used variable/function isn't declared.
With strtok you can split a string at the whitespaces -> you can separate the command itself and the parameters.
https://sampwiki.blast.hk/wiki/Strtok
There you can find an example how to use it with OnPlayerCommandText.
Re: How to fix this error -
Steven Paul - 02.02.2011
add this under if(!strcmp(cmd, "/vec", true))
new cmd[128];
new tmp[128];
new string[128];
and add this atlast
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;
}
-
Gotti_ - 02.02.2011
Can u edit my quote and type it here.. please..
ok.... tnx anyways