Car system help
#1

Error:
PHP код:
C:\Users\Kevin11\Desktop\Napoli\gamemodes\rp.pwn(1156) : error 017: undefined symbol "CMD" 
Script with first error:
PHP код:
CMD:spawnauto(playerid, params[])
{
    new 
Float:vx, Float:vy, Float:vz, vid;
    
tmp = strtok(CMD, idx);
    if (!
strlen(tmp)) return SendClientMessage(playerid, 0xF69521AA, "Utilizza: /spawnauto [vehicleid/nome]");
    if (
IsNumeric(tmp) == 1)
    {
       
vid = strval(tmp);
    } else {
      
vid = GetVehicleIDFromName(tmp);
    }
    if ((
vid < 400) || (vid > 611) || (vid == 590) || (vid == 569) || (vid == 570) || (vid == 537) || (vid == 538) || (vid == 449))
    {
       return 
SendClientMessage(playerid, 0xF69521AA, "Veicolo non riconosciuto.");
    }
    else
    {
       
GetPlayerPos(playerid, vx, vy, vz);
       
CreateVehicle(vid, vx + random(9) - 4, vy + random(9) - 4, vz, 0, -1, -1, -1);
       new 
car = GetPlayerVehicleID(playerid);
       
format(stringa,sizeof(stringa),"{0xF69521AA}T{0xF69521AA}D{0xFFFF00AA} %d",random(999));
       
SetVehicleNumberPlate(car, stringa);
       
SendClientMessage(playerid, 0xFFFF00AA, "Auto Spawnata con successo");
       return 
1;
}
}
return 
0;
} 

PHP код:
 C:\Users\Kevin11\Desktop\Napoli\gamemodes\rp.pwn(3269) : error 021: symbol already defined: "strtok" 
PHP код:
 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;
} 
guys help me pls
Reply
#2

Can u show me line 1156?
Reply
#3

Are you sure that you have included zcmd?
Also, remove that custom strtok function.

Edit: Did you put the code under OnPlayerCommandText ?
Reply
#4

PHP код:
tmp = strtok(CMD, idx); 
Reply
#5

Try this:
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{ 
   new 
index, cmd[20];
   
cmd = strtok(cmdtext, index);
    if (
strcmp(cmd, "/spawnauto", true) == 0)
    {
    new 
Float:vx, Float:vy, Float:vz, vid; 
    
tmp = strtok(cmdtext, index); 
    if (!
strlen(tmp)) return SendClientMessage(playerid, 0xF69521AA, "Utilizza: /spawnauto [vehicleid/nome]"); 
    if (
IsNumeric(tmp) == 1) 
    { 
       
vid = strval(tmp); 
    } else { 
      
vid = GetVehicleIDFromName(tmp); 
    } 
    if ((
vid < 400) || (vid > 611) || (vid == 590) || (vid == 569) || (vid == 570) || (vid == 537) || (vid == 538) || (vid == 449)) 
    { 
       return 
SendClientMessage(playerid, 0xF69521AA, "Veicolo non riconosciuto."); 
    } 
    else 
    { 
       
GetPlayerPos(playerid, vx, vy, vz); 
       
CreateVehicle(vid, vx + random(9) - 4, vy + random(9) - 4, vz, 0, -1, -1, -1); 
       new 
car = GetPlayerVehicleID(playerid); 
       
format(stringa,sizeof(stringa),"{0xF69521AA}T{0xF69521AA}D{0xFFFF00AA} %d",random(999)); 
       
SetVehicleNumberPlate(car, stringa); 
       
SendClientMessage(playerid, 0xFFFF00AA, "Auto Spawnata con successo"); 
       return 
1; 
} 
}
return 
0;
} 
Reply
#6

I have zcmd.
Reply
#7

Use sscanf instead of strtok. strtok is outdated.
Link to sscanf: https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#8

Ok, i have only this error
PHP код:
 error 021: symbol already defined: "strtok" 
Reply
#9

Just replace CMD with params. And for the second error, just remove the function. The error literally tells you what the problem is.
Reply
#10

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
And for the second error, just remove the function. The error literally tells you what the problem is.
Come on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)