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

TFS 1.X+ calculating the loss of experience

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
I'm making a system that when dying, the player will have time so that he can trigger an item and recover all lost experience (NOTE: EXPERIENCE AND NOT LEVEL), however I don't know if there is any function on the LUA or if I have to make any formula , will be that someone can help me, my biggest problem and calculate when he has with bless and without bless.

Lua:
function math.percent(percent,maxvalue)
    if tonumber(percent) and tonumber(maxvalue) then
        return (maxvalue*percent)/100
    end
    return false
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        local porcentagem = getConfigInfo('deathLosePercent')
       
        local expRetorno = math.percent(1.85, math.floor(player:getExperience()))   
        player:addExperience(expRetorno, true)
        -- player:setStorageValue(15715, 0)

    return true
end
 
How I'd do it, is just setup 2 storages..

onPrepareDeath -- finds the current experience
onLogin -- finds the experience after death

use 2 storages to hold the info

then

currentExperience - experienceAfterDeath = experience to give back to the player.
 
I'm making a system that when dying, the player will have time so that he can trigger an item and recover all lost experience (NOTE: EXPERIENCE AND NOT LEVEL), however I don't know if there is any function on the LUA or if I have to make any formula , will be that someone can help me, my biggest problem and calculate when he has with bless and without bless.

Lua:
function math.percent(percent,maxvalue)
    if tonumber(percent) and tonumber(maxvalue) then
        return (maxvalue*percent)/100
    end
    return false
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        local porcentagem = getConfigInfo('deathLosePercent')
      
        local expRetorno = math.percent(1.85, math.floor(player:getExperience()))  
        player:addExperience(expRetorno, true)
        -- player:setStorageValue(15715, 0)

    return true
end
 
Back
Top