• 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+ Experience Bonus when Storage > 1

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hello,
I need experience bonus when player have storage etc.

2500 >= 10 then getExpRate * 0.1
2500 >= 30 then getExpRate * 0.3
2500 >= 50 then getExpRate * 0.5

On TFS 0.3.7 i used function getPlayerRates(cid), but on 1.4.2 don't have this function.
 
I just took it and adapted it for you. If you didn't have a system to click and get bonuses, you can use it here.

actions/scripts/name.lua If you already have a system for getting storage, ignore this script here. Now go to events/player.lua to get 10%, 30% and 50%, bonuses etc.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local storageValue = player:getStorageValue(2500)

    if storageValue >= os.time() then
        player:say('You already have a bonus active!', TALKTYPE_MONSTER_SAY)
    elseif storageValue < 10 then
        player:setStorageValue(2500, os.time() + 3600) -- Sets storage value based on current time + 1 hour
        player:say('You have received a bonus! Your storage value is now active for 1 hour.', TALKTYPE_MONSTER_SAY)
        item:remove(1)
    elseif storageValue < 30 then
        player:setStorageValue(2500, os.time() + 3600) -- Sets storage value based on current time + 1 hour
        player:say('You have received a bonus! Your storage value is now active for 1 hour.', TALKTYPE_MONSTER_SAY)
        item:remove(1)
    elseif storageValue < 50 then
        player:setStorageValue(2500, os.time() + 3600) -- Sets storage value based on current time + 1 hour
        player:say('You have received a bonus! Your storage value is now active for 1 hour.', TALKTYPE_MONSTER_SAY)
        item:remove(1)
    else
        player:say('You have already reached the maximum bonus!', TALKTYPE_MONSTER_SAY)
    end

    return true
end


or


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local storageValue = player:getStorageValue(2500)

    if storageValue >= os.time() then
        player:say('You already have an active bonus!', TALKTYPE_MONSTER_SAY)
    elseif storageValue < os.time() + 3600 then
        player:setStorageValue(2500, os.time() + 3600)
        player:say('You received a bonus! Your storage value is now active for 1 hour.', TALKTYPE_MONSTER_SAY)
        item:remove(1)
    else
        player:say('You have already reached the maximum bonus!', TALKTYPE_MONSTER_SAY)
    end

    return true
end



events/player.lua

Lua:
function Player:onGainExperience(source, exp, rawExp)
    local storageValue = self:getStorageValue(2500)
    local currentTime = os.time()

    if storageValue >= 10 and storageValue >= currentTime then
        return exp * 1.1 -- Applies a 10% bonus
    elseif storageValue >= 30 and storageValue >= currentTime then
        return exp * 1.3 -- Applies a 30% bonus
    elseif storageValue >= 50 and storageValue >= currentTime then
        return exp * 1.5 -- Applies a 50% bonus
    end

    return exp
end

look for that line and set to 1
Events.xml:

XML:
<event class="Player" method="onGainExperience" enabled="1" />

Take a look here, I took it and adapted it.
 
Back
Top