biggest health amount
#1

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;
}
Reply
#2

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;
}
Reply
#3

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

any other ideas?
This is really important

rep+ for sure
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)