Respawn all unused cars by model - 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 all unused cars by model (
/showthread.php?tid=449199)
Respawn all unused cars by model -
deimantas1 - 07.07.2013
Hello, me need a code, whick respawn all unused cars by model.
Thanks.
Re: Respawn all unused cars by model -
Jefff - 07.07.2013
pawn Код:
bool:IsVehicleEmpty(vehicleid)
{
for(new i=0; i != MAX_PLAYERS; i++)
if(IsPlayerConnected(i))
if(IsPlayerInVehicle(i,vehicleid))
return false;
return true;
}
RespawnUnusedVehicleByModel(modelid)
{
for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++)
if(GetVehicleModel(vehicleid) == modelid)
if(IsVehicleEmpty(vehicleid))
SetVehicleToRespawn(vehicleid):
}
Re: Respawn all unused cars by model -
DobbysGamertag - 07.07.2013
pawn Код:
COMMAND:respawncars(playerid,params[])
{
for(new i = 0; i<MAX_VEHICLES; i++)
{
if(GetVehicleModel(i) == Car model here)
{
if(!IsVehicleOccupied(i))
{
SetVehicleToRespawn(i);
}
}
}
return 1;
}
Wrong section, but i've tested, it works fine for me

you need zcmd for it to work.
edit: heres the stock
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
return 1;
return 0;
}
Re: Respawn all unused cars by model -
deimantas1 - 07.07.2013
Thanks, working.