need help
#2

Use this:
pawn Код:
#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;
}
Reply


Messages In This Thread
need help - by nicoud - 06.10.2010, 00:33
Re: need help - by Miguel - 06.10.2010, 02:41
Re: need help - by nicoud - 06.10.2010, 19:22
Re: need help - by Miguel - 07.10.2010, 03:27
Re: need help - by nicoud - 07.10.2010, 10:45

Forum Jump:


Users browsing this thread: 1 Guest(s)