Liberty Unleashed

Scripting => Script Help => Topic started by: Mido_Pop on June 24, 2013, 09:08:37 am

Title: Some Help
Post by: Mido_Pop 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
Title: Re: Some Help
Post by: Shadow. on June 24, 2013, 10:35:35 am
wut
Title: Re: Some Help
Post by: Mido_Pop on June 24, 2013, 10:44:22 am
wut

 ??? ??? ??? What ?
Title: Re: Some Help
Post by: Vortrex 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;
}
Title: Re: Some Help
Post by: Mido_Pop on June 24, 2013, 05:18:00 pm
Dosen't Work  :-\
Title: Re: Some Help
Post by: Force 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.
Title: Re: Some Help
Post by: Mido_Pop 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;
}
Title: Re: Some Help
Post by: Vortrex 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.
Title: Re: Some Help
Post by: Thijn 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.)