Destroy All Cars - 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: Destroy All Cars (
/showthread.php?tid=273959)
Destroy All Cars -
SamyRomafia - 04.08.2011
Where i can find a function "Destroyallcars", but this function don't destroy a occupied vehicle.
I have search in the forum but i dont have find any commands.
Sorry for bad eng.
Re: Destroy All Cars -
=WoR=Varth - 04.08.2011
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
DestroyVehicle(i);
}
Re: Destroy All Cars -
SamyRomafia - 04.08.2011
Quote:
Originally Posted by varthshenon
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++) { DestroyVehicle(i); }
|
Thanks, but this destroy all vehicle, i don't want to destroy a occupied vehicle.
Re: Destroy All Cars -
=WoR=Varth - 04.08.2011
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
new count = 0;
for(new a=0;a<MAX_PLAYERS;a++)
{
if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a))
{
if(GetPlayerVehicleID(a) == i) count++;
}
}
if(count > 0)
{
DestroyVehicle(i);
}
}
Re: Destroy All Cars -
SamyRomafia - 04.08.2011
Quote:
Originally Posted by varthshenon
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++) { new count = 0; for(new a=0;a<MAX_PLAYERS;a++) { if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a)) { if(GetPlayerVehicleID(a) == i) count++; } } if(count > 0) { DestroyVehicle(i); } }
|
This destory only a occupied vehicle, i don't want to destroy a occupied vehicle and to destroy unoccupied vehicle.
Re: Destroy All Cars -
=WoR=Varth - 04.08.2011
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
new count = 0;
for(new a=0;a<MAX_PLAYERS;a++)
{
if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a))
{
if(GetPlayerVehicleID(a) == i) count++;
}
}
if(count == 0)
{
DestroyVehicle(i);
}
}
Re: Destroy All Cars -
Scenario - 04.08.2011
I would use
foreach to do this if I were you.