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

TFS 0.X How to add temporally a item atribute

runsicky

Member
Joined
Apr 19, 2018
Messages
80
Reaction score
12
I wanna do a system like Imbuements but on 8.60 server (0.4)

But i'm stuck in a thing...
How to add a temporally atribute to a item?

For example:
local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

How to add +10 speed for the item ibID for 20 hours?

bump
 
Last edited by a moderator:
you can always create some kind of system in sources for every item that has a slot with two properties, the actual bonus and the time left for the bonus.
If you dont know how to create it that would be harder :)
 
you can always create some kind of system in sources for every item that has a slot with two properties, the actual bonus and the time left for the bonus.
If you dont know how to create it that would be harder :)

Are u mean to do two atributes, right?
I was thinking about use his example and use a system with only one slot, by using
doSetItemAttribute(ibID, "BonusSpeed", os.time() + 60 * 60 * 20)
For example...

I got the same problem, but i think doSetItemAttribute is working, i think the problem is onLook on script...
 
No bro, the problem still in that function i told before:

on doSetItemAttribute
Code:
[8:35:40.537] [Error - NpcScript Interface]
[8:35:40.537] data/npc/scripts/npc_imbuements.lua:onCreatureSay
[8:35:40.537] Description:
[8:35:40.537] data/npc/scripts/npc_imbuements.lua:60: attempt to call global 'doSetItemAttribute' (a nil value)
[8:35:40.537] stack traceback:
[8:35:40.537]    data/npc/scripts/npc_imbuements.lua:60: in function 'callback'
[8:35:40.537]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[8:35:40.537]    data/npc/scripts/npc_imbuements.lua:29: in function <data/npc/scripts/npc_imbuements.lua:29>

when you say yes to the npc:
Code:
--[[
        CONST_SLOT_FIRST = 1
        CONST_SLOT_HEAD = CONST_SLOT_FIRST
        CONST_SLOT_NECKLACE = 2
        CONST_SLOT_BACKPACK = 3
        CONST_SLOT_ARMOR = 4
        CONST_SLOT_RIGHT = 5
        CONST_SLOT_LEFT = 6
        CONST_SLOT_LEGS = 7
        CONST_SLOT_FEET = 8
        CONST_SLOT_RING = 9
        CONST_SLOT_AMMO = 10
        CONST_SLOT_LAST = CONST_SLOT_AMMO
]]

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic, Description = {}, {}
local thinkMsg = {
        "I can personalise your items, come to me!",
        "Want to upgrade your items temporarily? Come to me!"
}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                      npcHandler:onThink() end

function greetCallback(cid)
        Topic[cid], Description[cid] = 1, nil
        return true
end
function creatureSayCallback(cid, type, msg)
        if not npcHandler:isFocused(cid) then
                return false
        elseif (Topic[cid] == 1) and (msgcontains(msg, 'yes') or msgcontains(msg, 'imbuement') or msgcontains(msg, 'imbuements')) then
                npcHandler:say('Choose the imbuements type: {swiftness}', cid)
                Topic[cid] = 2
      


        elseif Topic[cid] == 2 and msgcontains(msg, 'swiftness') then
                npcHandler:say('What kinda of weapon you want to upgrade? {boots}', cid)
                Topic[cid] = 17

        -- swiftness
        elseif Topic[cid] == 17 and msgcontains(msg, 'boots') then
                local ib_UID = getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
                -- HOW TO CHECK IF PLAYER IS USING A BOOTS?
                local recipient_itemid = 11219 -- compasses
                local recipient_neededammount = 25
                if(getPlayerItemCount(cid, recipient_itemid) >= recipient_neededammount) then
                        doPlayerRemoveItem(cid,recipient_itemid,recipient_neededammount)
                        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
                        npcHandler:say('Here you are. May I help you with something else? ', cid)
                        doSetItemAttribute(ib_UID, "BonusSpeed", os.time() + 60 * 60 * 20)
                        Topic[cid] = 1
                else
                        npcHandler:say('You do not have the recipients enoght to make the Imbuement! May I help you with something else?', cid)
                        Topic[cid] = 1
                end


        end
        return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, 'I hope you made the right choice, have a wonderful day.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Okay well, I guess you don\'t care if someone steals your stuff... You will have no idea if it\'s yours...')
