• 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 Server Boost Rate

Kthxbye

New Member
Joined
Jul 11, 2012
Messages
122
Reaction score
2
Hello all, I am look for a script that I can use as a talkaction to increase exp, skills, magic for x amount of hours
I am using TFS 1.3 10.98 server, thank you very much
 
Solution
Worked fantastic, Can you add were only a god can say the commands?

try this
Lua:
local talk = TalkAction("/boost", "!boost")

function talk.onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local booststorage = player:getStorageValue(SKILL_BOOST_CONF.storage)
    if booststorage and (booststorage > os.time()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Your boost is still active.')
        return false
    end

    player:setStorageValue(SKILL_BOOST_CONF.storage, os.time() + SKILL_BOOST_CONF.time)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Boost has...
Have only tested exp boost part so you will need to test magic & skill boost on your server.
Note: There are no restrictions in this code. Example: anyone can use the command and it doesnt cost money.

data/global.lua
Lua:
SKILL_BOOST_CONF = {
    storage   = 11223,

    -- 1 hour
    time      = 3600 * 1,

    expRate   = 1.2,  -- +20%
    magicRate = 1.2,  -- +20%
    skillRate = 1.2   -- +20%
}

data/scripts/talkactions/boostexp.lua
Lua:
local talk = TalkAction("/boost", "!boost")

function talk.onSay(player, words, param)
    local booststorage = player:getStorageValue(SKILL_BOOST_CONF.storage)
    if booststorage and (booststorage > os.time()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Your boost is still active.')
        return false
    end

    player:setStorageValue(SKILL_BOOST_CONF.storage, os.time() + SKILL_BOOST_CONF.time)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Boost has been activated. It will remain active for ' .. timeToReadable(SKILL_BOOST_CONF.time))
    return false
end

function timeToReadable(t)
    local str = os.date('!%T', t)
    str = string.split(str, ':')
    return tonumber(str[1]) .. 'h ' .. tonumber(str[2]) .. 'm ' .. tonumber(str[3]) ..'s.'
end

talk:separator(" ")
talk:register()

data/events/scripts/player.lua

inside Player:onGainSkillTries add the following:
Lua:
-- Apply magic & skill boost
local booststorage = self:getStorageValue(SKILL_BOOST_CONF.storage)
if booststorage and (booststorage > os.time()) then
    if skill == SKILL_MAGLEVEL then
        tries = tries * SKILL_BOOST_CONF.magicRate
    else
        tries = tries * SKILL_BOOST_CONF.skillRate
    end
end
before :
Lua:
if skill == SKILL_MAGLEVEL then
    tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
    return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
end
tries = tries * configManager.getNumber(configKeys.RATE_SKILL)

in Player:onGainExperience add the following:
Lua:
-- apply exp boost
local booststorage = self:getStorageValue(SKILL_BOOST_CONF.storage)
if booststorage and (booststorage > os.time()) then
    exp = exp * SKILL_BOOST_CONF.expRate
end
before:
Lua:
return hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
 
Worked fantastic, Can you add were only a god can say the commands?

try this
Lua:
local talk = TalkAction("/boost", "!boost")

function talk.onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local booststorage = player:getStorageValue(SKILL_BOOST_CONF.storage)
    if booststorage and (booststorage > os.time()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Your boost is still active.')
        return false
    end

    player:setStorageValue(SKILL_BOOST_CONF.storage, os.time() + SKILL_BOOST_CONF.time)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Boost has been activated. It will remain active for ' .. timeToReadable(SKILL_BOOST_CONF.time))
    return false
end

function timeToReadable(t)
    local str = os.date('!%T', t)
    str = string.split(str, ':')
    return tonumber(str[1]) .. 'h ' .. tonumber(str[2]) .. 'm ' .. tonumber(str[3]) ..'s.'
end

talk:separator(" ")
talk:register()
 
Solution
Back
Top