local topAmount = 5
local fragTime = configManager.getNumber(configKeys.FRAG_TIME)
function onThink(creature, interval)
local text = ''
local players = {}
for _, playerId in ipairs(Game.getPlayers()) do
local skullTime = playerId:getSkullTime()
if skullTime > 0 then
players[#players + 1] = {}
players[#players][1] = playerId
players[#players][2] = math.ceil(skullTime / fragTime)
end
end
if #players < 2 then
return false
end
table.sort(players, function(a, b) return a[2] > b[2] end)
-- just incase there is less then topAmount of pkers
local maxAmount = topAmount < #players and topAmount or #players
for i = 1, maxAmount do
text = text .. players[i][1]:getName() .. (i == maxAmount and '.' or ', ')
end
broadcastMessage('The top ' .. maxAmount .. ' fraggers on the server are ' .. text, MESSAGE_STATUS_WARNING)
return true
end