Author Topic: Some Help  (Read 2494 times)

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Some Help
« on: June 24, 2013, 09:08:37 am »
How To Get The Highest Score In A Massage ?
I Mean I Need To Write The Highest Score Player Name In A Massage . :P



Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Some Help
« Reply #1 on: June 24, 2013, 10:35:35 am »
wut

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Some Help
« Reply #2 on: June 24, 2013, 10:44:22 am »



Vortrex

  • Full Member
  • ***
  • Posts: 264
  • Karma: +54/-74
    • View Profile
Re: Some Help
« Reply #3 on: June 24, 2013, 04:20:41 pm »
This is untested, but I think it should work. All you have to do is loop through players, and see if their score is higher than the currently highest player in the loop. The function below will return a pointer to the player.

Code: [Select]
function GetHighestScoringPlayer( )
{
local highest = FindPlayer( 0 );
for( i = 0; i<= GetMaxPlayers( ); i++ )
{
if( FindPlayer( i ) )
{
if( highest )
{
if( FindPlayer( i ).Score > highest.Score )
{
highest = FindPlayer( i );
}
}
else
{
highest = FindPlayer( i );
}
}
}
return highest;
}

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Some Help
« Reply #4 on: June 24, 2013, 05:18:00 pm »
Dosen't Work  :-\



Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Some Help
« Reply #5 on: June 24, 2013, 08:57:58 pm »
You need to actually do something, other than just put that function in your code. The amount of people that blindly copy and paste is ridiculous.
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Some Help
« Reply #6 on: June 24, 2013, 11:09:55 pm »
What Is The Error In This >>
Code: [Select]
function onScriptLoad( )
{
   NewTimer( "Pop", 1000, 1 );
}

function Pop()
{
local highest = FindPlayer( 0 );
for( i = 0; i<= GetMaxPlayers( ); i++ )
{
if( FindPlayer( i ) )
{
if( highest )
{
if( FindPlayer( i ).Score > highest.Score )
{
highest = FindPlayer( i );
                                        MessagePlayer( ""+ FindPlayer( i ) +" The King .", player );
}
}
else
{
highest = FindPlayer( i );
}
}
}
return highest;
}



Vortrex

  • Full Member
  • ***
  • Posts: 264
  • Karma: +54/-74
    • View Profile
Re: Some Help
« Reply #7 on: June 25, 2013, 01:20:04 am »
You need to actually do something, other than just put that function in your code. The amount of people that blindly copy and paste is ridiculous.

Reminds me of this old saying:
Give a man a fish, he'll eat for a day. Teach the man to fish, and he'll eat for a lifetime.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 526
  • Karma: +27/-17
    • View Profile
Re: Some Help
« Reply #8 on: June 25, 2013, 12:50:13 pm »
What Is The Error In This >>
Like Vortrex said:
The function below will return a pointer to the player.

So you have to do something with that pointer. Something like:
Code: [Select]
function showHighestScore() {
local plr = GetHighestScoringPlayer();
if ( plr ) {
Message("Highest score: " + plr.Score + " by " + plr.Name);
}
}

(I'm writing this on the forum, so excuse me for no tabs.)

 

© Liberty Unleashed Team.