straher
???
- Joined
- Mar 23, 2010
- Messages
- 255
- Reaction score
- 3
Hi, my system counts frags as storage values and I'd like to add top 5 storage broadcast. Can anyone help me with it?
I've found those 2 pieces of code:
This one casts broadcast but it doesn't take frag amounts from storage but killers
db query:
I've found those 2 pieces of code:
This one casts broadcast but it doesn't take frag amounts from storage but killers
Lua:
[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 COUNT(*) as count FROM killers WHERE death_id IN (SELECT kill_id FROM player_killers) AND " .. getPlayerGUID(cid) .. " IN (SELECT player_id FROM player_killers WHERE kill_id = death_id)")
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
db query:
PHP:
$i = 0;
foreach($SQL->query('SELECT `p`.`name` AS `name` , `value` AS `storagevalue`
FROM `player_storage` k
LEFT JOIN `players` p ON `k`.`player_id` = `p`.`id`
WHERE `k`.`key` =6776
GROUP BY `name`
ORDER BY CAST( `value` AS SIGNED ) DESC
LIMIT 0 , 30;') as $player)
Last edited: