Health Problem (little help, please) - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health Problem (little help, please) (
/showthread.php?tid=216490)
Health Problem (little help, please) -
[BR]Michael - 25.01.2011
Hello all!
I'm having a problem with health in my server, I did a system that uses a variable (pHealth) to store a player's health and calculate his damage, but when I set his health higher, the "Update" function sets it back to the previous value.
OBS: sometimes it works normally.
Codes:
Код:
#define UPDATE_HEALTH 4
new pUpdate[MAX_PLAYERS];
new Float:pHealth[MAX_PLAYERS];
stock SetPlayerSysHealth(playerid, Float:health)
{
pHealth[playerid] = health;
SetPlayerHealth(playerid, pHealth[playerid]);
return pUpdate[playerid] |= UPDATE_HEALTH;
}
stock AddPlayerSysHealth(playerid, Float:health)
{
pHealth[playerid] += health;
SetPlayerHealth(playerid, pHealth[playerid]);
return pUpdate[playerid] |= UPDATE_HEALTH;
}
stock GetPlayerSysHealth(playerid, &Float:health)
health = pHealth[playerid];
public OnGameModeInit()
{
SetTimer("Update", 50, true);
}
public Update()
{
for(new n = 0; n < MAX_PLAYERS; n++)
{
if(IsPlayerConnected(n) && IsPlayerLogged(n))
{
if(pUpdate[n] & UPDATE_HEALTH)
{
if(pHealth[n] < 1.0)
pHealth[n] = 1.0;
if(pHealth[n] > 100.0)
pHealth[n] = 100.0;
SetPlayerHealth(n, pHealth[n]);
pUpdate[n] &= ~UPDATE_HEALTH;
}
else
{
new Float:H;
GetPlayerHealth(n, H);
if(H < pHealth[n])
{
new Float:D;
D = pHealth[n] - H;
SetPlayerSysHealth(n, H);
OnPlayerDamage(n, D);
}
}
}
}
}
That's it! Thanks a lot, and sorry for my bad english!
Re: Health Problem (little help, please) -
[BR]Michael - 26.01.2011
Help, please...
Re: Health Problem (little help, please) -
Grim_ - 26.01.2011
I'm sorry, but just can't understand what you are trying to accomplish here (it's currently 2:44 AM, so I am tired). If you could give me a list, step by step, of what you are trying to do, I would appreciate it.
Re: Health Problem (little help, please) -
Steven Paul - 26.01.2011
@Grim_ i think you need a rest
@topic are you trying to say that if you set someone health then after it update's it go back to default
Re: Health Problem (little help, please) -
[BR]Michael - 26.01.2011
When I 'increase' the health, it go back to default
Re: Health Problem (little help, please) -
[BR]Michael - 27.01.2011
Help :S