Destroy all empty 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: Destroy all empty vehicles? (
/showthread.php?tid=307416)
Destroy all empty vehicles? -
XxCozzaxX - 30.12.2011
Код:
public VehicleCheck()
{
new empty = false;
new currentveh;
for(new i =0; i != MAX_VEHICLES; ++i)
{
for (new x = 0; x != MAX_PLAYERS; ++x)
{
if(GetPlayerVehicleID(x) != i)
{
empty = true;
currentveh = i;
}
}
}
if(empty)
{
DestroyVehicle(currentveh);
}
}
This is the code I wrote to attempt to destroy all empty vehicles.
I called it using a timer that runs every 1 second (1000ms) and it doesn't seem to clear up any vehicles that have no one in them. Any ideas?
Re: Destroy all empty vehicles? -
Spooky - 30.12.2011
pawn Код:
stock VehicleCheck(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++) //All players
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
{
if(GetPlayerVehicleID(i) == vehicleid)
{
return 1;
}
}
}
return 0;
}
Use this.
Inlcude the Destroy Function also. Its not included