npcHandler:setMessage(MESSAGE_GREET, 'Hello, |PLAYERNAME|! I am a brander. I can personalize any of your items for a price, would you like to continue to the next step?')
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
No bro, the problem still in that function i told before:

on doSetItemAttribute
Code:
[8:35:40.537] [Error - NpcScript Interface]
[8:35:40.537] data/npc/scripts/npc_imbuements.lua:onCreatureSay
[8:35:40.537] Description:
[8:35:40.537] data/npc/scripts/npc_imbuements.lua:60: attempt to call global 'doSetItemAttribute' (a nil value)
[8:35:40.537] stack traceback:
[8:35:40.537]    data/npc/scripts/npc_imbuements.lua:60: in function 'callback'
[8:35:40.537]    data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[8:35:40.537]    data/npc/scripts/npc_imbuements.lua:29: in function <data/npc/scripts/npc_imbuements.lua:29>

when you say yes to the npc:
Code:
--[[
        CONST_SLOT_FIRST = 1
        CONST_SLOT_HEAD = CONST_SLOT_FIRST
        CONST_SLOT_NECKLACE = 2
        CONST_SLOT_BACKPACK = 3
        CONST_SLOT_ARMOR = 4
        CONST_SLOT_RIGHT = 5
        CONST_SLOT_LEFT = 6
        CONST_SLOT_LEGS = 7
        CONST_SLOT_FEET = 8
        CONST_SLOT_RING = 9
        CONST_SLOT_AMMO = 10
        CONST_SLOT_LAST = CONST_SLOT_AMMO
]]

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic, Description = {}, {}
local thinkMsg = {
        "I can personalise your items, come to me!",
        "Want to upgrade your items temporarily? Come to me!"
}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                      npcHandler:onThink() end

function greetCallback(cid)
        Topic[cid], Description[cid] = 1, nil
        return true
end
function creatureSayCallback(cid, type, msg)
        if not npcHandler:isFocused(cid) then
                return false
        elseif (Topic[cid] == 1) and (msgcontains(msg, 'yes') or msgcontains(msg, 'imbuement') or msgcontains(msg, 'imbuements')) then
                npcHandler:say('Choose the imbuements type: {swiftness}', cid)
                Topic[cid] = 2
     


        elseif Topic[cid] == 2 and msgcontains(msg, 'swiftness') then
                npcHandler:say('What kinda of weapon you want to upgrade? {boots}', cid)
                Topic[cid] = 17

        -- swiftness
        elseif Topic[cid] == 17 and msgcontains(msg, 'boots') then
                local ib_UID = getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
                -- HOW TO CHECK IF PLAYER IS USING A BOOTS?
                local recipient_itemid = 11219 -- compasses
                local recipient_neededammount = 25
                if(getPlayerItemCount(cid, recipient_itemid) >= recipient_neededammount) then
                        doPlayerRemoveItem(cid,recipient_itemid,recipient_neededammount)
                        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
                        npcHandler:say('Here you are. May I help you with something else? ', cid)
                        doSetItemAttribute(ib_UID, "BonusSpeed", os.time() + 60 * 60 * 20)
                        Topic[cid] = 1
                else
                        npcHandler:say('You do not have the recipients enoght to make the Imbuement! May I help you with something else?', cid)
                        Topic[cid] = 1
                end


        end
        return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, 'I hope you made the right choice, have a wonderful day.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Okay well, I guess you don\'t care if someone steals your stuff... You will have no idea if it\'s yours...')
npcHandler:setMessage(MESSAGE_GREET, 'Hello, |PLAYERNAME|! I am a brander. I can personalize any of your items for a price, would you like to continue to the next step?')
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


bump
 
Back
Top