Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
876 B
6
Indexable
Never
local maxPlayersPerMessage = 10

function onSay(player, words, param)
	local players = Game.getPlayers()
	local onlineList = {}
    local hasAccess = player:getGroup():getAccess()

	for _, targetPlayer in ipairs(players) do
        if hasAccess or targetPlayer:isInGhostMode() then
    		if player:canSeeCreature(targetPlayer) then
    			table.insert(onlineList, ("%s [%d]"):format(targetPlayer:getName(), targetPlayer:getLevel()))
    		end
        end
	end

	local playersOnline = #onlineList
	player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ("%d players online."):format(playersOnline))

	for i = 1, playersOnline, maxPlayersPerMessage do
		local j = math.min(i + maxPlayersPerMessage - 1, playersOnline)
		local msg = table.concat(onlineList, ", ", i, j) .. "."
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, msg)
	end
	return false
end