• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Daily Reward TFS 1.3 by Snavy error

Musaab

NoxOts
Joined
May 13, 2010
Messages
176
Reaction score
74
Location
Sweden
Ellooo!

So Snavy made a script service here on Otland Lua - Snavy & Levi - Free Scripting Service - TFS 1.3 (https://otland.net/threads/snavy-levi-free-scripting-service-tfs-1-3.275695/page-2#post-2654608)

He made the Daily reward that player can use each 24h.
Revscript,

Getting an error tho when launching,

Here my code below, only edited the actionID so far.

My error in console; 1618044701209.png

Lua:
---[ CUSTOM FUNCTIONS ]---
local function getTableLength(t)
    local count = 0
    for k, v in pairs(t) do count = count + 1 end
    return count
end

local function secondsToReadable(s)
    local hours   = math.floor(s / 3600)
    local minutes = math.floor(math.mod(s, 3600)/60)
    local seconds = math.floor(math.mod(s, 60))
    return (hours   > 0 and (hours   .. ' hours ')   or '') ..
           (minutes > 0 and (minutes .. ' minutes ') or '') ..
           (seconds > 0 and (seconds .. ' seconds ') or '')
end

---[ CONFIGURATION ]---
local config = {
    -- HEALTH BOOST
    HP_BOOST_TIME    = 10, -- 10 seconds
    HP_BOOST_PERCENT = 10, -- +10%
    HP_BOOST_STORAGE = 13450,

    -- MANA BOOST
    MP_BOOST_TIME    = 10, -- 10 seconds
    MP_BOOST_PERCENT = 10, -- +10%
    MP_BOOST_STORAGE = 13451,

    -- EXP_RATE
    EXPERIENCE_AMOUNT = 10,
    EXTRA_EXP_RATE    = 1.05, -- +5%
    EXTRA_EXP_STORAGE = 181233,
    EXTRA_EXP_TIME    = 60,

    STORAGE_LAST_USED = 181234,
    REWARD_TIME = 24 * 3600
}

local REWARD_TYPE = {
    ITEM         = 1,
    EXPERIENCE   = 2,
    EXTRA_HP     = 3,
    EXTRA_MP     = 4,
    EXP_RATE     = 5
}

local rewards = {}
rewards[REWARD_TYPE.ITEM]       = {2160, 10}
rewards[REWARD_TYPE.EXPERIENCE] = config.EXPERIENCE_AMOUNT -- want to add constant amount of xp to every player or modified?
rewards[REWARD_TYPE.EXTRA_HP] = Condition(CONDITION_ATTRIBUTES)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_SUBID, 1234)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100 + config.HP_BOOST_PERCENT)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_TICKS, config.HP_BOOST_TIME * 1000)

rewards[REWARD_TYPE.EXTRA_MP] = Condition(CONDITION_ATTRIBUTES)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_SUBID, 1235)
rewards[REWARD_TYPE.EXTRA_MP]:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100 + config.MP_BOOST_PERCENT)
rewards[REWARD_TYPE.EXTRA_MP]:setParameter(CONDITION_PARAM_TICKS, config.MP_BOOST_TIME * 1000)

rewards[REWARD_TYPE.EXP_RATE] = config.EXTRA_EXP_RATE

---[ ACTION SCRIPT ]---
local act = Action()
function act.onUse(player, item, fromPosition, itemEx, toPosition)
    if player:getStorageValue(config.STORAGE_LAST_USED) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You can only use this chest every 24h!')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local rewardType = math.random(1, getTableLength(REWARD_TYPE))
    if not rewards[rewardType] then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'An error has occured. Contact admin.')
        print('[Warning - DailyRewardChest] Unknown reward. Type ('.. rewardType ..')')
        return true
    end

    player:setStorageValue(config.STORAGE_LAST_USED, os.time() + config.REWARD_TIME)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    -- +EXPERIENCE --
    if rewardType == REWARD_TYPE.EXPERIENCE then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received ' .. rewards[rewardType] .. ' exp.')
        player:addExperience(rewards[rewardType])
        return true
    end

    -- EXTRA EXP RATE --
    if rewardType == REWARD_TYPE.EXP_RATE then
        player:setStorageValue(config.EXTRA_EXP_STORAGE, os.time() + config.EXTRA_EXP_TIME)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,
            'You have received extra exp rate of +'
                .. (config.EXTRA_EXP_RATE * 100) - 100
                .. '% for '
                .. secondsToReadable(config.EXTRA_EXP_TIME)
            )
        return true
    end

    -- ITEM --
    if rewardType == REWARD_TYPE.ITEM then
        local item = rewards[rewardType]
        player:addItem(item[1], item[2])
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found an item.')
        return true
    end

    -- EXTRA HP / MANA --
    if rewardType == REWARD_TYPE.EXTRA_HP then
        player:addCondition(rewards[rewardType])
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            'You have received +'.. config.HP_BOOST_PERCENT ..'% health boost for '
            .. secondsToReadable(config.HP_BOOST_TIME)
        )
        return true
    end

    if rewardType == REWARD_TYPE.EXTRA_MP then
        player:addCondition(rewards[rewardType])
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            'You have received +'.. config.MP_BOOST_PERCENT ..'% mana boost for '
            .. secondsToReadable(config.MP_BOOST_TIME)
        )
    end
    return true
