local amountOfTopsToDisplay = 5
addCommandHandler ( "top",
function ( player, command, value )
if ( value == "wins" or value == "points" ) then
local tableOrder = { }
for i, v in ipairs ( getAccounts ( ) ) do
table.insert (
tableOrder,
{
name = getAccountData ( v, "nick" ) or getAccountName ( v ),
data = getAccountData ( v, value )
}
)
end
table.sort (
tableOrder,
function ( a, b )
return ( tonumber ( a.data ) or 0 ) > ( tonumber ( b.data ) or 0 )
end
)
outputChatBox ( "#c0c0c0* Top 5 #abcdef".. value, player, 255, 255, 255, true )
for i = 1, amountOfTopsToDisplay do
outputChatBox ( "#c0c0c0* #abcdef".. i .."#c0c0c0. #abcdef".. tostring ( tableOrder [ i ].name ) .." #c0c0c0- #abcdef".. tostring ( tableOrder [ i ].data ), player, 255, 255, 255, true )
end
else
outputChatBox ( "#c0c0c0* Syntax : #abcdef/top #c0c0c0[#abcdefwins #c0c0c0| #abcdefpoints#c0c0c0]", player, 255, 255, 255, true )
end
end
)
You can do that, so if the account doesn't has 'nick' data, it'll set name as account name.