First commit
This commit is contained in:
		
							
								
								
									
										31
									
								
								app/SabrehavenServer/data/talkactions/scripts/online.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								app/SabrehavenServer/data/talkactions/scripts/online.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
local maxPlayersPerMessage = 10
 | 
			
		||||
 | 
			
		||||
function onSay(player, words, param)
 | 
			
		||||
	if not player:getGroup():getAccess() then
 | 
			
		||||
		return true
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if player:getAccountType() < ACCOUNT_TYPE_GOD then
 | 
			
		||||
		return false
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local hasAccess = player:getGroup():getAccess()
 | 
			
		||||
	local players = Game.getPlayers()
 | 
			
		||||
	local onlineList = {}
 | 
			
		||||
 | 
			
		||||
	for _, targetPlayer in ipairs(players) do
 | 
			
		||||
		if hasAccess or not targetPlayer:isInGhostMode() then
 | 
			
		||||
			table.insert(onlineList, ("%s [%d]"):format(targetPlayer:getName(), targetPlayer:getLevel()))
 | 
			
		||||
		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
 | 
			
		||||
		Reference in New Issue
	
	Block a user