SA-MP Forums Archive
[SOLVED] SetPlayerHealth help needed - 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: [SOLVED] SetPlayerHealth help needed (/showthread.php?tid=116539)



[SOLVED] SetPlayerHealth help needed - Madykevy - 29.12.2009

Hello,

I have a command

buyappel.

And i want if you type that command you get +20 health.
Now it sets your health to 20.

Can someone help me


Re: SetPlayerHealth help needed - M4S7ERMIND - 29.12.2009

Код:
if(GetPlayerHealth(playerid) > 80) SetPlayerHealth(playerid, 100);
else SetPlayerHealth(playerid, GetPlayerHealth(playerid)+20);



Re: SetPlayerHealth help needed - _[HuN]_Epsilon_ - 29.12.2009

Use my function istead of SetPlayerHealth(playerid,20)

This macro above your command maybe over the main() function.
// GivePlayerHealth(playerid,health) /* GetHealth function needed! */
#define GivePlayerHealth(%1,%2) SetPlayerHealth(%1,floatadd(GetHealth(%1),%2))

This goes to the bottom of you script.
pawn Код:
Float: GetHealth(id)
{
    new Float: pp;
    GetPlayerHealth(id,pp);
    return pp;
}
And the function: GivePlayerHealth(playerid,20);

_________________________________________________

Quote:
Originally Posted by Mастерминд
Код:
if(GetPlayerHealth(playerid) > 80) SetPlayerHealth(playerid, 100);
else SetPlayerHealth(playerid, GetPlayerHealth(playerid)+20);
This wont work


Re: SetPlayerHealth help needed - M4S7ERMIND - 29.12.2009

hmm.. playerid, in your macro, should be %1.. right?
#define GivePlayerHealth(%1,%2) SetPlayerHealth(%1,floatadd(GetHealth(%1),%2))

Quote:
Originally Posted by [HUN
Epsilon ]
Quote:
Originally Posted by Mастерминд
Код:
if(GetPlayerHealth(playerid) > 80) SetPlayerHealth(playerid, 100);
else SetPlayerHealth(playerid, GetPlayerHealth(playerid)+20);
This wont work
Alright, I fixed it
pawn Код:
new Float:phealth;
GetPlayerHealth(playerid, phealth);
if(phealth > 80) SetPlayerHealth(playerid, 100);
else SetPlayerHealth(playerid, phealth+20);



Re: SetPlayerHealth help needed - Double-O-Seven - 29.12.2009

pawn Код:
stock GivePlayerHealth(playerid,Float:health)
{
    new Float:tmp_health;
    GetPlayerHealth(playerid,tmp_health);
    tmp_health+=health;
    if(tmp_health>100.0)
        tmp_health=100.0;  
    else if(tmp_health<0.0)
        tmp_health=0.0;
    return SetPlayerHealth(playerid,tmp_health);
}



Re: [SOLVED] SetPlayerHealth help needed - Madykevy - 29.12.2009

I made it on a other way.
But thanks for the help