• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Globalevent - Top Ranking

Niloahs

Well-Known Member
Joined
Feb 10, 2020
Messages
115
Solutions
1
Reaction score
84
Need help to make not show GM or GOD on this script plz

LUA:
local config = {
    topCount = 10,
    messageType = MESSAGE_EVENT_ADVANCE,
    interval = 30 * 60 * 1000 -- 1 minutes for each
}

local currentTopType = 1
local topTypes = {
    { 'Level', Player.getLevel },
    -- { 'Magic Level', Player.getMagicLevel },
    -- { 'Sword', Player.getSkillLevel },
    -- { 'Distance', Player.getSkillLevel },
    -- { 'Shield', Player.getSkillLevel }
    --{ 'Fish', Player.getSkillLevel },
    --{ 'Fist', Player.getSkillLevel }
}

local globalEvent = GlobalEvent("TopLevelOnline")
function globalEvent.onThink(interval)
    local type = topTypes[currentTopType]
    local getSkill = type[2]
    local types = #topTypes
    currentTopType = math.min(types, currentTopType +1)
    if currentTopType == types then
        currentTopType = 1
    end
    local players = Game.getPlayers()
    local count = math.min(config.topCount, #players)
    if count > 0 then
        if count > 1 then
            table.sort(players, function(a, b) return getSkill(a) > getSkill(b) end)
        end
        local description = string.format("~ Top %d Online / %s ~\n\n", config.topCount, type[1])
        for i = 1, count do
            local p = players[i]
            description = string.format("%s%d) %s - %d%s", description, i, p:getName(), getSkill(p), (i == count and "" or "\n"))
        end
        broadcastMessage(description, config.messageType)
    end
    return true
end
globalEvent:interval(config.interval)
globalEvent:register()
 
Solution
X
uhhhh, try this.
LUA:
local config = {
	topCount = 10,
	messageType = MESSAGE_EVENT_ADVANCE,
	interval = 30 * 60 * 1000 -- 1 minutes for each
}

local currentTopType = 1
local topTypes = {
	{ 'Level', Player.getLevel },
	-- { 'Magic Level', Player.getMagicLevel },
	-- { 'Sword', Player.getSkillLevel },
	-- { 'Distance', Player.getSkillLevel },
	-- { 'Shield', Player.getSkillLevel }
	--{ 'Fish', Player.getSkillLevel },
	--{ 'Fist', Player.getSkillLevel }
}

local globalEvent = GlobalEvent("TopLevelOnline")
function globalEvent.onThink(interval)
	local type = topTypes[currentTopType]
	local getSkill = type[2]
	local types = #topTypes
	currentTopType = math.min(types, currentTopType +1)
	if currentTopType == types then
		currentTopType = 1
	end
	local...
uhhhh, try this.
LUA:
local config = {
	topCount = 10,
	messageType = MESSAGE_EVENT_ADVANCE,
	interval = 30 * 60 * 1000 -- 1 minutes for each
}

local currentTopType = 1
local topTypes = {
	{ 'Level', Player.getLevel },
	-- { 'Magic Level', Player.getMagicLevel },
	-- { 'Sword', Player.getSkillLevel },
	-- { 'Distance', Player.getSkillLevel },
	-- { 'Shield', Player.getSkillLevel }
	--{ 'Fish', Player.getSkillLevel },
	--{ 'Fist', Player.getSkillLevel }
}

local globalEvent = GlobalEvent("TopLevelOnline")
function globalEvent.onThink(interval)
	local type = topTypes[currentTopType]
	local getSkill = type[2]
	local types = #topTypes
	currentTopType = math.min(types, currentTopType +1)
	if currentTopType == types then
		currentTopType = 1
	end
	local onlineList = Game.getPlayers()
	local players = {}
	for _, targetPlayer in ipairs(onlineList) do
		if not targetPlayer:getGroup():getAccess() then
			table.insert(players, targetPlayer)
		end
	end
	local count = math.min(config.topCount, #players)
	if count > 0 then
		if count > 1 then
			table.sort(players, function(a, b) return getSkill(a) > getSkill(b) end)
		end
		local description = string.format("~ Top %d Online / %s ~\n\n", config.topCount, type[1])
		for i = 1, count do
			local p = players[i]
			description = string.format("%s%d) %s - %d%s", description, i, p:getName(), getSkill(p), (i == count and "" or "\n"))
		end
		broadcastMessage(description, config.messageType)
	end
	return true
end
globalEvent:interval(config.interval)
globalEvent:register()
 
Solution

Similar threads

Back
Top