Help - System - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help - System (
/showthread.php?tid=637571)
Help - System -
Jorgeeee - 17.07.2017
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?
Re: Help - System -
aoky - 17.07.2017
Possibly could do OnPlayerUpdate, can you show us the code?
Re: Help - System -
Jorgeeee - 17.07.2017
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?
Re: Help - System -
FailerZ - 17.07.2017
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?
Re: Help - System -
Jorgeeee - 17.07.2017
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.
Re: Help - System -
JasonRiggs - 17.07.2017
You mean when player stops moving? Like in Sleeping Dogs?
Re: Help - System -
Jorgeeee - 17.07.2017
Quote:
Originally Posted by JasonRiggs
You mean when player stops moving? Like in Sleeping Dogs?
|
Yes, when he stops moving, life recovers ...
Re: Help - System -
JasonRiggs - 17.07.2017
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
Re: Help - System -
Jorgeeee - 17.07.2017
I wanted it to pop up little by little, how can I do this check in onplayerupdate?