• 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.3 Function Player:AddItem

christx

New Member
Joined
Jun 25, 2017
Messages
24
Reaction score
2
Hi,
I couldn't find any similar topic so I created this one. My problem is, that I don't know how to make this function on 1 specific position, I mean a box that would give 1 item only from 1 position. I tried to make this with pos parameter at actions.xml but no result, every box with id 1738 giving item with ID 22391 and I want to make it only 1 specific box with
pos ={ x=33502,y=32545,z=7}

actions.xml
<action itemid="1738" pos="33502;32545;7" script="roshamuul/item.lua"/>


Item.lua
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local exhaustion = player:getStorageValue(1231231)
    local item = 23391
    local pos = {x=33502,y=32545,z=7}
    if os.time() <= exhaustion then
        player:sendCancelMessage("Nothing seems to happen....")
        return true
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a mouthpiece for a horn.")
    player:addItem(22391, 1)
   
    player:setStorageValue(1231231, os.time() + (1 * 60 * 30))
    return true
end
 
Last edited:
I dont think a pos paramter would work in actions.xml I never seen it anywhere , if I understand correctly you want a special chest/box item in a certain position to give you an item of ID: 22391?
 
Yes @Xinax, I want to place box(id=1738) at roshamuul that giving to players item called "mouthpiece for a horn" (id=22391) 1 per every 24 hours. Right now the box is placed at position 33502;32545;7 and working. everyone can take this item from this box (its ok) but the other boxes (not located at this position) shouldn't giving players this item
 
Last edited:
Would be easier if it were an ActionID/UniqueID as @Static_ said.

Edit and add this at Actions.xml
XML:
<action uniqueid="####" script="#####.lua" />


Save as .lua at 'actions\scripts':
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local exhaustion = player:getStorageValue(1231231)
        if os.time() <= exhaustion then
            player:sendCancelMessage("Nothing seems to happen...")
        return true
        end
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a mouthpiece for a horn.")
            player:addItem(22391, 1) --ItemID
            player:setStorageValue(1231231, os.time() + (1 * 60 * 30))
    return true
end

Then go to RME and add the UniqueID
unknown.png
 
Back
Top