please help me with jump
#1

Hello All i want to set when the player jump no -hp plesae how

+ rep who is help me
Reply
#2

All what i can advice you, is to set player health into 99999 Once he connects.
Reply
#3

Pretty simple using a timer whenever the player presses the JUMP key.
NOTE, the timer interval must be set accordingly. I prefer a 2 seconds timer but each jump differs.

pawn Код:
new nohptimer[MAX_PLAYERS] = -1;

public OnPlayerConnect(playerid)
{
    nohptimer[playerid] = -1;
    return 1;
}

forward OnPlayerReachGround(playerid, Float:health);
public OnPlayerReachGround(playerid, Float:health)
{
    nohptimer[playerid] = -1;
    SetPlayerHealth(playerid, health);
    return 1;
}

//just to make sure player updating and taking damage is not effected by the timer

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
    nohptimer[playerid] = -1;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
    nohptimer[playerid] = -1;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
    nohptimer[playerid] = -1;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
    nohptimer[playerid] = -1;
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_JUMP)
    {
        new Float:health;
        GetPlayerHealth(playerid, health);

        if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
        nohptimer[playerid] = SetTimerEx("OnPlayerReachGround", 2 * 1000, false, "if", playerid, health);
    }
    return 1;
}
Those extra checks done in the callbacks are there so that no player updating is affected by the timer.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)