Hello i have problem with top fraggers.
TFS 3.6 V8, tibia 8.6
15:35 Top 2 fraggers online:
1. Gruby - 0 frags
2. Zxdruid - 0 frags
In datababase have Players with table frags.
They have in database Gruby 40 frags and Zxdruid 21 frags.
Plz help
[27/04/2014 15:39:20] Error during getDataInt(count).
[27/04/2014 15:39:20] Error during getDataInt(count).
[27/04/2014 15:39:20] > Broadcasted message: "Top 2 fraggers online:
[27/04/2014 15:39:20] 1. Gruby - 0 frags
[27/04/2014 15:39:20] 2. Zxdruid - 0 frags".
TFS 3.6 V8, tibia 8.6
15:35 Top 2 fraggers online:
1. Gruby - 0 frags
2. Zxdruid - 0 frags
In datababase have Players with table frags.
They have in database Gruby 40 frags and Zxdruid 21 frags.
Plz help
[27/04/2014 15:39:20] Error during getDataInt(count).
[27/04/2014 15:39:20] Error during getDataInt(count).
[27/04/2014 15:39:20] > Broadcasted message: "Top 2 fraggers online:
[27/04/2014 15:39:20] 1. Gruby - 0 frags
[27/04/2014 15:39:20] 2. Zxdruid - 0 frags".
Code:
local config = {
limit = 5
}
function onThink(interval, lastExecution)
local t, ret, tmp = {}, "Top " .. math.min(config.limit, getWorldCreatures(0)) .. " fraggers online:"
for _, cid in ipairs(getPlayersOnline()) do
tmp = db.getResult("SELECT * FROM `players` ORDER BY `frags` DESC LIMIT 5")
table.insert(t, {cid, tmp:getDataInt("count")})
tmp:free()
end
table.sort(t, function(a,b) return a[2] > b[2] end)
for i = 1, math.min(#t, config.limit) do
ret = ret .. "\n" .. i .. ". " .. getPlayerName(t[i][1]) .. " - " .. t[i][2] .. " frags"
end
return doBroadcastMessage(ret)
end