SA-MP Forums Archive
Vehicle Problem. - 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: Vehicle Problem. (/showthread.php?tid=583883)



Vehicle Problem. - ChristolisTV - 31.07.2015

Hey guys!
I am creating my own admin filterscript with sscanf,zcmd and mysql.

My problem:
I have a "Respawn Cars" command (/respawncars). And when I type it it respawns all the vehicles but the player's cars doesnt respawn. It stays there. How to fix it?

Code:
PHP код:
CMD:respawncars(playerid,params[]){
     if(
P_DATA[playerid][alevel] < 4)return SendClientMessage(playerid,-1,"{FFFFFF}You must be{FF0000} Level 4{FFFFFF} to use this command.");
     for(new 
v=0v<MAX_VEHICLESv++){
     
SetVehicleToRespawn(v);
     }
     new 
name[MAX_PLAYER_NAME],str[256];
     
GetPlayerName(playerid,name,sizeof(name));
     
format(str,sizeof(str),"{FFFF00}%s{FFFFFF} has respawned all vehicles!",name);
     
SendClientMessageToAll(-1,str);
     return 
1;




Re: Vehicle Problem. - ChristolisTV - 31.07.2015

Anyone?


Re: Vehicle Problem. - nezo2001 - 31.07.2015

what do you mean with
Код:
the player's cars



Re: Vehicle Problem. - ChristolisTV - 31.07.2015

When a player does the /car command.


Re: Vehicle Problem. - nezo2001 - 31.07.2015

Try this:
on the top of the script
PHP код:
new bool:Spawned[MAX_VEHICLES]; 
Under the spawn car command
PHP код:
//Beside the create vehicle type
//new car = CreateVehicle(.....
Spawned[car] = true
Then under the respawn command
PHP код:
for(new 0MAX_VEHICLES;x++)
{
    if(
Spawned[x] == true)
    {
          
SetVehicleToRespawn(x); 
    }

I'm not sure but try


Re: Vehicle Problem. - ChristolisTV - 31.07.2015

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
Try this:
on the top of the script
PHP код:
new bool:Spawned[MAX_VEHICLES]; 
Under the spawn car command
PHP код:
//Beside the create vehicle type
//new car = CreateVehicle(.....
Spawned[car] = true
Then under the respawn command
PHP код:
for(new 0MAX_VEHICLES;x++)
{
    if(
Spawned[x] == true)
    {
          
SetVehicleToRespawn(x); 
    }

I'm not sure but try
Unfortunately I get these errors:
Код:
C:\Users\Chris\Desktop\GTA SAMP Test Server\filterscripts\CAdmin.pwn(409) : error 028: invalid subscript (not an array or too many subscripts): "Spawned"
C:\Users\Chris\Desktop\GTA SAMP Test Server\filterscripts\CAdmin.pwn(409) : error 017: undefined symbol "car"
C:\Users\Chris\Desktop\GTA SAMP Test Server\filterscripts\CAdmin.pwn(409) : error 029: invalid expression, assumed zero
C:\Users\Chris\Desktop\GTA SAMP Test Server\filterscripts\CAdmin.pwn(409) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: Vehicle Problem. - Variable™ - 31.07.2015

Removed.


Re: Vehicle Problem. - nezo2001 - 31.07.2015

how the code


Re: Vehicle Problem. - TheLegend1 - 31.07.2015

PHP код:
COMMAND:respawnallcars(playeridparams[])
{
    if(
P_DATA[playerid][alevel] < 4)return SendClientMessage(playerid,-1,"{FFFFFF}You must be{FF0000} Level 4{FFFFFF} to use this command."); 
    
SendClientMessageToAll(-1"{ff0000}(( WARNING: {FFFFFF}Unoccupied vehicles will be respawned in 20 seconds! {ff0000}))");
    
PlayerLoop(i)
    {
        
SetVehicleToRespawn(v); 
                new 
name[MAX_PLAYER_NAME],str[256]; 
     
GetPlayerName(playerid,name,sizeof(name)); 
     
format(str,sizeof(str),"{FFFF00}%s{FFFFFF} has respawned all vehicles!",name); 
     
SendClientMessageToAll(-1,str); 
    }
    return 
1;

try it