Increase Health
#1

hi, im wondering how you can increase health like for example, you walk into a checkpoint and it gives you 5 more health, im trying to do this but it just sets to that health level

any help?
Reply
#2

something like this? (not tested)
Код:
new oldhealth,newhealth;
GetPlayerHealth(playerid,oldhealth);
if(oldhealth<95) newhealth = oldhealth+5;
else newhealth = 100;
SetPlayerHealth(playerid,newhealth);
Reply
#3

pawn Код:
new Float:health; GetPlayerHealth(playerid,health);
if(health >= 95) SetPlayerHealth(playerid,100);
else SetPlayerHealth(playerid, floatround(health) + 5);
Reply
#4

what is floataround, i get error with it :S
Reply
#5

It's floatround, it rounds to the nearest integer.
Reply
#6

Quote:
Originally Posted by GreenHammy
what is floataround, i get error with it :S
Typo, floatround it is.
Reply
#7

you need to say what kind of rounding,
see here: https://sampwiki.blast.hk/wiki/Floatround
and here: https://sampwiki.blast.hk/wiki/Scripting...Old#floatround
Reply
#8

lol of course, thanks it works
Reply
#9

Quote:
Originally Posted by Sergei
Посмотреть сообщение
pawn Код:
new Float:health; GetPlayerHealth(playerid,health);
if(health >= 95) SetPlayerHealth(playerid,100);
else SetPlayerHealth(playerid, floatround(health) + 5);
can u put timer to do that code automaticly incearse 5 value per 10 sec
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)