• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Avesta - Item that add bonus exp for a time

Eldora

Banned User
Joined
Oct 19, 2009
Messages
604
Reaction score
26
I am trying to create action script for a item.
I want this item to add 50% more experience, skill and magic level gains for 6 hours.

Please help me complete the code to work.
Using Avesta server.

LUA:
function onUse(cid, item, frompos, item2, topos)

if item2.itemid == 2345 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received 6 hours of bonus. Please login again!")

doRemoveItem(item.uid,1)
setPlayerStorageValue(cid, 30011, 1)

end


return TRUE
end

@ruth

Thank you in advance!
 
Last edited by a moderator:
Hello, I making this script based on this post:
CreatureEvent - If premium then 50% extra more experience, ml and skills rate and ++loot!

Hope this work for you:

LUA:
function setRates(cid, rate)
    if rate == nil then
        return false
    end
    if doPlayerSetRate(cid, SKILL_FIST, rate) and 
    doPlayerSetRate(cid, SKILL_CLUB, rate) and 
    doPlayerSetRate(cid, SKILL_SWORD, rate) and 
    doPlayerSetRate(cid, SKILL_AXE, rate) and 
    doPlayerSetRate(cid, SKILL_DISTANCE, rate) and 
    doPlayerSetRate(cid, SKILL_SHIELD, rate) and 
    doPlayerSetRate(cid, SKILL_FISHING, rate) and 
    doPlayerSetRate(cid, SKILL__MAGLEVEL, rate) and 
    doPlayerSetRate(cid, SKILL__LEVEL, rate) then
    return true
    end
end
function onUse(cid, item, frompos, item2, topos)
    local multiplier = 1.5 -- This means 50% extra, 1.45 for 45%, 1.32 for 32% etcetera, etcetera...
    if item.itemid == 2345 then
        if getPlayerStorageValue(cid, 30011) == -1 then
            if setRates(cid, multiplier) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
                doRemoveItem(item.uid,1)
                setPlayerStorageValue(cid, 30011, 1)
                doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have activated this bonus.")
            doSendMagicEffect(frompos, CONST_ME_POFF)
        end
    end 
return TRUE
end
Or if you want to put the rates separate can use this code:

LUA:
function setDifRates(cid, rateSkill, rateMagic, rateExp)
    if rateExp == nil then
        return false
    elseif rateExp == nil then
        return false
    elseif rateMagic == nil then
        return false
    end
    if doPlayerSetRate(cid, SKILL_FIST, rateSkill) and 
    doPlayerSetRate(cid, SKILL_CLUB, rateSkill) and 
    doPlayerSetRate(cid, SKILL_SWORD, rateSkill) and 
    doPlayerSetRate(cid, SKILL_AXE, rateSkill) and 
    doPlayerSetRate(cid, SKILL_DISTANCE, rateSkill) and 
    doPlayerSetRate(cid, SKILL_SHIELD, rateSkill) and 
    doPlayerSetRate(cid, SKILL_FISHING, rateSkill) and 
    doPlayerSetRate(cid, SKILL__MAGLEVEL, rateMagic) and 
    doPlayerSetRate(cid, SKILL__LEVEL, rateExp) then
    return true
    end
end
function onUse(cid, item, frompos, item2, topos)
    local skillMultiplier = 1.5 -- 30% more skill
    local magicMultiplier = 1.2 -- 20 % more magic
    local expMultiplier = 2.0 -- 50% of gain experience, its just and example
    if item.itemid == 2345 then
        if getPlayerStorageValue(cid, 30011) == -1 then
            if setDifRates(cid, skillMultiplier, magicMultiplier, expMultiplier) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
                doRemoveItem(item.uid,1)
                setPlayerStorageValue(cid, 30011, 1)
                doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have activated this bonus.")
            doSendMagicEffect(frompos, CONST_ME_POFF)
        end
    end 
return TRUE
end

Kind, regards.
 
Hello, I making this script based on this post:
CreatureEvent - If premium then 50% extra more experience, ml and skills rate and ++loot!

Hope this work for you:

