28.11.2011, 10:38
Quote:
Thanks now it works fine, but would you just explain to me what you just did? so I can learn..
your first post was easier to understand, but this one a little complicated :P |
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(seatbelt[playerid])
{
new Float:x, Float:y, Float:z;
SetPVarInt(playerid, "VehicleExited", vehicleid);
SetPVarInt(playerid, "VehicleSeat", GetPlayerVehicleSeat(playerid));
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
SetTimerEx("EnterBack", 600, false, "i", playerid);
SendClientMessage(playerid, 0xAFAFAFAA, " You must take your seatbelt off first! (/seatbelt)");
}
return 1;
}
forward EnterBack(playerid);
public EnterBack(playerid)
{
PutPlayerInVehicle(playerid, GetPVarInt(playerid, "VehicleExited"), GetPVarInt(playerid, "VehicleSeat"));
DeletePVar(playerid, "VehicleExited");
return DeletePVar(playerid, "VehicleSeat");
}
- Create three new variables: x, y, z. These are all floats, as we're storing the player's position.
- The PVar "VehicleExited" is set to the vehicleid the player is currently trying to exit.
- The PVar "VehicleSeat" is set to where the player is sitting (seatid) in vehicleid.
- Then, it will get the player's position (GetPlayerPos) and store their values in x, y, z.
- It will set the player's position on top of the vehicle (SetPlayerPos).
- It will set a timer to call the function "EnterBack" in 600 milliseconds (which is 0.6 seconds, 1000 milliseconds is 1 second, etc).
- It will send them a message, saying they have to take their seatbelt off first.
The EnterBack function:
- Puts the player back into the vehicle as soon as it's called.
- Deletes the 2 PVars we used: VehicleSeat and VehicleExited.
Here's more information on the functions we've used in that code (they are links, click them!).
SetPVarInt
GetPVarInt
SetPlayerPos
GetPlayerPos
SetTimerEx
OnPlayerExitVehicle