How to fix this error
#1

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 FloatX, FloatY, FloatZ, 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
Reply
#2

"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.
Reply
#3

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;
}
Reply
#4

Can u edit my quote and type it here.. please..

ok.... tnx anyways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)