end
act:id(21355) -- change this
act:register()

--------[ EVENTS ]--------
local ecb = EventCallback
ecb.onGainExperience = function(self, source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

    if self:getStorageValue(config.EXTRA_EXP_STORAGE) < os.time() then
        return exp
    end

    exp = exp * config.EXTRA_EXP_RATE
    return exp
end
ecb:register(1)
 
OP
OP
Musaab

Musaab

NoxOts
Joined
May 13, 2010
Messages
176
Reaction score
74
Location
Sweden
🤔 show data/scripts/lib/event_callbacks.lua
Lua:
-- Creature
EVENT_CALLBACK_ONCHANGEOUTFIT = 1
EVENT_CALLBACK_ONCHANGEMOUNT = 2
EVENT_CALLBACK_ONAREACOMBAT = 3
EVENT_CALLBACK_ONTARGETCOMBAT = 4
EVENT_CALLBACK_ONHEAR = 5
-- Party
EVENT_CALLBACK_ONJOIN = 6
EVENT_CALLBACK_ONLEAVE = 7
EVENT_CALLBACK_ONDISBAND = 8
EVENT_CALLBACK_ONSHAREEXPERIENCE = 9
-- Player
EVENT_CALLBACK_ONBROWSEFIELD = 10
EVENT_CALLBACK_ONLOOK = 11
EVENT_CALLBACK_ONLOOKINBATTLELIST = 12
EVENT_CALLBACK_ONLOOKINTRADE = 13
EVENT_CALLBACK_ONLOOKINSHOP = 14
EVENT_CALLBACK_ONTRADEREQUEST = 15
EVENT_CALLBACK_ONTRADEACCEPT = 16
EVENT_CALLBACK_ONTRADECOMPLETED = 17
EVENT_CALLBACK_ONMOVEITEM = 18
EVENT_CALLBACK_ONITEMMOVED = 19
EVENT_CALLBACK_ONMOVECREATURE = 20
EVENT_CALLBACK_ONREPORTRULEVIOLATION = 21
EVENT_CALLBACK_ONREPORTBUG = 22
EVENT_CALLBACK_ONTURN = 23
EVENT_CALLBACK_ONGAINEXPERIENCE = 24
EVENT_CALLBACK_ONLOSEEXPERIENCE = 25
EVENT_CALLBACK_ONGAINSKILLTRIES = 26
EVENT_CALLBACK_ONWRAPITEM = 27
-- Monster
EVENT_CALLBACK_ONDROPLOOT = 28
EVENT_CALLBACK_ONSPAWN = 29
-- last (for correct table counting)
EVENT_CALLBACK_LAST = EVENT_CALLBACK_ONSPAWN

local callbacks = {
    -- Creature
    ["onChangeOutfit"] = EVENT_CALLBACK_ONCHANGEOUTFIT,
    ["onChangeMount"] = EVENT_CALLBACK_ONCHANGEMOUNT,
    ["onAreaCombat"] = EVENT_CALLBACK_ONAREACOMBAT,
    ["onTargetCombat"] = EVENT_CALLBACK_ONTARGETCOMBAT,
    ["onHear"] = EVENT_CALLBACK_ONHEAR,
    -- Party
    ["onJoin"] = EVENT_CALLBACK_ONJOIN,
    ["onLeave"] = EVENT_CALLBACK_ONLEAVE,
    ["onDisband"] = EVENT_CALLBACK_ONDISBAND,
    ["onShareExperience"] = EVENT_CALLBACK_ONSHAREEXPERIENCE,
    -- Player
    ["onBrowseField"] = EVENT_CALLBACK_ONBROWSEFIELD,
    ["onLook"] = EVENT_CALLBACK_ONLOOK,
    ["onLookInBattleList"] = EVENT_CALLBACK_ONLOOKINBATTLELIST,
    ["onLookInTrade"] = EVENT_CALLBACK_ONLOOKINTRADE,
    ["onLookInShop"] = EVENT_CALLBACK_ONLOOKINSHOP,
    ["onTradeRequest"] = EVENT_CALLBACK_ONTRADEREQUEST,
    ["onTradeAccept"] = EVENT_CALLBACK_ONTRADEACCEPT,
    ["onTradeCompleted"] = EVENT_CALLBACK_ONTRADECOMPLETED,
    ["onMoveItem"] = EVENT_CALLBACK_ONMOVEITEM,
    ["onItemMoved"] = EVENT_CALLBACK_ONITEMMOVED,
    ["onMoveCreature"] = EVENT_CALLBACK_ONMOVECREATURE,
    ["onReportRuleViolation"] = EVENT_CALLBACK_ONREPORTRULEVIOLATION,
    ["onReportBug"] = EVENT_CALLBACK_ONREPORTBUG,
    ["onTurn"] = EVENT_CALLBACK_ONTURN,
    ["onGainExperience"] = EVENT_CALLBACK_ONGAINEXPERIENCE,
    ["onLoseExperience"] = EVENT_CALLBACK_ONLOSEEXPERIENCE,
    ["onGainSkillTries"] = EVENT_CALLBACK_ONGAINSKILLTRIES,
    ["onWrapItem"] = EVENT_CALLBACK_ONWRAPITEM,
    -- Monster
    ["onDropLoot"] = EVENT_CALLBACK_ONDROPLOOT,
    ["onSpawn"] = EVENT_CALLBACK_ONSPAWN
}

-- can't be overwritten on /reload global/libs now
if not EventCallbackData then
    EventCallbackData = {}
    for i = 1, EVENT_CALLBACK_LAST do
        EventCallbackData[i] = {}
    end
end
EventCallback = {}
setmetatable(EventCallback,
{
    __index =
    function(self)
        if isScriptsInterface() then
            return self
        else
            return nil
        end
    end,

    __newindex =
    function(self, key, value)
        if isScriptsInterface() then
            if self[key] then
                local ecd = EventCallbackData
                ecd[callbacks[key]][#ecd == nil and 1 or #ecd[callbacks[key]] + 1] = value
            end
        else
            return nil
        end
    end,

    __call =
    function(self, callbackType, ...)
        local result
        local key, event = next(EventCallbackData[callbackType])
        repeat
            result = {event(...)}
            key, event = next(EventCallbackData[callbackType], key)
        until event == nil or (result[1] ~= nil and (result[1] == false or table.contains({EVENT_CALLBACK_ONAREACOMBAT, EVENT_CALLBACK_ONTARGETCOMBAT}, callbackType) and result[1] ~= RETURNVALUE_NOERROR))
        return unpack(result)
    end
})

function hasEventCallback(callbackType)
    if #EventCallbackData[callbackType] == 0 then
        return false
    end
    return true
end
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
607
Location
Hell
Lua:
-- Creature
EVENT_CALLBACK_ONCHANGEOUTFIT = 1
EVENT_CALLBACK_ONCHANGEMOUNT = 2
EVENT_CALLBACK_ONAREACOMBAT = 3
EVENT_CALLBACK_ONTARGETCOMBAT = 4
EVENT_CALLBACK_ONHEAR = 5
-- Party
EVENT_CALLBACK_ONJOIN = 6
EVENT_CALLBACK_ONLEAVE = 7
EVENT_CALLBACK_ONDISBAND = 8
EVENT_CALLBACK_ONSHAREEXPERIENCE = 9
-- Player
EVENT_CALLBACK_ONBROWSEFIELD = 10
EVENT_CALLBACK_ONLOOK = 11
EVENT_CALLBACK_ONLOOKINBATTLELIST = 12
EVENT_CALLBACK_ONLOOKINTRADE = 13
EVENT_CALLBACK_ONLOOKINSHOP = 14
EVENT_CALLBACK_ONTRADEREQUEST = 15
EVENT_CALLBACK_ONTRADEACCEPT = 16
EVENT_CALLBACK_ONTRADECOMPLETED = 17
EVENT_CALLBACK_ONMOVEITEM = 18
EVENT_CALLBACK_ONITEMMOVED = 19
EVENT_CALLBACK_ONMOVECREATURE = 20
EVENT_CALLBACK_ONREPORTRULEVIOLATION = 21
EVENT_CALLBACK_ONREPORTBUG = 22
EVENT_CALLBACK_ONTURN = 23
EVENT_CALLBACK_ONGAINEXPERIENCE = 24
EVENT_CALLBACK_ONLOSEEXPERIENCE = 25
EVENT_CALLBACK_ONGAINSKILLTRIES = 26
EVENT_CALLBACK_ONWRAPITEM = 27
-- Monster
EVENT_CALLBACK_ONDROPLOOT = 28
EVENT_CALLBACK_ONSPAWN = 29
-- last (for correct table counting)
EVENT_CALLBACK_LAST = EVENT_CALLBACK_ONSPAWN

local callbacks = {
    -- Creature
    ["onChangeOutfit"] = EVENT_CALLBACK_ONCHANGEOUTFIT,
    ["onChangeMount"] = EVENT_CALLBACK_ONCHANGEMOUNT,
    ["onAreaCombat"] = EVENT_CALLBACK_ONAREACOMBAT,
    ["onTargetCombat"] = EVENT_CALLBACK_ONTARGETCOMBAT,
    ["onHear"] = EVENT_CALLBACK_ONHEAR,
    -- Party
    ["onJoin"] = EVENT_CALLBACK_ONJOIN,
    ["onLeave"] = EVENT_CALLBACK_ONLEAVE,
    ["onDisband"] = EVENT_CALLBACK_ONDISBAND,
    ["onShareExperience"] = EVENT_CALLBACK_ONSHAREEXPERIENCE,
    -- Player
    ["onBrowseField"] = EVENT_CALLBACK_ONBROWSEFIELD,
    ["onLook"] = EVENT_CALLBACK_ONLOOK,
    ["onLookInBattleList"] = EVENT_CALLBACK_ONLOOKINBATTLELIST,
    ["onLookInTrade"] = EVENT_CALLBACK_ONLOOKINTRADE,
    ["onLookInShop"] = EVENT_CALLBACK_ONLOOKINSHOP,
    ["onTradeRequest"] = EVENT_CALLBACK_ONTRADEREQUEST,
    ["onTradeAccept"] = EVENT_CALLBACK_ONTRADEACCEPT,
    ["onTradeCompleted"] = EVENT_CALLBACK_ONTRADECOMPLETED,
    ["onMoveItem"] = EVENT_CALLBACK_ONMOVEITEM,
    ["onItemMoved"] = EVENT_CALLBACK_ONITEMMOVED,
    ["onMoveCreature"] = EVENT_CALLBACK_ONMOVECREATURE,
    ["onReportRuleViolation"] = EVENT_CALLBACK_ONREPORTRULEVIOLATION,
    ["onReportBug"] = EVENT_CALLBACK_ONREPORTBUG,
    ["onTurn"] = EVENT_CALLBACK_ONTURN,
    ["onGainExperience"] = EVENT_CALLBACK_ONGAINEXPERIENCE,
    ["onLoseExperience"] = EVENT_CALLBACK_ONLOSEEXPERIENCE,
    ["onGainSkillTries"] = EVENT_CALLBACK_ONGAINSKILLTRIES,
    ["onWrapItem"] = EVENT_CALLBACK_ONWRAPITEM,
    -- Monster
    ["onDropLoot"] = EVENT_CALLBACK_ONDROPLOOT,
    ["onSpawn"] = EVENT_CALLBACK_ONSPAWN
}

-- can't be overwritten on /reload global/libs now
if not EventCallbackData then
    EventCallbackData = {}
    for i = 1, EVENT_CALLBACK_LAST do
        EventCallbackData[i] = {}
    end
end
EventCallback = {}
setmetatable(EventCallback,
{
    __index =
    function(self)
        if isScriptsInterface() then
            return self
        else
            return nil
        end
    end,

    __newindex =
    function(self, key, value)
        if isScriptsInterface() then
            if self[key] then
                local ecd = EventCallbackData
                ecd[callbacks[key]][#ecd == nil and 1 or #ecd[callbacks[key]] + 1] = value
            end
        else
            return nil
        end
    end,

    __call =
    function(self, callbackType, ...)
        local result
        local key, event = next(EventCallbackData[callbackType])
        repeat
            result = {event(...)}
            key, event = next(EventCallbackData[callbackType], key)
        until event == nil or (result[1] ~= nil and (result[1] == false or table.contains({EVENT_CALLBACK_ONAREACOMBAT, EVENT_CALLBACK_ONTARGETCOMBAT}, callbackType) and result[1] ~= RETURNVALUE_NOERROR))
        return unpack(result)
    end
})

function hasEventCallback(callbackType)
    if #EventCallbackData[callbackType] == 0 then
        return false
    end
    return true
end
Does not seem to be up to date with the latest version.

@Musaab
.. However, if you wish to continue with the old version that you currently have, you can move the following part:
Lua:
if self:getStorageValue(config.EXTRA_EXP_STORAGE) < os.time() then
    return exp
end

exp = exp * config.EXTRA_EXP_RATE
to this File & Line:

modified as:
Lua:
if self:getStorageValue(181233) > os.time() then
    exp = exp * 1.05 --config.EXTRA_EXP_RATE
end
 
Last edited:
OP
OP
Musaab

Musaab

NoxOts
Joined
May 13, 2010
Messages
176
Reaction score
74
Location
Sweden
Alright!

I appreciate the help, thank you :)
Post automatically merged:

So i tested now with updated files , both the file u mentioned and the rest of new changes that was made from latest release,

But keep getting this now when i try to "Look" at anything

1618065616879.png

Only when the script is in script file tho, otherwise np with browsing or any other issues ;x
Post automatically merged:

I'll show u my both files as well,
 

Attachments

Last edited:

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
607
Location
Hell
Alright!

I appreciate the help, thank you :)
Post automatically merged:

So i tested now with updated files , both the file u mentioned and the rest of new changes that was made from latest release,

But keep getting this now when i try to "Look" at anything

View attachment 57518

Only when the script is in script file tho, otherwise np with browsing or any other issues ;x
Post automatically merged:

I'll show u my both files as well,
attemp to call field 'pack' (a nil value)

I should've provided you this link instead, pack function is added here:
 

VagosClubTM

Member
Joined
Aug 16, 2019
Messages
155
Reaction score
20
Location
Chile
Ellooo!

So Snavy made a script service here on Otland Lua - Snavy & Levi - Free Scripting Service - TFS 1.3 (https://otland.net/threads/snavy-levi-free-scripting-service-tfs-1-3.275695/page-2#post-2654608)

He made the Daily reward that player can use each 24h.
Revscript,

Getting an error tho when launching,

Here my code below, only edited the actionID so far.

My error in console; View attachment 57503

Lua:
---[ CUSTOM FUNCTIONS ]---
local function getTableLength(t)
    local count = 0
    for k, v in pairs(t) do count = count + 1 end
    return count
end

local function secondsToReadable(s)
    local hours   = math.floor(s / 3600)
    local minutes = math.floor(math.mod(s, 3600)/60)
    local seconds = math.floor(math.mod(s, 60))
    return (hours   > 0 and (hours   .. ' hours ')   or '') ..
           (minutes > 0 and (minutes .. ' minutes ') or '') ..
           (seconds > 0 and (seconds .. ' seconds ') or '')
end

---[ CONFIGURATION ]---
local config = {
    -- HEALTH BOOST
    HP_BOOST_TIME    = 10, -- 10 seconds
    HP_BOOST_PERCENT = 10, -- +10%
    HP_BOOST_STORAGE = 13450,

    -- MANA BOOST
    MP_BOOST_TIME    = 10, -- 10 seconds
    MP_BOOST_PERCENT = 10, -- +10%
    MP_BOOST_STORAGE = 13451,

    -- EXP_RATE
    EXPERIENCE_AMOUNT = 10,
    EXTRA_EXP_RATE    = 1.05, -- +5%
    EXTRA_EXP_STORAGE = 181233,
    EXTRA_EXP_TIME    = 60,

    STORAGE_LAST_USED = 181234,
    REWARD_TIME = 24 * 3600
}

local REWARD_TYPE = {
    ITEM         = 1,
    EXPERIENCE   = 2,
    EXTRA_HP     = 3,
    EXTRA_MP     = 4,
    EXP_RATE     = 5
}

local rewards = {}
rewards[REWARD_TYPE.ITEM]       = {2160, 10}
rewards[REWARD_TYPE.EXPERIENCE] = config.EXPERIENCE_AMOUNT -- want to add constant amount of xp to every player or modified?
rewards[REWARD_TYPE.EXTRA_HP] = Condition(CONDITION_ATTRIBUTES)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_SUBID, 1234)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100 + config.HP_BOOST_PERCENT)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_TICKS, config.HP_BOOST_TIME * 1000)

