[HELP] CreateVehicle cars respawning
#1

Hello! I have a admin script where you can spawn cars. Once those cars blow up, they respawn in the same place they were created. I would like to make it so they don't spawn once they are destroyed - they just disappear all together. They are created with CreateVehicle, so they aren't static.

I used DestroyVehicle under OnVehicleRespawn, but it effects the non-admin vehicles as well.

I was wondering if there is another way to do this, or if there is a way to assign the admin vehicles a vehicle-specific name or something that sets it apart from the others, so I can tell DestroyVehicle to destroy ONLY the admin vehicles.

Thanks guys!

- Haegon
Reply
#2

new admincar = CreateVehicle...

DestroyVehicle(admincar);
Reply
#3

The only thing with that, is it only deletes the last vehicle created. Is it possible to destroy all of the admin vehicles, or am I missing something? :P
Reply
#4

Maybe try putting the destroyvehicle(admincar) in public onvehicledeath
Reply
#5

That was worth a shot but it didn't work. It successfully destroyed the last one of the 3 I made to test it on, but the other two respawned. =|

Thanks for the try though. =)
Reply
#6

You need to either create an array to store all of your spawned vehicles - or limit the amount of a vehicles an admin can spawn.
Reply
#7

Make a /deleteveh command and make it a admin only command .
Reply
#8

I currently have what I might mistakingly be calling an array of cars to control my random car spawns. I'm not sure if I can utilize that for this purpose as well? Here is the code.

Код:
new RandCars[] = {
400,401,404,410,
421,422,426,439, 
445,461,466,467,
474,477,479,482, // Here are the random car ID's that are allowed to spawn.
483,489,491,492,
496,500,507,516,
517,518,526,533,
540,542,545,554,
555,559,565,576,
581,600,602,605
};

enum eCars
{
	model_id,
	Float:pos_x,
	Float:pos_y, // The eCars enum.
	Float:pos_z,
	Float:z_angle,
};

for (new i; i < sizeof CarSpawns; i++)   //Random mumbo jumbo of code.
    AddStaticVehicleEx( RandCars[random(sizeof RandCars)], CarSpawns[i][pos_x], CarSpawns[i][pos_y], CarSpawns[i][pos_z], CarSpawns[i][z_angle], -1, -1, 100000);
Somewhere inbetween the top two and the last bit of code is all the coordinates for the cars to spawn at.

I'm not sure if this is quite what you were referring to or not, so I figured i'd show off a little code. :P
Reply
#9

Quote:
Originally Posted by XoSarahMoX
Посмотреть сообщение
Make a /deleteveh command and make it a admin only command .
Actually, that's what I temporarily have in place now, but it only deletes the one the admin is in. I'm aiming to make it like a sort of cleanup tool and delete all admin vehicles that aren't occupied.
Reply
#10

Maybe make it so when the admin does /deleteveh it does

DeleteVehicle(playerid, admincar);

Wouldnt that delete all cars with the admincar variable representing them? Not sure though :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)