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