If you rename a variable the result still not going to change xd Forget this script, i wrote it before you said you need 2nd and 3rd players too. I copied a link above about the insertion sort, use that to sort the players by exp. After you're ready, you have to only print (or put in cvars) the first 3 elements of the sorted array.
EDIT: I thought you will never write the script, so:
PHP Code:
checkStatus()
{
level.brakdanych = "^1BRAK DANYCH";
places = [];
places[0] = []; // 1st player
places[1] = []; // 2nd player
places[2] = []; // 3rd player
players = getEntArray("player", "classname");
// take invalid players from the array
array = [];
for (i = 0; i < players.size; i++)
{
player = players[ i ];
if (! isDefined(player.pers["team"]) || player.pers["team"] == "spectator")
continue;
array[ array.size ] = players[ i ];
}
// sort the 'players' array by exp
array = array_sort_by_exp(array);
// set places
for (i = 0; i < places.size; i++)
{
if (isDefined(array[ i ])) {
places[ i ]["player"] = array[ i ];
places[ i ]["name"] = array[ i ].name;
places[ i ]["exp"] = array[ i ].sexp;
places[ i ]["rank"] = array[ i ].poziom;
} else {
places[ i ]["player"] = undefined;
places[ i ]["name"] = level.brakdanych;
places[ i ]["exp"] = level.brakdanych;
places[ i ]["rank"] = level.brakdanych;
}
}
// set cvars for all players
for (i = 0; i < players.size; i++)
{
player = players[ i ];
player setClientCvar("first_player",
"first Player: Name:" + places[0]["name"] +
" His Exp IS:" + places[0]["exp"] +
" His rank IS:" + places[0]["rank"]);
player setClientCvar("second_player",
"second Player: Name:" + places[1]["name"] +
" His Exp IS:" + places[1]["exp"] +
" His rank IS:" + places[1]["rank"]);
player setClientCvar("third_player",
"third Player: Name:" + places[2]["name"] +
" His Exp IS:" + places[2]["exp"] +
" His rank IS:" + places[2]["rank"]);
}
}
array_sort_by_exp(array)
{
temp = array;
for (i = 0; i < temp.size - 1; i++)
{
for (j = i + 1; j < temp.size; j++)
{
if (temp[ i ].sexp > temp[ j ].sexp)
{
var = temp[ i ];
temp[ i ] = temp[ j ];
temp[ j ] = var;
}
}
}
return temp;
}