30.08.2010, 20:27
1. putting player in seat
2. saving the car ID when its created, and destroy when the player steps out
Add this on declarations:
Add this onplayerspawn:
This on the dialog when the player gets an vehicle:
And finally... this on OnPlayerStateChange (not on playerkeystatechange!)
pawn Код:
new temp_veh;
temp_veh = AddStaticVehicle(etc...)
PutPlayerInVehicle(playerid,temp_veh,0); //temp_veh is the vehicle ID, and 0 is the driver's seat
Add this on declarations:
pawn Код:
IsVehicleCreatedForPlayer[MAX_PLAYERS];
pawn Код:
IsVehicleCreatedForPlayer[playerid] = -1; //setting the value standard on -1 (so not created for player)
pawn Код:
IsVehicleCreatedForPlayer[playerid] = temp_veh; //assigning the car ID
pawn Код:
if (IsVehicleCreatedForPlayer[playerid] >-1) //if its not -1, so an spawned vehicle (assigned with the id)
{
if (oldstate == PLAYER_STATE_DRIVER)
{
DestroyVehicle(IsVehicleCreatedForPlayer[playerid]); //destroying the car
IsVehicleCreatedForPlayer[playerid] = -1; //resetting state
}
}