health
#1

How can I increase players health like by +5 or 10 when they buy a drink?
Reply
#2

Do you currently have a system for purchasing drinks?

if so, I need to know what variable you use for health.

But it will look something like this;
Код:
playerVariables[playerid][pHealth] += 5;
Add that to the command for purchasing a drink, should work but again you need to adapt it to your script.
Reply
#3

No im using just a dialog. no zcmd nothing.
Reply
#4

pawn Код:
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health + 5.0);
Reply
#5

pawn Код:
new Float:Health;
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health+10.0);
if(Health > 100.0)
{
    SetPlayerHealth(playerid, 100.0);
}
_______________
EDIT: Haha, too late.
Reply
#6

C:\Users\Oscar\Desktop\*\Modern Life Roleplay [Oscar]\Modern Life Roleplay [Oscar]\pawno\include\func.inc(109) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Oscar\Desktop\*\Modern Life Roleplay [Oscar]\Modern Life Roleplay [Oscar]\pawno\include\func.inc(387) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Oscar\Desktop\*\Modern Life Roleplay [Oscar]\Modern Life Roleplay [Oscar]\pawno\include\func.inc(453) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Oscar\Desktop\*\Modern Life Roleplay [Oscar]\Modern Life Roleplay [Oscar]\pawno\include\func.inc(492) : warning 219: local variable "health" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Warnings.
Reply
#7

You already got the health variable defined,

pawn Код:
new Float:healthtwo;
GetPlayerHealth(playerid, healthtwo);
SetPlayerHealth(playerid, healthtwo + 5.0);
Reply
#8

Try this:
pawn Код:
new Float:DrinkH;
GetPlayerHealth(playerid, DrinkH);
SetPlayerHealth(playerid, DrinkH+10.0);
if(DrinkH > 100.0)
{
    SetPlayerHealth(playerid, 100.0);
}
or just delete the new Float:health; that you added.
I think you should use my method because if you drink too much you'll get more life than normal, mine sets it to normal. Your choose.

Best regards!
Reply
#9

I found one that works thanks anyway rep + for helping me.

new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid,hp+5);
Reply
#10

Now I need to know how to save current position when disconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)