Liberty Unleashed
Scripting => Script Help => Topic started 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
-
wut
-
wut
??? ??? ??? What ?
-
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.
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;
}
-
Dosen't Work :-\
-
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.
-
What Is The Error In This >>
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;
}
-
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.
-
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:
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.)