• 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+ addEvent

theduck

Member
Joined
Dec 6, 2018
Messages
246
Reaction score
20
Code:
function onSay(player, words, param)
  
    
    
    local function removeitem(position)
    local removeitem = Tile(position):getItemById(1754) 
    
    if teleportItem then
        teleportItem:remove() 
        
        position:sendMagicEffect(CONST_ME_POFF)
    end
end
 
   
         player:addItem(1754, 1)
         

addEvent(removeitem, 10,position) 
         
      return true
end


I am trying to make the player create an item in his position and after 1 minute this item disappears
 
Solution
LUA:
local function removeItem(position, itemId)
    local tile = Tile(position)
    if tile then
        local item = tile:getItemById(itemId)
        if item then
            item:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
    end
end

local itemId = 1754

function onSay(player, words, param)
    Game.createItem(itemId, 1, player:getPosition())
    addEvent(removeItem, 10000, player:getPosition(), itemId)
    return true
end
LUA:
local function removeItem(position, itemId)
    local tile = Tile(position)
    if tile then
        local item = tile:getItemById(itemId)
        if item then
            item:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
    end
end

local itemId = 1754

function onSay(player, words, param)
    Game.createItem(itemId, 1, player:getPosition())
    addEvent(removeItem, 10000, player:getPosition(), itemId)
    return true
end
 
Last edited:
Solution
LUA:
local function removeItem(position, itemId)
    local tile = Tile(position)
    if tile then
        local item = tile:getItemById(itemId)
        if item then
            item:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
    end
end

local itemId = 1754

function onSay(player, words, param)
    Game.createItem(itemId, 1, player:getPosition())
    addEvent(removeItem, 10000, position, itemId)
    return true
end
tested he's creating but not removing
 

Similar threads

Replies
7
Views
327
Xikini
X
Back
Top