rewards[REWARD_TYPE.EXTRA_MP] = Condition(CONDITION_ATTRIBUTES)
rewards[REWARD_TYPE.EXTRA_HP]:setParameter(CONDITION_PARAM_SUBID, 1235)
rewards[REWARD_TYPE.EXTRA_MP]:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100 + config.MP_BOOST_PERCENT)
rewards[REWARD_TYPE.EXTRA_MP]:setParameter(CONDITION_PARAM_TICKS, config.MP_BOOST_TIME * 1000)

rewards[REWARD_TYPE.EXP_RATE] = config.EXTRA_EXP_RATE

---[ ACTION SCRIPT ]---
local act = Action()
function act.onUse(player, item, fromPosition, itemEx, toPosition)
    if player:getStorageValue(config.STORAGE_LAST_USED) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You can only use this chest every 24h!')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local rewardType = math.random(1, getTableLength(REWARD_TYPE))
    if not rewards[rewardType] then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'An error has occured. Contact admin.')
        print('[Warning - DailyRewardChest] Unknown reward. Type ('.. rewardType ..')')
        return true
    end

    player:setStorageValue(config.STORAGE_LAST_USED, os.time() + config.REWARD_TIME)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)

    -- +EXPERIENCE --
    if rewardType == REWARD_TYPE.EXPERIENCE then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received ' .. rewards[rewardType] .. ' exp.')
        player:addExperience(rewards[rewardType])
        return true
    end

    -- EXTRA EXP RATE --
    if rewardType == REWARD_TYPE.EXP_RATE then
        player:setStorageValue(config.EXTRA_EXP_STORAGE, os.time() + config.EXTRA_EXP_TIME)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,
            'You have received extra exp rate of +'
                .. (config.EXTRA_EXP_RATE * 100) - 100
                .. '% for '
                .. secondsToReadable(config.EXTRA_EXP_TIME)
            )
        return true
    end

    -- ITEM --
    if rewardType == REWARD_TYPE.ITEM then
        local item = rewards[rewardType]
        player:addItem(item[1], item[2])
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found an item.')
        return true
    end

    -- EXTRA HP / MANA --
    if rewardType == REWARD_TYPE.EXTRA_HP then
        player:addCondition(rewards[rewardType])
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            'You have received +'.. config.HP_BOOST_PERCENT ..'% health boost for '
            .. secondsToReadable(config.HP_BOOST_TIME)
        )
        return true
    end

    if rewardType == REWARD_TYPE.EXTRA_MP then
        player:addCondition(rewards[rewardType])
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            'You have received +'.. config.MP_BOOST_PERCENT ..'% mana boost for '
            .. secondsToReadable(config.MP_BOOST_TIME)
        )
    end
    return true
