• 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.X+ [1.3] Add new item to player dont decay

Morrison

Intermediate OT User
Joined
Mar 15, 2009
Messages
266
Solutions
3
Reaction score
119
Location
Exive me
GitHub
none
I have action when player use give a sword with time to decay, but dont work

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local it = player:addItem(2390, 1)
    it:setAttribute(ITEM_ATTRIBUTE_DURATION, 60000)
    it:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
    it:decay()
    return true
end
 
I have action when player use give a sword with time to decay, but dont work

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local it = player:addItem(2390, 1)
    it:setAttribute(ITEM_ATTRIBUTE_DURATION, 60000)
    it:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
    it:decay()
    return true
end

local it = player:addItem(2390, 1) This dont perform any action

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:addItem(2390, 1)
    return true
end

XML:
    <item id="2390" name="Sixty Minute Man">
        <attribute key="weight" value="15000" />
        <attribute key="defense" value="5" />
        <attribute key="attack" value="5" />
        <attribute key="weaponType" value="sword" />
        <attribute key="decayTo" value="0" />
        <attribute key="duration" value="60" />
        <attribute key="showduration" value="1" />
        <attribute key="showattributes" value="1" />
    </item>
 
Perhaps create and configure the item before giving it to the player? (incase the return reference from player:addItem isn't working as intented).
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item = Game.createItem(2390, 1)
    item:decay()
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, 60000)
    item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
    player:addItemEx(item)
    return true
end
 
local it = player:addItem(2390, 1) This dont perform any action
yep easy way, but i really wan to use this function 😭

Perhaps create and configure the item before giving it to the player? (incase the return reference from player:addItem isn't working as intented).
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item = Game.createItem(2390, 1)
    item:decay()
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, 60000)
    item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
    player:addItemEx(item)
    return true
end
i try i do your same example but dont works 😭
 

Attachments

Back
Top