Car Destory Help X2 (Different)
#9

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.
Reply


Messages In This Thread
Car Destory Help X2 (Different) - by RandomDude - 12.07.2013, 16:25
Re: Car Destory Help X2 (Different) - by RandomDude - 12.07.2013, 17:10
Re: Car Destory Help X2 (Different) - by kristo - 12.07.2013, 17:39
Re: Car Destory Help X2 (Different) - by RandomDude - 12.07.2013, 18:18
Re: Car Destory Help X2 (Different) - by RandomDude - 12.07.2013, 18:23
Re: Car Destory Help X2 (Different) - by JimmyCh - 12.07.2013, 18:31
Re: Car Destory Help X2 (Different) - by kristo - 12.07.2013, 18:45
Re: Car Destory Help X2 (Different) - by RandomDude - 13.07.2013, 14:14
Re: Car Destory Help X2 (Different) - by Konstantinos - 13.07.2013, 14:18
Re: Car Destory Help X2 (Different) - by RandomDude - 13.07.2013, 14:19

Forum Jump:


Users browsing this thread: 1 Guest(s)