HP bar shows vehicle HP? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: HP bar shows vehicle HP? (
/showthread.php?tid=195673)
HP bar shows vehicle HP? -
Spiral - 03.12.2010
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?
Re: HP bar shows vehicle HP? -
WillyP - 03.12.2010
GetVehicleHeath
SetPlayerHeath
Re: HP bar shows vehicle HP? -
Spiral - 03.12.2010
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
Re: HP bar shows vehicle HP? -
Steven82 - 03.12.2010
Make a textdraw for it, or use the progress bar include.
Re: HP bar shows vehicle HP? -
Scenario - 03.12.2010
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).
Re: HP bar shows vehicle HP? -
Seven. - 03.12.2010
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);
}
}
Re: HP bar shows vehicle HP? -
Arrows73 - 03.12.2010
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)
Re: HP bar shows vehicle HP? -
Seven. - 03.12.2010
xD just a example i've done quick