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

Help with creating script for TFS 1.5

Mokk

New Member
Joined
Jun 2, 2023
Messages
12
Reaction score
4
Hello, I would like someone to help me create a script that temporarily adds attributes to an item using another item.

Example: When using X item on the sword, you gain +5 sword skill for X hours

I use TFS 1.5 for 8.60 downgrade by nekiro, thank you all for your attention!
 
Solution
Lua:
local config = {
    time = 1000 * 60 * 60, -- 1 hour
    skillAmount = 10,
    itemUse = 2294,
    itemTarget = 2160,
    effect = CONST_ME_BATS,
    storage = 10040,
    exhaustTime = 60,
    removeItem = false,
    exhaustTable = {},
}

local skill = Condition(CONDITION_ATTRIBUTES)
skill:setParameter(CONDITION_PARAM_TICKS, config.time)
skill:setParameter(CONDITION_PARAM_SKILL_SWORD, config.skillAmount)

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local playerGuid = player:getGuid()
    local timeAmount = config.exhaustTable[playerGuid]
    if timeAmount and timeAmount > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) ...
Lua:
local config = {
    time = 1000 * 60 * 60, -- 1 hour
    skillAmount = 10,
    itemUse = 2294,
    itemTarget = 2160,
    effect = CONST_ME_BATS,
    storage = 10040,
    exhaustTime = 60,
    removeItem = false,
    exhaustTable = {},
}

local skill = Condition(CONDITION_ATTRIBUTES)
skill:setParameter(CONDITION_PARAM_TICKS, config.time)
skill:setParameter(CONDITION_PARAM_SKILL_SWORD, config.skillAmount)

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    local playerGuid = player:getGuid()
    local timeAmount = config.exhaustTable[playerGuid]
    if timeAmount and timeAmount > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
        return true
    end
    if target.itemid == config.itemTarget then
        if config.removeItem then
            item:remove()
        end
        player:addCondition(skill)
        player:getPosition():sendMagicEffect(config.effect)
        config.exhaustTable[playerGuid] = os.time() + config.exhaustTime
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Buff has been activated.')
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You can use it only on itemBlaBla')
    end
    return true
end

action:id(config.itemUse)
action:register()
 
Solution
Hello, thank you for responding promptly. Your script worked, added the skills using the stone, I would like to know if you could add some more functions to make the script more efficient.

The changes would be:

When adding the enchantment to the weapon, show the enchantment and time.
Example:
You see a giant sword (atk: 15)
+5 Sword (TIME)

Another change, if it's not too much to ask, would be so that when removing the item from the slot, the attributes would also be removed.

Thank you for your attention!
 
Back
Top