• 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 1.1 - Weapon duration

narko

vertrauenswürdig ~
Joined
Oct 19, 2008
Messages
1,317
Solutions
2
Reaction score
132
Location
Unknown
Hi there! I hope someone can help me out with this as I've already tried for hours. I was trying to make a weapon that has a duration. As it is now, the weapon starts counting the duration once I create it. What I want to achieve is that the duration starts counting once the player equips the item and stop counting when it deEquip, this can be done using two different ID's but I wonder if this can be done using the same item ID.

Here's a script of what I tried to do, ofc it didn't work.
LUA:
function onEquip(cid, item, slot)
    local player = Player(cid)
    local slots = getPlayerSlotItem(cid,slot)

    if slots.itemid ~= item.itemid then
        return true
    end

    local item = player:getSlotItem(CONST_SLOT_LEFT)
    print(item)

     item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
     print("Start duration!")
end
function onDeEquip(cid, item, slot)
    local player = Player(cid)
    local item = player:getSlotItem(CONST_SLOT_LEFT)
    print(item)

     item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, false)
    print("Stop duration!")
end

Thanks in advance.
 
Last edited:
and then where is the return true or return false?
I guess that the functions will not work without them
about the funcionality of what you want, holy shit I need it to haha
also, did you try remove the attr instead of set it false?
 
Last edited:
edit: just try remove the attribute decaystate
EDIT 2: TESTED and it don't work, I'm trying here
onEquip
Code:
item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
item:decay()
onDeEquip
Code:
item:removeAttribute(ITEM_ATTRIBUTE_DECAYSTATE)
because the item will still have the attribute duration, we just need handle with the decaystate
 
Last edited:
Back
Top