Comparing the health - 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: Comparing the health (
/showthread.php?tid=593043)
Comparing the health -
JaKe Elite - 01.11.2015
I am creating the 11th game of my X Games Series, and the type of game is derby.
I would like to know how can i compare all the vehicle's health (The player that is occupied on) and find the result which has the highest health (stable.)
Same goes to the Player Health.
Re: Comparing the health -
BroZeus - 01.11.2015
PHP код:
native IsValidVehicle(vehicleid);//on top
stock IsVehicleOccupied(vid)
{
for(new i = GetPlayerPoolSize(); i >= 0; i--)
{
if(!IsPlayerConnected(i)) continue;
if(GetPlayerVehicleID(i) == vid && GetPlayerSeat(playerid) == 0) return true;
}
return false;
}
stock Get_Vehicle_With_Highest_Health()
{
new Float:vh, Float:vh2, vid;
for(new i = GetVehiclePoolSize(); i >= 0; i--)
{
if(IsValidVehicle(i))
if(IsVehicleOccupied(i))
{
GetVehicleHealth(i, vh2);
if(vh2 > vh) { vh = vh2; vid = i; }
}
}
return vid;
}
You can apply same method with player health.
Re: Comparing the health -
JaKe Elite - 01.11.2015
I would try it out, Thank you.