• 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!

[Global-event] Requesting 'King' script

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
247
Solutions
1
Reaction score
40
Location
Ankrahmun
hello otlanders,
i tried to make a script but i fail, simply it was made to show up text above the highest player (storage) on the server and if there are two players have got the same storage it checks another storage(storage2) so that it shows as the server highest players
im using tibia 8,60 windows server 0.3.6
LUA:
local str1 = 1005
local str2 = 1074
local players = {}

function onThink(interval)
for _, name in  ipairs(getOnlinePlayers()) do
            local cid = getPlayerByName(name)
            local rebs = getPlayerRebirth(cid)
            local pos = getPlayerPosition(cid)
            table.insert(players, rebs)
            if rebs > 0 then
            local top = table.maxn(players)
            if top > 0 then
            doSendAnimatedText(getPlayerPosition(top), 'King', 180)
            end
            end
            end
            return true
            end
REP++

edited

maybe a script like this but it select the high score rebirth player, then level
Code:
local ranks = {

['fist'] = {0},

['club'] = {1},
['sword'] = {2},
['axe'] = {3},
['distance'] = {4},
['shield'] = {5},
['fish'] = {6},
['magic'] = {7},
['level'] = {8},
['Reborn'] = {9},

}




function onSay(cid, words, param)

local msg = string.lower(param)
if ranks[msg] ~= nil then
str = getHighscoreString((ranks[msg][1]))
else
str = getHighscoreString((8))
end
doShowTextDialog(cid,6500, str)
return TRUE

end

bump
 
Last edited by a moderator:
Since getPlayerRebirth is a custom function we need to have that code aswell.
But here is a cleaner code atleast, but it you still need to check who has the highest storage.

LUA:
local players = {}
function onThink(interval)
    for _, cid in  ipairs(getPlayersOnline()) do
        players = getPlayerRebirth(cid)
        if #players > 0 then
            doSendAnimatedText(getPlayerPosition(cid), 'King', 180)
        end
    end

    return true
end
 
This may work for you:
LUA:
local str1 = 1005
local str2 = 1074

local players = {}
function onThink(interval)
    local lowestStr1 = 0
    local player = 0
    for _, cid in  ipairs(getPlayersOnline()) do
        local store1 = getPlayerStorageValue(cid,str1)
        players = getPlayerRebirth(cid)
        if #players > lowestStr1 then
            player = cid
            lowestStr1 = #players
        elseif #players == lowestStr1 then
            if(getPlayerStorageValue(cid, str2) > getPlayerStorageValue(player, str2)) then
                player = cid
                lowestStr1 = #players
            end
        end
    end
    doSendAnimatedText(getPlayerPosition(player), 'King', 180)

    return true
end

Untested and POOMA. Hope you can fix any bugs.
 
Back
Top