LUA:
function setRates(cid, rate)
    if rate == nil then
        return false
    end
    if doPlayerSetRate(cid, SKILL_FIST, rate) and
    doPlayerSetRate(cid, SKILL_CLUB, rate) and
    doPlayerSetRate(cid, SKILL_SWORD, rate) and
    doPlayerSetRate(cid, SKILL_AXE, rate) and
    doPlayerSetRate(cid, SKILL_DISTANCE, rate) and
    doPlayerSetRate(cid, SKILL_SHIELD, rate) and
    doPlayerSetRate(cid, SKILL_FISHING, rate) and
    doPlayerSetRate(cid, SKILL__MAGLEVEL, rate) and
    doPlayerSetRate(cid, SKILL__LEVEL, rate) then
    return true
    end
end
function onUse(cid, item, frompos, item2, topos)
    local multiplier = 1.5 -- This means 50% extra, 1.45 for 45%, 1.32 for 32% etcetera, etcetera...
    if item.itemid == 2345 then
        if getPlayerStorageValue(cid, 30011) == -1 then
            if setRates(cid, multiplier) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
                doRemoveItem(item.uid,1)
                setPlayerStorageValue(cid, 30011, 1)
                doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have activated this bonus.")
            doSendMagicEffect(frompos, CONST_ME_POFF)
        end
    end
return TRUE
end
Or if you want to put the rates separate can use this code:

LUA:
function setDifRates(cid, rateSkill, rateMagic, rateExp)
    if rateExp == nil then
        return false
    elseif rateExp == nil then
        return false
    elseif rateMagic == nil then
        return false
    end
    if doPlayerSetRate(cid, SKILL_FIST, rateSkill) and
    doPlayerSetRate(cid, SKILL_CLUB, rateSkill) and
    doPlayerSetRate(cid, SKILL_SWORD, rateSkill) and
    doPlayerSetRate(cid, SKILL_AXE, rateSkill) and
    doPlayerSetRate(cid, SKILL_DISTANCE, rateSkill) and
    doPlayerSetRate(cid, SKILL_SHIELD, rateSkill) and
    doPlayerSetRate(cid, SKILL_FISHING, rateSkill) and
    doPlayerSetRate(cid, SKILL__MAGLEVEL, rateMagic) and
    doPlayerSetRate(cid, SKILL__LEVEL, rateExp) then
    return true
    end
end
function onUse(cid, item, frompos, item2, topos)
    local skillMultiplier = 1.5 -- 30% more skill
    local magicMultiplier = 1.2 -- 20 % more magic
    local expMultiplier = 2.0 -- 50% of gain experience, its just and example
    if item.itemid == 2345 then
        if getPlayerStorageValue(cid, 30011) == -1 then
            if setDifRates(cid, skillMultiplier, magicMultiplier, expMultiplier) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
                doRemoveItem(item.uid,1)
                setPlayerStorageValue(cid, 30011, 1)
                doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have activated this bonus.")
            doSendMagicEffect(frompos, CONST_ME_POFF)
        end
    end
return TRUE
end

Kind, regards.

It won't work, maybe you can help me over skype? Send me a PM here on Otland :)
 
I have investigated about functions on avesta, Idk that kind of server, I was thinkin that was the same of TFS 0.3.6 or 0.4, but now I belive this will work:
I made it with exp rate back after 6 hours passed. I think this can be buged if player is not online :S but if someone can help to improve.
LUA:
function setRates(cid, rate)
    if rate == nil then
        return false
    end
    local skills = {SKILL_FIST, SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DIST, SKILL_SHIELD}
    for i = 1, #skill do
        skill = skills[i]
        setSkillRate(cid, skill, rate)
    end
    if setExperienceRate(cid, rate) and setMagicRate(cid, rate) and setSkillRate(cid, skill, rate) then
        return true
    end
end
function onUse(cid, item, frompos, item2, topos)
    local multiplier = 1.5 -- This means 50% extra, 1.45 for 45%, 1.32 for 32% etcetera, etcetera...
    local setTimeInHours = 6
    if item.itemid == 2345 then
        if getPlayerStorageValue(cid, 30011) == -1 then
            if setRates(cid, multiplier) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are premium, enjoy 50% extra experience, skills and magic level rates.")
                doRemoveItem(item.uid,1)
                setPlayerStorageValue(cid, 30011, 1)
                doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
                addEvent(setRates, setTimeInHours * 60 * 60 * 1000, cid, 1.0)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have activated this bonus.")
            doSendMagicEffect(frompos, CONST_ME_POFF)
        end
    end
return TRUE
end
 
Last edited:
Back
Top