Posts: 85
Threads: 37
Joined: Sep 2016
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?
Posts: 493
Threads: 82
Joined: Oct 2016
Reputation:
0
Possibly could do OnPlayerUpdate, can you show us the code?
Posts: 85
Threads: 37
Joined: Sep 2016
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?
Posts: 241
Threads: 18
Joined: Oct 2013
Reputation:
0
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?
Posts: 85
Threads: 37
Joined: Sep 2016
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.
Posts: 851
Threads: 33
Joined: Jul 2016
Reputation:
0
You mean when player stops moving? Like in Sleeping Dogs?
Posts: 85
Threads: 37
Joined: Sep 2016
Quote:
Originally Posted by JasonRiggs
You mean when player stops moving? Like in Sleeping Dogs?
|
Yes, when he stops moving, life recovers ...
Posts: 851
Threads: 33
Joined: Jul 2016
Reputation:
0
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
Posts: 85
Threads: 37
Joined: Sep 2016
I wanted it to pop up little by little, how can I do this check in onplayerupdate?