vehiclehealt = playerhealth
#1

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.
Reply
#2

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 ..
Reply
#3

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...
Reply
#4

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)