04.11.2017, 13:27
You can create a variable for each player which saves the last ID of vehicle that has been created by him.
Reset and delete it on join and on leave.
And when you spawn a new vehicle just check whether the LastVehicleID is valid or not.
Don't forget to assign the ID of the new vehicle after it's spawned.
Код:
new LastVehicleID[MAX_PLAYERS];
Код:
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; }
Код:
if(LastVehicleID[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(LastVehicleID[playerid]);
Код:
LastVehicleID[playerid] = CreateVehicle(...);