Author Topic: Need help to display Best skilled players whille in game  (Read 1442 times)

Offline KAMIKAZE

  • Rank: Private
  • *
  • Posts: 6
    • http://stoneboys.forumotion.com/
Need help to display Best skilled players whille in game
« on: June 12, 2010, 09:52:34 pm »
Hello.

Recently friend of mine wrote one script for Best Skilled players in Axis and Allies so code is ok but we have no idea how to  display via hud on the screen or any other way. The idea is to Display the top players from the both teams on the top of the screen. Here is the code:

findSkillPlayer()
{
  self endon("disconnected");

  while(1)
  {
    
    players = getentarray("player", "classname");
    
    axisskill = undefined;
    alliesskill = undefined;
    
    axisscore = 0;
    alliesscore = 0;
    
    
     for(i = 0; i <players> alliesscore)
        {
          alliesscore = players.score;
          alliesskill = players;
        }
      
      }
      else if((isdefined(players.pers["team"])) && (players.pers["team"] == "axis"))
      {
        if (players.score > axisscore)
        {
          axisscore = players.score;
          axisskill = players;
        }
      }
     }
     
    self.info["nameaxis"] = axisskill.name;
    self.info["nameallies"] = alliesskill.name;
     
     wait 1;
  }
}


Any suggestions it will be welcome for all
 :)

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Need help to display Best skilled players whille in game
« Reply #1 on: June 13, 2010, 07:52:58 am »
Sorry to say, but that code won't run.
You also should not run that code as a player thread, but as a level thread.

// show highest scoring player
level thread showHighestScoringPlayer();


Try this instead:

Code: [Select]
showHighestScoringPlayer()
{
level endon("ex_gameover");

while(1)
{
wait(1);

players = getentarray("player", "classname");

winner = undefined;
tie = false;

for(i = 0; i < players.size; i++)
{
if(!isDefined( players[i].score )) continue;

if(players[i].score <1> winner.score)
{
winner = players[i];
tie = false;
}
else if(players[i].score == winner.score)
{
if(players[i].deaths < winner.deaths)
{
winner = players[i];
tie = false;
}
else if(players[i].deaths == winner.deaths)
tie = true;
}
}

if(isDefined(winner))
{
if(!isDefined(level.ex_topscore))
{
level.ex_topscore = newHudElem();
level.ex_topscore.archived = false;
level.ex_topscore.horzAlign = "fullscreen";
level.ex_topscore.vertAlign = "fullscreen";
level.ex_topscore.alignX = "center";
level.ex_topscore.alignY = "top";
level.ex_topscore.x = 320;
level.ex_topscore.y = 20;
level.ex_topscore.fontscale = 1.2;
level.ex_topscore.color = (0.705, 0.705, 0.392);
level.ex_topscore.label = &"MISC_TOPSCORE";
}

level.ex_topscore setPlayerNameString(winner);
}
}
}

Offline KAMIKAZE

  • Rank: Private
  • *
  • Posts: 6
    • http://stoneboys.forumotion.com/
Re: Need help to display Best skilled players whille in game
« Reply #2 on: June 14, 2010, 09:16:42 am »
Thank you so much PatmanSan the code is working,,,and i was wondering is it possible to dispaly ping whille in game or i need to open new topic for that or i'm asking too much questions  :oops:

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Need help to display Best skilled players whille in game
« Reply #3 on: June 14, 2010, 10:58:40 am »
No you can't get or display a player's ping from within a script. At least not that I'm aware of.

One remark about the code above: it uses a localized string TOPSCORE in file localizedstrings\MISC.str as a label. If you don't add it, you will see MISC_TOPSCORE on screen. So either disable disable that line by putting // in front of it, or add the localized string to the mod's iwd file.

Offline KAMIKAZE

  • Rank: Private
  • *
  • Posts: 6
    • http://stoneboys.forumotion.com/
Re: Need help to display Best skilled players whille in game
« Reply #4 on: June 15, 2010, 12:12:05 pm »
Yes i have recognize the problem and have create a string in my mode so problem is solved. Thanks again PatmanSan 8)

I'm just curious about the  level.topscore2.horzAlign = "fullscreen"; and level.topscore2.vertAlign = "fullscreen"; i mean about the command "fullscreen"  does it mean that with this if i set for example cordinates on the x and y  it will be dispayed corectly for players that they have monitors 4:3 and 16:9. For example i have monitor 4:3 19"inc so when i put coordinates  editing the mode i see them on the botom of the screen where i want them to be ..so if players on the server playing with 16:9 Widescreen monitor do they see the same coordinates of the displaying text that i set on the same place or is varible to them? Becouse i'm little confused on that thing ..in some scripts i find horzAlign = "right"; and vertAlign = "top";.  :?