Respawn All Vehicles command. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn All Vehicles command. (
/showthread.php?tid=78538)
Respawn All Vehicles command. -
Badger(new) - 21.05.2009
hi. I attempted a command that respawns all vehicles. The command itself works, but all vehicles get respawned and then the server crashes.
I tried to get it to only respawn empty vehicles. Here is the code in the timer:
pawn Код:
public RespawnVeh()
{
for(new v=0; v<MAX_VEHICLES; v++)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i,v)){}
else SetVehicleToRespawn(v);
}
}
return 1;
}
What have I done wrong here, or is this way which I've done not possible?
Re: Respawn All Vehicles command. -
-eXo - 21.05.2009
From the LARP gamemode.
Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) // by Ellis
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
return 1;
}
new bool:unwanted[CAR_AMOUNT];
for(new player=0; player<MAX_PLAYERS; player++)
{
if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
}
for(new car = 1; car <= 268; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
BroadCast(COLOR_WHITE,string);
}
return 1;
}
Re: Respawn All Vehicles command. -
GammerZ - 21.05.2009
Код:
public RespawnVeh()
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
SetVehicleToRespawn(v);
}
return 1;
}
I hope that can help you
sorry my bad english
Re: Respawn All Vehicles command. -
Badger(new) - 21.05.2009
thanks exo. I'll try pick out the bits I need

.
thanka for replying GammerZ but, I could've easily done that bit myself, which I did, but in the second line of my first post
Quote:
Originally Posted by -The_Badger-
hi. I attempted a command that respawns all vehicles. The command itself works, but all vehicles get respawned and then the server crashes.
I tried to get it to only respawn empty vehicles. Here is the code in the timer:
|
it says I want to only respawn empty vehicles. Thanks anyway.
Re: Respawn All Vehicles command. -
Badger(new) - 21.05.2009
i changed it to go a different way, but now the server crashes. It respawns all vehicles except ones with players in but then no-one can join the server, although it is still online and it shows that players are connected, when they aren't.
Here is the code:
pawn Код:
public RespawnVeh()
{
new v;
new i;
while(v<340)
{
if(i>=200){SetVehicleToRespawn(v);v++;i=0;}
if(IsPlayerConnected(i)!=1)i++;
else if(!IsPlayerInVehicle(i,v))i++;
}
i=0;
v=0;
return 1;
}
i think it may be because I have:
pawn Код:
BV[0]=CreateVehicle(//etc);
lots of those so the vehicle ID would be whatever i have infront right?