HP bar shows vehicle HP?
#1

Hey folks,

So I'm trying to do something, which sets the vehicle HP to the player's HP. Like, 1000 vehicle hp would be 100 HP and if the player crashes, his HP goes down as much as vehicle's one did. But ex, if i crash with 500 damage vehicle HP would be 500 HP as it should and player HP would be 50. Any help doing this?
Reply
#2

GetVehicleHeath
SetPlayerHeath
Reply
#3

Sure its like that using both of these functions. But it sets the player health to 1000, so how do I change it? Also, a bit of code would be good
Reply
#4

Make a textdraw for it, or use the progress bar include.
Reply
#5

Quote:
Originally Posted by Spiral
Посмотреть сообщение
Sure its like that using both of these functions. But it sets the player health to 1000, so how do I change it? Also, a bit of code would be good
You could store the players health into a variable (or PVar) then set the health according to the vehicles health. When the player exits the vehicle, then set their health to what you stored in the variable (or PVar).
Reply
#6

maybe something like this?

Just a idea, dunno if it works.. ;p

pawn Код:
public Hpsetter(playerid)
{
    new vehhealth[MAX_PLAYERS];
    GetVehicleHealth(playerid, vehhealth[playerid]);
    if(vehhealth[playerid] == 1000) return SetPlayerHealth(playerid, 100);
    else if(vehhealth[playerid] == 900) return SetPlayerHealth(playerid, 90);
    else if(vehhealth[playerid] == 800) return SetPlayerHealth(playerid, 80);
    }
}
Reply
#7

Just set the player's health to (Carhealth/10) + cast the resulting float value to int (floatround) [https://sampwiki.blast.hk/wiki/Floatround]

EDIT: Seven was faster but thats exactly what I meant (however, you do not have to make 1000 'if's xD)
Reply
#8

xD just a example i've done quick
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)