Very simple Question Rep+
#1

EDIT: Another Question: How would I get a players health then subtract like -5 health from it? Using GetPlayerHealth and SetPlayerHealth, Thanks.
Reply
#2

pawn Код:
PlayerInfo[playerid][pHunger]-=69;
Decrease by 69.
Reply
#3

PlayerInfo[playerid][pHunger] -= 255;

Theres (http://wiki.amxmodx.org/Pawn#Expressions)
= : Set
++ : Add 1
-- : Minus 1
+= : Add
-= : Subtract
*= : Multiply
/= : Divide
... And more but these are real basic Mathmatical Operators.
Reply
#4

Updated main post with another help question
Reply
#5

pawn Код:
new Float: fHealth;
GetPlayerHealth(playerid, fHealth);
SetPlayerHealth(playerid, fHealth-5);
Subtraction with floats is just as simple as it is with integers.
Reply
#6

Thanks everyone, you guys helped me create my hunger system!
Reply
#7

Heres how I would do it:

pawn Код:
new health;
health = GetPlayerHealth(playerid);
health = health-5;
SetPlayerHealth(playerid, health);
EDIT: I was too late with my answer ^ ^ :P Someone got there first
Reply
#8

^ Unneed lined though and it's a variable not a float.
Reply
#9

Quote:
Originally Posted by Cody_Maverak
Посмотреть сообщение
Heres how I would do it:

pawn Код:
new health;
health = GetPlayerHealth(playerid);
health = health-5;
SetPlayerHealth(playerid, health);
That wouldn't work, GetPlayerHealth returns a float to the variable that is the second parameter of the function, you can't use integers and you've written the function parameters incorrectly.

https://sampwiki.blast.hk/wiki/GetPlayerHealth
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)