2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2025-07-05 20:38:02 +00:00
RedisBungee/src/main/resources/lua/get_player_count.lua
2015-12-06 16:39:03 -05:00

25 lines
468 B
Lua

local c = redis.call
local curTime = c("TIME")
local time = tonumber(curTime[1])
local heartbeats = c("HGETALL", "heartbeats")
local total = 0
local key
for _, v in ipairs(heartbeats) do
if not key then
key = v
else
local n = tonumber(v)
if n then
if n + 30 >= time then
total = total + c("SCARD", "proxy:" .. key .. ":usersOnline")
end
end
key = nil
end
end
return total