end
act:id(21355) -- change this
act:register()

--------[ EVENTS ]--------
local ecb = EventCallback
ecb.onGainExperience = function(self, source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

    if self:getStorageValue(config.EXTRA_EXP_STORAGE) < os.time() then
        return exp
    end

    exp = exp * config.EXTRA_EXP_RATE
    return exp
end
ecb:register(1)
the ID is a UNIQUEID or ACTIONID?
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,149
Solutions
122
Reaction score
1,361
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
the ID is a UNIQUEID or ACTIONID?
the id is the itemid, when it comes to actionid it is used aid, and when it is uniqueid it is uid

1641272583579.png

21355 should be the ID of the chest item, or whatever you want
if you want it to be an actionID you can change id to aid in the script
 

VagosClubTM

Member
Joined
Aug 16, 2019
Messages
155
Reaction score
20
Location
Chile
the id is the itemid, when it comes to actionid it is used aid, and when it is uniqueid it is uid

View attachment 64419

21355 should be the ID of the chest item, or whatever you want
if you want it to be an actionID you can change id to aid in the script
how does it work? where does the script go? in revscript? in actions? is it for a chest or a lever? I can't understand it, I come from an old version of tibia 760 xml, it would be of great help, please guide me in advance, thank you very much
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,149
Solutions
122
Reaction score
1,361
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
how does it work? where does the script go? in revscript? in actions? is it for a chest or a lever? I can't understand it, I come from an old version of tibia 760 xml, it would be of great help, please guide me in advance, thank you very much
All Revscripts go in the folder: data/scripts/
 
Top