SA-MP Forums Archive
biggest health amount - 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: biggest health amount (/showthread.php?tid=301056)



biggest health amount - PawnoQ - 02.12.2011

hi,

how to detect the name of the player that is driving the vehicle with the most health?
This code does not work...

pawn Код:
forward Detector(playerid);
public Detector(playerid)
{
    foreach(Player,i)
    {
            new Float:MostHealth, Float:vHealth, vDriver, veh;
            for(new c = 0; c < MAX_VEHICLES; c++)
            {
                 GetVehicleHealth(c, vHealth);
                 if(vHealth > MostHealth)
                 {
                      MostHealth = vHealth;
                      veh = c;
                 }
            }
            vDriver = GetVehicleDriver(veh);
            new name[24];
            GetPlayerName(vDriver,name,24);
       }
return 1;
}



Respuesta: biggest health amount - OPremium - 02.12.2011

pawn Код:
forward Detector();
public Detector() //Playerid parameter is not needed here!
{
    new Float:MostHealth, Float:vHealth, vDriver = -1;
    foreach(Player, i)
    {
        if(GetPlayerVehicleSeat(i) != 0) continue; //Ignores passengers and players that aren't in a vehicle
        GetVehicleHealth(GetPlayerVehicleID(i), vHealth);
        if(floatcmp(MostHealth, vHealth) == -1) //Checks if the health is higher than the one saved previously
        {
            MostHealth = vHealth;
            vDriver = i;
        }
    }
    if(vDriver == -1) return 0; //No players online...
    new name[MAX_PLAYER_NAME];
    GetPlayerName(vDriver, name, MAX_PLAYER_NAME);
    //Whatever you want to do with the name
    return 1;
}



Re: biggest health amount - PawnoQ - 03.12.2011

thx but this also doesnt work.
It shows all names, not just the one of the person whos vehicle has the most health.
Any ideas?


Re: biggest health amount - PawnoQ - 03.12.2011

any other ideas?
This is really important

rep+ for sure


Re: biggest health amount - PawnoQ - 04.12.2011

please guys, i know some of you know whats wrong here
Would be very happy about help.