How to add Health to current....
#1

Well I was trying to figure this out but I couldn't so what I wanted to do is add health to the players current health for ex. player has 50 hp and he uses a command that gives him +20hp how would i do that?
Reply
#2

You would get the current health, then set the health to varhealth+20.

pawn Code:
new Float:HP;
GetPlayerHealth(playerid, HP);
SetPlayerHealth(playerid, HP+20);
Reply
#3

thanks m8
Reply
#4

it works with vehicles too?

Code:
new Float:HP;
GetVehicleHealth(playerid, HP);
SetVehicleHealth(playerid, HP+20);
yes?
Reply
#5

Correct mate.
Reply
#6

i was looking for this, thanks
Reply
#7

it kinda doesn't work :/
Code:
if(!strcmp(cmdtext, "/taisyti", true))
	{
 		if(playerDB[playerid][specialybe]!=13){SendClientMessage(playerid,RED,"* this command is only for mechanik!"); return 1;}
        if(!IsPlayerInAnyVehicle(playerid)){
				SendClientMessage(playerid,RED,"* you're not in a car");
				return 1;
		}
		if(GetPlayerMoneyA(playerid)<50)
	    {
		    SendClientMessage(playerid,RED,"* price for 100hp is 50lt");
		    return 1;
		}
		GivePlayerMoneyA(playerid,-50);
  		SendClientMessage(playerid,GREEN,"* added 100hp to vehicle!");
  		if(IsPlayerInAnyVehicle(playerid))
GetVehicleHealth(playerid, carHP);
SetVehicleHealth(playerid, carHP+100);
  		return 1;
 	}
and in top of gamemode i added

Code:
new Float:carHP;
Reply
#8

i;ve made it
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)