Quote:
Originally Posted by kvann
pawn Код:
new lastcar[MAX_PLAYERS];
native IsValidVehicle(vehicleid);
public OnPlayerConnect(playerid) { lastcar[playerid] = -1; return 1; }
public OnPlayerStateChange(playerid, newstate, oldstate) { if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT) { if (IsValidVehicle(lastcar[playerid])) DestroyVehicle(lastcar[playerid]); lastcar[playerid] = GetPlayerVehicleID(playerid); } else if (newstate == PLAYER_STATE_ONFOOT) lastcar[playerid] = -1; return 1; }
I also added some extra checks that aren't needed but make it a bit safer.
|
That should work, but an advise. Check if the vehicleid the player is in is not the one lastcar[playerid] "holds", because it will delete the player's current vehicle.
EDIT: So when he spawns a second, to destroy the first one. Then go to your command and destroy the vehicle. Store the vehicleid when you create the vehicle.