SA-MP Forums Archive
Respawn vehicles.. - 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: Respawn vehicles.. (/showthread.php?tid=149964)



Respawn vehicles.. - DevilRP - 24.05.2010

how can i make it so if i do a command i respawn all vehicles?


Re: Respawn vehicles.. - Jeffry - 24.05.2010

pawn Code:
for(new i=0; i<MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
Not tested, I dont know if it will work.


Re: Respawn vehicles.. - LTomi - 24.05.2010

pawn Code:
if(strcmp("/respawnallcars", cmdtext, true) == 0)
{
   for(new i = 0; i < MAX_VEHICLES; i++)
   {
     SetVehicleToRespawn(i);
   }
   return 1;
}
EDIT: Ahh, Jeffry was faster. :P


Re: Respawn vehicles.. - DevilRP - 24.05.2010

Thanks for the help guys, but how can i make it so only rcon admins can do that
?



Re: Respawn vehicles.. - LTomi - 24.05.2010

pawn Code:
if(strcmp("/respawnallcars", cmdtext, true) == 0)
{
   if(IsPlayerAdmin(playerid))
   {
     for(new i = 0; i < MAX_VEHICLES; i++)
     {
        SetVehicleToRespawn(i);
     }
     SendClientMessage(playerid, COLOR_GREEN, "You have respawned all vehicles.");
   }
   else
   {
     SendClientMessage(playerid, COLOR_RED, "You are not an admin.");
   }
   return 1;
}



Re: Respawn vehicles.. - Jeffry - 24.05.2010

Wow, fast discussion, I was just testing it.
LTomi's code will work.


Re: Respawn vehicles.. - dice7 - 24.05.2010

Slight edit:

pawn Code:
if(strcmp("/respawnallcars", cmdtext, true) == 0)
{
   if(IsPlayerAdmin(playerid))
   {
     for(new i = 1; i <= MAX_VEHICLES; i++)
     {
        SetVehicleToRespawn(i);
     }
     SendClientMessage(playerid, COLOR_GREEN, "You have respawned all vehicles.");
   }
   else
   {
     SendClientMessage(playerid, COLOR_RED, "You are not an admin.");
   }
   return 1;
}
since vehicle ids start with 1 and end with MAX_VEHICLES


Re: Respawn vehicles.. - DevilRP - 24.05.2010

Thanks!


Re: Respawn vehicles.. - LTomi - 24.05.2010

Quote:
Originally Posted by dice7
Slight edit:

pawn Code:
if(strcmp("/respawnallcars", cmdtext, true) == 0)
{
  if(IsPlayerAdmin(playerid))
  {
     for(new i = 1; i <= MAX_VEHICLES; i++)
     {
       SetVehicleToRespawn(i);
     }
     SendClientMessage(playerid, COLOR_GREEN, "You have respawned all vehicles.");
  }
  else
  {
     SendClientMessage(playerid, COLOR_RED, "You are not an admin.");
  }
  return 1;
}
since vehicle ids start with 1 and end with MAX_VEHICLES
Yes, you are right.


Re: Respawn vehicles.. - DevilRP - 24.05.2010

edit, fixed it thanks!