SA-MP Forums Archive
Car system help - 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: Car system help (/showthread.php?tid=603040)



Car system help - kevi11 - 17.03.2016

Error:
PHP код:
C:\Users\Kevin11\Desktop\Napoli\gamemodes\rp.pwn(1156) : error 017undefined symbol "CMD" 
Script with first error:
PHP код:
CMD:spawnauto(playeridparams[])
{
    new 
Float:vxFloat:vyFloat:vzvid;
    
tmp strtok(CMDidx);
    if (!
strlen(tmp)) return SendClientMessage(playerid0xF69521AA"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(playerid0xF69521AA"Veicolo non riconosciuto.");
    }
    else
    {
       
GetPlayerPos(playeridvxvyvz);
       
CreateVehicle(vidvx random(9) - 4vy random(9) - 4vz0, -1, -1, -1);
       new 
car GetPlayerVehicleID(playerid);
       
format(stringa,sizeof(stringa),"{0xF69521AA}T{0xF69521AA}D{0xFFFF00AA} %d",random(999));
       
SetVehicleNumberPlate(carstringa);
       
SendClientMessage(playerid0xFFFF00AA"Auto Spawnata con successo");
       return 
1;
}
}
return 
0;


PHP код:
 C:\Users\Kevin11\Desktop\Napoli\gamemodes\rp.pwn(3269) : error 021symbol 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


Re: Car system help - N0FeaR - 17.03.2016

Can u show me line 1156?


Re: Car system help - ATGOggy - 17.03.2016

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

Edit: Did you put the code under OnPlayerCommandText ?


Re: Car system help - kevi11 - 17.03.2016

PHP код:
tmp strtok(CMDidx); 



Re: Car system help - ATGOggy - 17.03.2016

Try this:
PHP код:
public OnPlayerCommandText(playeridcmdtext[])

   new 
indexcmd[20];
   
cmd strtok(cmdtextindex);
    if (
strcmp(cmd"/spawnauto"true) == 0)
    {
    new 
Float:vxFloat:vyFloat:vzvid
    
tmp strtok(cmdtextindex); 
    if (!
strlen(tmp)) return SendClientMessage(playerid0xF69521AA"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(playerid0xF69521AA"Veicolo non riconosciuto."); 
    } 
    else 
    { 
       
GetPlayerPos(playeridvxvyvz); 
       
CreateVehicle(vidvx random(9) - 4vy random(9) - 4vz0, -1, -1, -1); 
       new 
car GetPlayerVehicleID(playerid); 
       
format(stringa,sizeof(stringa),"{0xF69521AA}T{0xF69521AA}D{0xFFFF00AA} %d",random(999)); 
       
SetVehicleNumberPlate(carstringa); 
       
SendClientMessage(playerid0xFFFF00AA"Auto Spawnata con successo"); 
       return 
1

}
return 
0;




Re: Car system help - kevi11 - 17.03.2016

I have zcmd.


Re: Car system help - ATGOggy - 17.03.2016

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


Re: Car system help - kevi11 - 17.03.2016

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



Re: Car system help - AndySedeyn - 17.03.2016

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


Re: Car system help - AndySedeyn - 17.03.2016

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.