/adminveh
#1

How to make it when a player writes /adminveh if he has already created a vehicle to clear it?
Reply
#2

You can create a variable for each player which saves the last ID of vehicle that has been created by him.
Код:
new LastVehicleID[MAX_PLAYERS];
Reset and delete it on join and on leave.
Код:
public OnPlayerConnect(playerid)
{
    LastVehicleID[playerid] = INVALID_VEHICLE_ID;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(LastVehicleID[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(LastVehicleID[playerid]);
    LastVehicleID[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
And when you spawn a new vehicle just check whether the LastVehicleID is valid or not.
Код:
if(LastVehicleID[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(LastVehicleID[playerid]);
Don't forget to assign the ID of the new vehicle after it's spawned.
Код:
LastVehicleID[playerid] = CreateVehicle(...);
Reply
#3

Tnx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)