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

Lua Amulet of experience

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
hiii well i have a amulet of experience action, that gives you x2 exp during a week, the problem is that if you die, the exp comes back to normal :S. Plz guys help me fix this :(
Code:
local config = {
        rate = 2.0, -- 4x More Experience
        time = 168, -- Hours of Exp Time
        storage = 20011
    }
    local function endExpRate(cid)
        doPlayerSetRate(cid, SKILL__LEVEL, 6.0) --config.lua rate
        setPlayerStorageValue(cid, config.storage, -1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
    end
    function onUse(cid, item, fromPosition, itemEx, toPosition)
        if(getPlayerStorageValue(cid, config.storage) == -1) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hours.")
            doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
            setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600 * 1000)
            addEvent(endExpRate, config.time * 3600 * 1000, cid)
            doRemoveItem(item.uid, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
        end
        return true
    end
 
no i didn't i don't understand why there are two scripts :/ i don't know wich one to use...but i think i will do this with a ring instead of an action. It's easier and less buggy >.< thanks anyway greypaw and limos :D
 
Last edited:
You need to add both, 1 is an action script (function onUse), the other is a creaturescript (function onLogin).
You need to add the creaturescript with type login in creaturescripts.xml and don't register the name like with other creaturescripts, you don't have to register login scripts.
 
ooooh now i understand! sorry limos, is just inglish is not my first languaje and besides am no expert in this matter, i will test it right away :D thanks
 
omg now is working!!! but i have a final doubt, what happens if i want to make new scripts like x3 exp for a day x4 exp for 1 hour, i copy the script in actions and that's it? or i have to make a new copy of the one in creaturescripts?
 
If you are using the same storage in both action scripts, so someone can't use the new one, when the old one has still time left, then you only need 1 login script, because it will work with the same storage.
 
Back
Top