[SOLVED] SetPlayerHealth help needed
#1

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
Reply
#2

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

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
Reply
#4

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);
Reply
#5

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);
}
Reply
#6

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


Forum Jump:


Users browsing this thread: 8 Guest(s)