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

Prestige effect on player

8634287zf

New Member
Joined
Dec 21, 2009
Messages
2
Reaction score
0
Hello, I have a script for when someone prestiges in my server they have an effect over them displaying the prestige. Problem is that it is showing subsequent prestiges on top of the current one. For example, onplayer it is showing Pres 3 Pres 4, every second when it should only be Pres 4. Heres the script:


function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
local cid = getPlayerByName(name)
if getPlayerStorageValue(cid, 200) >= 2 then
doSendMagicEffect(getPlayerPosition(cid), 30)
doSendAnimatedText(getPlayerPosition(cid), "Pres 2", 100)
end
end
return true
end

Thanks for any help!!
 
you clearly have that script copied for each prestige or something, so it isn't surprising that all of them execute and if they're prestige 4, 4 is >= 2 and 4 >= 3 and 4 >= 4 so 3 scripts will execute
you can use a table with prestiges instead and access the table key with player rebirth
Lua:
local effects = {
    [1] = CONST_ME_FIREWORK_RED,
    [2] = CONST_ME_FIREWORK_BLUE,
    [3] = CONST_ME_FIREWORK_YELLOW
}

function onThink(interval, lastExecution)
    for _, cid in ipairs(getPlayersOnline()) do
        local rebirth = getPlayerStorageValue(cid, 200)
        if rebirth >= 1 then
            local effect = effects[rebirth] or CONST_ME_MORTAREA -- get effect from table, if not found then default to mortarea
            local position = getPlayerPosition(cid)
            doSendMagicEffect(position, effect)
            doSendAnimatedText(position, "Pres ".. rebirth, TEXTCOLOR_MAYABLUE)
        end
    end
    return true
end
you can create new effects in the table by putting [rebirth] = effect
use CONST values instead of numbers, it's more readable. here's a list:
tfs-old-svn/global.lua at 1b7500bb947de1827c39174b05c31fea92c10240 · otland/tfs-old-svn · GitHub
 
Back
Top