SA-MP Forums Archive
respawn all 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: respawn all vehicles (/showthread.php?tid=235377)



respawn all vehicles - Madsen - 05.03.2011

i am trying to make a command that respawns all vehicles this is what i have made so far
Код:
// at the top
new vehicles[MAX_VEHICLES];

// OnPlayerCommandText(playerid, cmdtext[])

if (strcmp("/respawnallvehicles", cmdtext, true, 10) == 0)
	{
   	 	RepairVehicle(vehicles[MAX_VEHICLES]);
		SetVehicleToRespawn(vehicles[MAX_VEHICLES]);
		return 1;
	}



Re: respawn all vehicles - HyperZ - 05.03.2011

Command:
pawn Код:
if (strcmp("/respawnallvehicles", cmdtext, true, 10) == 0)
{
    for(new cars=0; cars<MAX_VEHICLES; cars++)
    {
        if(!VehicleOccupied(cars))
        {
            SetVehicleToRespawn(cars);
            RepairVehicle(cars);
        }
    }
    return 1;
}
Somewhere in your script:
pawn Код:
forward VehicleOccupied(vehicleid);
public VehicleOccupied(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerInVehicle(i,vehicleid)) return 1;
    }
    return 0;
}



Re: respawn all vehicles - Madsen - 05.03.2011

hmm xD, i was not even close :P