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

problem with item

  • Thread starter Thread starter verdehile95
  • Start date Start date
V

verdehile95

Guest
When I use the item from my inventory, it disappears as expected. However, when I use the item when it is on the ground, it doesn't disappear, and I can use it infinitely. tfs 1.4.2
LUA:
-- Script for item usage
local ITEM_ID = 30097 -- ID of the item to be used
local XP_REWARD = 100   -- Amount of experience points to reward

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if the item ID matches
    if item.itemid == ITEM_ID then
        -- Remove the item from the player's inventory
        player:removeItem(ITEM_ID, 1)
        
        -- Reward the player with experience points
        player:addExperience(XP_REWARD)
        
        -- Send a message to the player (optional)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have gained " .. XP_REWARD .. " experience points!")
        
        return true -- Action successful
    end

    return false -- Action not allowed
end
 
Well if you write player in front of the item it's obviously gonna search for the item inside the player. I don't think you need the player: just write item: remove() or removeItem whatever the command for your otserver is.
 

Similar threads

Back
Top