• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [TFS 1.3] Target item in slot

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
Is there a way the script returns the transform only if the target item is in the slot ring?
Example: if the target item is not in the ring slot, returns false, if the target item is in the ring slot returns transform
:confused::confused:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ring = player:getSlotItem(CONST_SLOT_RING)
    if not ring then
        return false
    end
    if target.itemid ~= 2357 and ring:getId() ~= 2357 then
        return false
    end
  
        ring:transform(2123)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Congratulations!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        item:remove()
    return true
end
 
Solution
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end

    if target == ringItem then
         print("do something here")
    end
    return true
end
Is there a way the script returns the transform only if the target item is in the slot ring?
Example: if the target item is not in the ring slot, returns false, if the target item is in the ring slot returns transform
:confused::confused:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ring = player:getSlotItem(CONST_SLOT_RING)
    if not ring then
        return false
    end
    if target.itemid ~= 2357 and ring:getId() ~= 2357 then
        return false
    end
 
        ring:transform(2123)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Congratulations!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        item:remove()
    return true
end
Not sure if you want the item of use to be separate from the ring your transforming. But hope this is what you mean.

LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ring = player:getSlotItem(CONST_SLOT_RING)
    if item ~= ring then
        return false
    end
    item:transform(2123)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Congratulations!')
    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    return true
end
 
Last edited:
Not sure if you want the item of use to be separate from the ring your transforming. But hope this is what you mean.

LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ring = player:getSlotItem(CONST_SLOT_RING)
    if not item == ring then
        return false
    end
    item:transform(2123)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Congratulations!')
    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    return true
end
the target item must be in the slot
Example: I want to use item x in the item y, however the item y must be in the ring slot, otherwise it returns false
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if not ringItem then
        return true
    end

    if target == ringItem then
         print("do something here")
    end
    return true
end
 
Last edited:
Solution
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local it = ItemType(target.uid)
    if not it then
        return true
    end

    if it:getSlotPosition() == SLOTP_RING then
        print("do something here")
    end
    return true
end
did not work, and did not show the print on the console o_O
 
Back
Top