Hi. I need help making a command that destroys all vehicles spawned with a command
#1

Hi i was looking to make a command that destroys all vehicles spawned with a command. Because sometimes players might just start to have fun spawning random cars than have a pile of cars sitting somewhere blocking the roads and etc.
Reply
#2

Can you show the command you use to spawn vehicles?
Reply
#3

Create a variable that stores all the spawned vehicles.
Код:
new spawned_vehicles[MAX_PLAYERS][MAX_VEHICLES];
Once you spawn a vehicle, assign it's id to the variable.
Код:
spawned_vehicles[playerid][vehicleid] = 1; // '1' means that the vehicle is spawned.
When you want to destroy all player's spawned vehicles, use:
Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(spawned_vehicles[playerid][i] == 1)
{
DestroyVehicle(i);
spawned_vehicles[playerid][i] = 0;
}
}
Reply
#4

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Create a variable that stores all the spawned vehicles.
Код:
new spawned_vehicles[MAX_PLAYERS][MAX_VEHICLES];
Once you spawn a vehicle, assign it's id to the variable.
Код:
spawned_vehicles[playerid][vehicleid] = 1; // '1' means that the vehicle is spawned.
When you want to destroy all player's spawned vehicles, use:
Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(spawned_vehicles[playerid][i] == 1)
{
DestroyVehicle(i);
spawned_vehicles[playerid][i] = 0;
}
}
That will destroy the vehicles that the playerid have spawned
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)