#include <a_samp> #include <a_player> #include <a_vehicle> public OnPlayerUpdate(playerid) { new float:X, float:Y, float:Z; new vehicleid = GetPlayerVehicleID(playerid); if (GetVehicleModel(vehicleid) == 592) { if (PRESSED( KEY_ANALOG_DOWN )) GetVehiclePos(vehicleid, X, Y, Z); SetPlayerCheckpoint(vehicleid, X, Y, Z); } return 1; } new float:X, float:Y, float:Z; new vehicleid = GetPlayerVehicleID(playerid); if (GetVehicleModel(vehicleid) == 592) { if (PRESSED( KEY_ANALOG_UP )) GetVehiclePos(vehicleid, X, Y, Z); DisablePlayerCheckpoint(vehicleid, X, Y, Z); } return 1; }
#include <a_samp>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new bool:IsActivated[MAX_PLAYERS] = {false, ...}; // variable to know if the checkpoint is activated
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) // callback to check for player keys
{
if(PRESSED(KEY_ANALOG_DOWN)) IsActivated[playerid] = true; // if the analog down key was pressed we set the variable to true
else if(PRESSED(KEY_ANALOG_UP)) // if the analog up key was pressed the variable is set to false
{
DisablePlayerCheckpoint(playerid); // we also delete the checkpoint
IsActivated[playerid] = false;
}
return 1;
}
public OnPlayerUpdate(playerid) // we use this callback to update the checkpoint position
{
if(IsActivated[playerid] == true) // we first check if the variable is activated
{
new
Float:x,
Float:y,
Float:z;
if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z); // if the player is in a car we need its vehicle's pos
else GetPlayerPos(playerid, x, y, z); // if not then we need the PLAYER'S POSITION
SetPlayerCheckpoint(playerid, x, y, z); // after we get the position we set it to the checkpoint
}
return 1;
}
Originally Posted by nicoud
can you help me now how to make the player teleport on the checkpoint InIt?
|