help with car spawning
#1

i made a car spawn in my gamemode with like car name /greenwood
it spawns but how i make it where when i spawn another the vehicle destoys ur last one
also how to destroy that spawned vehicle OnVehicleDeath
using strcmp command processer
Reply
#2

So CreateVehicle returns a value. You need to assign that value to something like playercar[playerid]

Код:
playercar[playerid] = CreateVehicle(etc so forth);
To destroy it:

Код:
if(playercar[playerid] != INVALID_VEHICLE_ID)
{
    DestroyVehicle(playercar[playerid]);
    playercar[playerid] = INVALID_VEHICLE_ID;
}
You can add the destroy code to the beginning of your command, and in OnVehicleDeath (sort-of)

OnVehicleDeath:
Код:
for(new i; i < MAX_PLAYERS; i++)
{
    if(playercar[i] == vehicleid)
    {
        DestroyVehicle(playercar[i]);
        playercar[i] = INVALID_VEHICLE_ID;
        break; //(or would return be better?)
    }
}
EDIT: make sure you are destroying the vehicle in OnPlayerDisconnect too, or you'll have orphans.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)