respawning 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: respawning help (
/showthread.php?tid=332682)
respawning help -
RicaNiel - 09.04.2012
Guys how to respawn all cars
except those who has players inside on it
Re: respawning help -
.FuneraL. - 09.04.2012
Example Command:
pawn Код:
if(strcmp("/respawncars", cmdtext, true) == 0)
{
new Name[MAX_PLAYER_NAME];
new string[256]
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s Respawned All Cars!", Name);
SendClientMessageToAll(0xFFFFFFFF, string);
for(new i = 1; i <= MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
return 1;
}
Re: respawning help -
WarriorEd22 - 09.04.2012
This was taken from the Lux Admin script; just modify it according to your own needs.
pawn Код:
dcmd_respawncars(playerid,params[])
{
#pragma unused params
if(AccInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, green, "|- Your have Successfully Respawned all Vehicles! -|");
GameTextForAll("~n~~n~~n~~n~~n~~n~~r~Vehicles ~g~Respawned!", 3000,3);
for(new cars=0; cars<MAX_VEHICLES; cars++)
{
if(!VehicleOccupied(cars))
{
SetVehicleToRespawn(cars);
}
}
return 1;
}
else return ErrorMessages(playerid, 1);
}
Re: respawning help -
RicaNiel - 09.04.2012
like i said except those who has players inside on it
so vehicles who has players inside on it wont be respawned
Re: respawning help -
ReneG - 09.04.2012
Just thought of it right now, lemme know if it works.
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
foreach(Player,i)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
{
return 1;
}
else
{
return 0;
}
}
}
}
pawn Код:
CMD:respawncars(playerid,params[])
{
for(new i=0, i<MAX_VEHICLES; i++);
{
if(!IsVehicleOccupied(i)) // will only respawn unoccupied vehicles
{
SetVehicleToRespawn(i);
}
}
SendClientMessage(playerid, -1, "SERVER: Cars Respawned");
return 1;
}