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

EXP Stage based off storage OTX 3.0+

athenso

Average Coder
Joined
May 31, 2011
Messages
155
Solutions
3
Reaction score
23
I am working on a script to change a players exp stage based off a storage value. I am not seeing any Functions that I know I can get it to work with. An example script would be something like:

Code:
local player = Player(cid)
local check = player:getStorageValue(928487)


function onThink(interval)
    if check >=0 then
       Game.getExperienceStage(SetNewStage)
   else 
       Game.getExperienceStage(Original Stage)
end

but the Game.getExperienceStage(level) wouldnt work to my knowledge. Im not looking for someone to give me or write me the script, just point me to the right function to use for this case.
 
I don't think your locals will work, as won't know what 'cid' is.
You'd have to grab cid by looping through players online.

As for changing the experience stage.. in 0.3.7 in config.lua you want to have the default set to '1.0' for experience multiplier, and have the experience stages set to false.
After that you just update the players experience multiplier however you want to.

So if your doing it by storage value, experience multiplier is in 1.0 , 1.1, 1.2 et cetera.
So I'd just set the storage value to 10, 11, 12 and do like..
Code:
new_value = getstorage / 10
doPlayerSetRate(cid, SKILL__LEVEL, new_value)

You'll probably have to figure out the applicable function in your OTX server though.

Hope that helps!
 
Basically I have Staged experience right now, and I want to set it so if someone completes a quest they get a little less (due to the quest being harder it means they are in the higher level ranges) without adjusting the stage table. The script i posted above was an example, its not what im using i just wrote it in for something to look at.
 
Code:
function Player:onGainExperience(source, exp, rawExp)
    -- if they completed quest with storage 12345 then they only get 50% of the exp
    if self:getStorageValue(85987) >= 1 and self:getStorageValue(85987) <= 10 then
        exp = exp * 0.9
    elseif self:getStorageValue(85987) >= 11 and self:getStorageValue(85987) <= 50 then
        exp = exp * 0.75
    elseif self:getStorageValue(85987) >= 51 and self:getStorageValue(85987) <= 100 then
        exp = exp * 0.50
    elseif self:getStorageValue(85987) >= 101 and self:getStorageValue(85987) <= 175 then
        exp = exp * 0.25
    else
    if self:getStorageValue(85987) >= 176 then
        exp = exp * 0.15
    end
    end
return exp
end

Got home to test it, with your help this is the final script. Thanks
 
Last edited:
Back
Top