SetVehicleHealth - 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: SetVehicleHealth (
/showthread.php?tid=600904)
SetVehicleHealth (+REP) ITS QUICK PPL -
Lirbo - 14.02.2016
1000 health = 100 Health precents
10000 health = 1300 Health precents... wtf?
how can i set 1000 health precents then?
Re: SetVehicleHealth -
Lirbo - 14.02.2016
bump cmon it's a silly question pls help me for 1 sec and get ur rep
Re: SetVehicleHealth -
Joron - 14.02.2016
What? 100% for what?
Re: SetVehicleHealth -
AmigaBlizzard - 14.02.2016
Show some code where it calculates that weird percent value.
10000 health should be 1000 percent.
How did you get 1300 percent?
There is no native function to check health in percent.
Re: SetVehicleHealth -
iKarim - 15.02.2016
PHP код:
Float:CalculatePercent(Float:value, Float:maxvalue) {
return ( (value / maxvalue ) * 100.0 );
}
Test:
PHP код:
printf("Value: %0.1f, Max: %0.1f, percent: %0.1f%%", 900.0, 1000.0, CalculatePercent(900.0, 1000.0));
printf("Value: %0.1f, Max: %0.1f, percent: %0.1f%%", 9000.0, 1000.0, CalculatePercent(9000.0, 1000.0));
printf("Value: %0.1f, Max: %0.1f, percent: %0.1f%%", 1000.0, 1000.0, CalculatePercent(1000.0, 1000.0));
printf("Value: %0.1f, Max: %0.1f, percent: %0.1f%%", 10000.0, 1000.0, CalculatePercent(10000.0, 1000.0));
printf("Value: %0.1f, Max: %0.1f, percent: %0.1f%%", 845.0, 1000.0, CalculatePercent(845.0, 1000.0));
Results:
PHP код:
[07:13:38] Value: 900.0, Max: 1000.0, percent: 90.0%
[07:13:38] Value: 9000.0, Max: 1000.0, percent: 900.0%
[07:13:38] Value: 1000.0, Max: 1000.0, percent: 100.0%
[07:13:38] Value: 10000.0, Max: 1000.0, percent: 1000.0%
[07:13:38] Value: 845.0, Max: 1000.0, percent: 84.5%
Re: SetVehicleHealth -
Nero_3D - 15.02.2016
Set the vehicle health to 7750 for 1000 Health Percent
PHP код:
#define CalcPercentVehicleHealth(%0) (((%0) * 75) / 10 + 250)