Help - System
#1

Hello friends, I found a system to recover life by pressing a key, however I wanted to recover life alone, without pressing the key, it is possible ?, instead of putting functions in the onkeystage, wanted to verify if the player is stopped, has Any way to do this?
Reply
#2

Possibly could do OnPlayerUpdate, can you show us the code?
Reply
#3

Quote:
Originally Posted by aoky
Посмотреть сообщение
Possibly could do OnPlayerUpdate, can you show us the code?
pawn Код:
#include <a_samp>

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new Timer[MAX_PLAYERS];

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(Timer[playerid]);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_CROUCH))
    {
        new Float:Vida;
        GetPlayerHealth(playerid, Vida);
        if(Vida <= 100)
        {
            Timer[playerid] = SetTimerEx("LifeA", 1000, 1, "i", playerid);
        }
        else return TieneVida(playerid);
    }
    if(oldkeys == KEY_CROUCH)
    {
        KillTimer(Timer[playerid]);
    }
    return 1;
}

forward LifeA(playerid);
public LifeA(playerid)
{
    new Float:Vida;
    GetPlayerHealth(playerid, Vida);
    if(Vida == 100)
    {
        KillTimer(Timer[playerid]);
        return 1;
    }
    SetPlayerHealth(playerid, Vida+1);
    return 1;
}

stock LifeB(playerid)
{
    SendClientMessage(playerid, -1,"");
    return 1;
}
But how do I do this verification?
Reply
#4

When do you want it to recover alone?
Like when the player dies and no body kills him? or if admin used command on some player? or what exactly?
Reply
#5

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
When do you want it to recover alone?
Like when the player dies and no body kills him? or if admin used command on some player? or what exactly?
I want it when the player goes without moving, starts to fill the life.
Reply
#6

You mean when player stops moving? Like in Sleeping Dogs?
Reply
#7

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
You mean when player stops moving? Like in Sleeping Dogs?
Yes, when he stops moving, life recovers ...
Reply
#8

Maybe try to make a GetSpeed stock or something, add it under OnPlayerUpdate, and if it is equal to 0, SetPlayerHealth to 100 or smth
Reply
#9

I wanted it to pop up little by little, how can I do this check in onplayerupdate?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)