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

Noblity System

Pedrook

Advanced OT User
Joined
May 24, 2009
Messages
442
Solutions
3
Reaction score
183
Location
Brazil
I was thinking of a system that every Gold, Platinum, Crystal that was donated you would earn a ranking

example of 1 GP up to 500k - Knight
1kk up to 4kk - Barao

from 5kk to 25kk - Duke

from 50kk to 100kk - King

can add in the look the title, was thinking of making a title in the site tb as if it were archiv, or every 1min appear an effect in the different char and upload an emote text of the current ranking. If anyone is interested in the idea, in the future, of doing quests, or houses, only p such title, or a ranking of the noblest and rich :)
 
Solution
It could be done in many different ways: onThink events etc. Here is a version based on what you presented.

Lua:
local config = {
    interval = 5,
    ranks = {
        {minBalance = 100, rankName = "Knight", effect = CONST_ME_FIREWORK_RED},
        {minBalance = 1000, rankName = "Duke", effect = CONST_ME_FIREWORK_RED},
        {minBalance = 10000, rankName = "King", effect = CONST_ME_FIREWORK_RED},
    },
}

local function getRankByBalance(balance)
    for i = 1, #config.ranks do
        if balance < config.ranks[i].minBalance then
            return (i - 1 > 0) and (i - 1) or false
        end
    end
    return false
end

local function sendEffectTopPlayer(cid, rank)
    local player = Player(cid)
    if not player then...
Which tfs?
tfs 1.2

up

I need some help. I would like to do 1 table with 5 ranks for example

[rank1]
[rank2]
[rank3]
[rank4]
[rank5]

and each rank you're earning a name with effect.
if I have 1 gp up to 100k be rank5
from 100k up to 500k be rank4 and so on, if anyone can help me :)

player:say('rank1', TALKTYPE_MONSTER_SAY)
player:say('rank2, TALKTYPE_MONSTER_SAY)
player:say('rank3, TALKTYPE_MONSTER_SAY)
player:say('rank4, TALKTYPE_MONSTER_SAY)
player:say('rank5, TALKTYPE_MONSTER_SAY)


Code:
local function getHighestPlayer()
    local resultId = db.storeQuery("SELECT `name`, `balance` FROM `players` WHERE `balance` > 5000000 ORDER BY `balance` DESC LIMIT 1")
    if not resultId then
        return false
    end
    return result.getDataString(resultId, "name")
end
local config = {
    interval = 5,
    effect = CONST_ME_FIREWORK_RED
}
local function sendEffectTopPlayer(cid)
    local player = Player(cid)
    if not player then
        return true
    end
    player:getPosition():sendMagicEffect(config.effect)
    addEvent(sendEffectTopPlayer, config.interval * 1000, cid)
    player:say('King', TALKTYPE_MONSTER_SAY)
    return true
end
function onLogin(player)
    if player:getName() ~= getHighestPlayer() then
        return true
    end
    sendEffectTopPlayer(player:getId())
    return true
end
 
Last edited by a moderator:
It could be done in many different ways: onThink events etc. Here is a version based on what you presented.

Lua:
local config = {
    interval = 5,
    ranks = {
        {minBalance = 100, rankName = "Knight", effect = CONST_ME_FIREWORK_RED},
        {minBalance = 1000, rankName = "Duke", effect = CONST_ME_FIREWORK_RED},
        {minBalance = 10000, rankName = "King", effect = CONST_ME_FIREWORK_RED},
    },
}

local function getRankByBalance(balance)
    for i = 1, #config.ranks do
        if balance < config.ranks[i].minBalance then
            return (i - 1 > 0) and (i - 1) or false
        end
    end
    return false
end

local function sendEffectTopPlayer(cid, rank)
    local player = Player(cid)
    if not player then
        return true
    end
    player:getPosition():sendMagicEffect(config.ranks[rank].effect)
    player:say(config.ranks[rank].rankName, TALKTYPE_MONSTER_SAY)
    addEvent(sendEffectTopPlayer, config.interval * 1000, cid, rank)
    return true
end

function onLogin(player)
    local rank = getRankByBalance(player:getBankBalance())
    if rank then
        sendEffectTopPlayer(player:getId(), rank)
    end
    return true
end
 
Solution
Back
Top