Check wich vehicle has the most health
#1

Hi all,

I got a question.

I am making a small derby mission but at the end i want it to say Playernames vehicle has the most health and won this round. Is it possible (with GetVehiclehealth or something??

Plz help.
Reply
#2

Please help me ...
Reply
#3

Just a little example how to do it:
pawn Код:
//somewhere
new Float:max = 0.00;
new winner = -1;
for(new i = 0; i < GetMaxPlayers(); i++)
{
  if(IsPlayerConnected(i))
  {
    if(PlayerInDerby[i] == 1)//or whatever you use to know that this player is in derby
    {
      if(IsPlayerInAnyVehicle(i))
      {
        new Float:h;
        GetVehicleHealth(GetPlayerVehicleID(i),h);
        if(h > max)
        {
          max = h;
          winner = i;
         }
       }
     
    }
  }
}
if(winner != -1)
{
  new name[MAX_PLAYER_NAME], string[80];
  GetPlayerName(winner,name,sizeof(name));
  format(string,sizeof(string),"%s's vehicle has the most health and won this round",name);
  SendClientMessageToAll(COLOR_WHITE,string);//or whatever color you need
}
Reply
#4

Quote:
Originally Posted by Sinyavski
Just a little example how to do it:
pawn Код:
//somewhere
new Float:max = 0.00;
new winner = -1;
for(new i = 0; i < GetMaxPlayers(); i++)
{
  if(IsPlayerConnected(i))
  {
    if(PlayerInDerby[i] == 1)//or whatever you use to know that this player is in derby
    {
      if(IsPlayerInAnyVehicle(i))
      {
        new Float:h;
        GetVehicleHealth(GetPlayerVehicleID(i),h);
        if(h > max)
        {
          max = h;
          winner = i;
        }
      }
     
    }
  }
}
if(winner != -1)
{
  new name[MAX_PLAYER_NAME], string[80];
  GetPlayerName(winner,name,sizeof(name));
  format(string,sizeof(string),"%s's vehicle has the most health and won this round",name);
  SendClientMessageToAll(COLOR_WHITE,string);//or whatever color you need
}
Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)