vehiclehealt = playerhealth - 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)
+--- Thread: vehiclehealt = playerhealth (
/showthread.php?tid=292432)
vehiclehealt = playerhealth -
cruising - 23.10.2011
Hello!
How do i let a player lose health as his vehicle looses health? i mean the player dies just before the vehicle explode or something like that.
Re: vehiclehealt = playerhealth -
Michael@Belgium - 24.10.2011
pawn Код:
new Float:vehhealth;
GetVehicleHealth(GetPlayerVehicleID(playerid),vehhealth);
SetPlayerHealth(playerid,vehhealth/100);
Actually this isn't gonna work, but when i get home i'll send the ... correct calculation ..
Re: vehiclehealt = playerhealth -
Jesus_wow - 24.10.2011
Quote:
Originally Posted by Michael@Belgium
pawn Код:
new Float:vehhealth; GetVehicleHealth(GetPlayerVehicleID(playerid),vehhealth); SetPlayerHealth(playerid,vehhealth[B]/100[/B]);
Actually this isn't gonna work, but when i get home i'll send the ... correct calculation .. 
|
Why you put /100, isnt it /10 , because the car have 1000 HP, and the player have 100HP , the difference is 1000/100 = 10 i think...
Re: vehiclehealt = playerhealth -
Babul - 24.10.2011
not to forget that a vehicle starts burning @ 250 HP, so the player would get 25 HP @ vehicledeath, but he deserves 0:
Код:
new VehID=GetPlayerVehicle(playerid);
new Health=(GetVehicleHealth(VehID)-250.0)/10;
SetPlayerHealth(playerid,health);
but since the offset is 250.0, we need to scale the actual healthrange (0.0 to 75.0) up to (0.0 to 100.0),
this can be done by dividing Health by 3 (75/3=25), and multiplying it with 4:
Код:
new VehID=GetPlayerVehicle(playerid);
new Health=(GetVehicleHealth(VehID)-250.0)*40/25;
SetPlayerHealth(playerid,health);