• 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 Remake of the GuildExp mod by Summ

Apoccalypse

New Member
Joined
Apr 15, 2017
Messages
114
Solutions
2
Reaction score
4
Hi Guys,
I have GuildExp mod created by Summ which works perfect.
I want to remake it to work in a little other way. So to the point,
I want to create an experience scroll which is gonna work in a following way:
When player use it, the scroll disappears and a storage is set to the player.
Then when player relog ,on the base of the storage , a new mod is gonna set player an additional experience rate for the x time and after this time the storage should be removed from the player.

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Guild Experience Reward" version="1.0" author="Summ" contact="otland.net" enabled="yes">
    <config name="ge_config"><![CDATA[
        ge_storage = 45501
        function loadGuildExp()
            local ret = getStorage(ge_storage)
            if type(ret) == "string" then
                return loadstring("return " .. ret)()
            end
            return {}
        end
        
        function saveGuildExp(list)
            local ret = "{"
            for guild, conf in pairs(list) do
                ret = ret .. "[" .. guild .. "] = {" .. table.concat(conf, ",") .. "},"
            end
            ret = ret .. "}"
            doSetStorage(ge_storage, ret)
        end
        
        function addGuildExp(name, exp, time)
            local id = getGuildId(name)
            if not(id) then
                return print("Guild Exp System: Guild '" .. name .. "' was not found. (add)")
            end
        
            local c = loadGuildExp()
            c[id] = {exp, time+os.time()}
            saveGuildExp(c)
            updateGuildExp(id, exp, time+os.time())
        end
        
        function removeGuildExp(id)
            local c = loadGuildExp()
            c[id] = nil
            saveGuildExp(c)
        end
        
        function setRate(cid, exp)
            if not(isPlayer(cid)) then
                return true
            end
            doPlayerSetRate(cid, SKILL__LEVEL, exp)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your guild's extra experience time ended.")
        end
        
        function addRate(cid, exp, time)
            local ex = getPlayerRates(cid)[SKILL__LEVEL]
            doPlayerSetRate(cid, SKILL__LEVEL, (ex+exp))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your guild received " .. exp * 200 .. "% extra experience.")
            addEvent(setRate, (time-os.time())*1000, cid, ex)
        end
        
        function updateGuildExp(guild, exp, time)
            for _, cid in pairs(getPlayersOnline()) do
                if guild == getPlayerGuildId(cid) then
                    addRate(cid, exp, time)
                end
            end
        end
    ]]></config>
    <talkaction log="yes" words="/ge" access="5" event="buffer"><![CDATA[
        domodlib('ge_config')
        local split = param:explode(",")
        local name, exp, time = split[1], tonumber(split[2]), tonumber(split[3])
        if not(split[3]) then
            return doPlayerSendCancel(cid, "The commands requires 3 parameters: guild name, experience and time")
        end
        if not(exp and time) then
            print(exp .. time)
            return doPlayerSendCancel(cid, "Numeric parameter required (experience and time in minutes).")
        end
    
        addGuildExp(split[1], exp, time*60)
        return true
    ]]></talkaction>
    <event type="login" name="GuildExpLogin" event="buffer"><![CDATA[
        domodlib('ge_config')
        local gid = getPlayerGuildId(cid)
        if gid ~= 0 then
            local c = loadGuildExp()[gid]
            if c then
                if os.time() > c[2] then
                    removeGuildExp(gid)
                else
                    addRate(cid, c[1], c[2])
                end
            end
        end
    ]]></event>
</mod>

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Blessed Experience" version="1.0" author="Summ" contact="otland.net" enabled="yes">
    <config name="gi_config"><![CDATA[
        gi_storage = 45520

        function loadBlessedExp()
            local ret = getStorage(gi_storage)
            if type(ret) == "string" then
                return loadstring("return " .. ret)()
            end
            return {}
        end
         
        function saveBlessedExp(list)
            local ret = "{"
            for Blessed, conf in pairs(list) do
                ret = ret .. "[" .. Blessed .. "] = {" .. table.concat(conf, ",") .. "},"
            end
            ret = ret .. "}"
            doSetStorage(gi_storage, ret)
        end
         
         
        function removeBlessedExp(id)
            local c = loadBlessedExp()
            c[id] = nil
            saveBlessedExp(c)
        end
         
        function setRate(cid, exp)
            if not(isPlayer(cid)) then
                return true
            end
            doPlayerSetRate(cid, SKILL__LEVEL, exp)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience time ended.")
        end
         
        function addRate(cid, exp, time)
            local ex = getPlayerRates(cid)[SKILL__LEVEL]
            doPlayerSetRate(cid, SKILL__LEVEL, (ex + exp))
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You received 30% experience boost!")
            addEvent(setRate, (os.time() + exp), cid, ex) 
        end
         
        function updateBlessedExp(Blessed, exp, time)
            for _, cid in pairs(getPlayersOnline()) do
                if getStorage(gi_storage) == 1 then
                    addRate(cid, exp, time)
                end
            end
        end
    ]]></config>

    <event type="login" name="BlessedExpLogin" event="buffer"><![CDATA[
        domodlib('gi_config')
        local gid = getCreature(cid)
            local c = loadBlessedExp()[gid]
            if c then
                if os.time() > c[2] then
                    removeBlessedExp(gid)
                else
                    addRate(cid, c[1], c[2])
                end
            end
        end
    ]]></event>
</mod>

I think that variable exp should be set as 30 if I want to get always 30% more experience and I should add sometning at login part which is gonna to set experience rate if the player has set the storage.

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, 45520) == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Please relog to obtain you extra experience!")
        doCreatureSetStorage(cid, 45520, 1)
        doRemoveItem(item.uid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You still have 30% more experience .")
    end
    return true
end

If anyone could take a look at it that would be great :)
 
Back
Top