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

ItemType Remove

luhfe

New Member
Joined
Apr 26, 2018
Messages
48
Reaction score
2
Hello, nite nite.
Does anyone know the command line to remove the equipments that are in the backpack slots, armor slot, etc?
 
Hello, nite nite.
Does anyone know the command line to remove the equipments that are in the backpack slots, armor slot, etc?

I will assume you are using TFS 1.0

Lua:
player:removeItem(itemId, count[, subType = -1[, ignoreEquipped = false]])

example use:

Lua:
player:removeItem(2681, 1, -1, false)

change false to true if you want to ignore equipped items

and you should probably post it here :p

Support
 
Sorry for my ignorance but will this remove all equipped items? I'm using TFs 1.3 if I'm not mistaken
Ty for reply !
-------------------
and i dont want remove item by ID, i want remove item on equipped slot ! ty
 
Last edited:
Sorry for my ignorance but will this remove all equipped items? I'm using TFs 1.3 if I'm not mistaken
Ty for reply !
-------------------
and i dont want remove item by ID, i want remove item on equipped slot ! ty

this should remove all items from the player

Lua:
local slots = {CONST_SLOT_FIRST, CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_BACKPACK, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING, CONST_SLOT_AMMO}

local player = Player(cid)

for i = 1, #slots do
    local item = player:getSlotItem(slots[i])
    player:removeItem(item, 1)
end

not tested though
 
make sure you have a player variable somewhere in your npc file where you can use this with, otherwise you'll get an error
Lua:
for slot = 1, 10 do
    local item = player:getSlotItem(slot)
    if item then
        item:remove()
    end
end
 
Lua:
local Slott = {[1] = CONST_SLOT_LEFT, [2] = CONST_SLOT_RIGHT, [3] = CONST_SLOT_RING, [4] = CONST_SLOT_HEAD, [5] = CONST_SLOT_NECKLACE, [6] = CONST_SLOT_BACKPACK}
for Slott = 1, 10 do
    local item = player:getSlotItem(slott)
    if item then
        item:remove()
    end
end

'=' Expected near 'for' :'(
 
Lua:
local Slott = {[1] = CONST_SLOT_LEFT, [2] = CONST_SLOT_RIGHT, [3] = CONST_SLOT_RING, [4] = CONST_SLOT_HEAD, [5] = CONST_SLOT_NECKLACE, [6] = CONST_SLOT_BACKPACK}
for Slott = 1, 10 do
    local item = player:getSlotItem(slot)
    if item then
        item:remove()
    end
end

'=' Expected near 'for' :'(
C++:
enum slots_t : uint8_t {
    CONST_SLOT_WHEREEVER = 0,
    CONST_SLOT_HEAD = 1,
    CONST_SLOT_NECKLACE = 2,
    CONST_SLOT_BACKPACK = 3,
    CONST_SLOT_ARMOR = 4,
    CONST_SLOT_RIGHT = 5,
    CONST_SLOT_LEFT = 6,
    CONST_SLOT_LEGS = 7,
    CONST_SLOT_FEET = 8,
    CONST_SLOT_RING = 9,
    CONST_SLOT_AMMO = 10,

    CONST_SLOT_FIRST = CONST_SLOT_HEAD,
    CONST_SLOT_LAST = CONST_SLOT_AMMO,
};
If you want explicit slot id's then you can do something like this.
Lua:
local slots = {1, 2, 3, 5, 6, 9}

for _, slot in pairs(slots) do
    local item = player:getSlotItem(slot)
    if item then
        item:remove()
    end
end
 
Lua:
local Slott = {CONST_SLOT_FIRST, CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_BACKPACK, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING, CONST_SLOT_AMMO}


local item = player:getSlotItem(Slott)
item:remove()

eERqzD.png
 
This way works but dont remove only Armor slot, why that?

Lua:
local slots = {1, 2, 3, 5, 6, 7, 8, 9, 10}
for _, slot in pairs(slots) do
    local item = player:getSlotItem(slot)
    if item then
        item:remove()
    end
end
 
Lua:
local Slott = {CONST_SLOT_FIRST, CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_BACKPACK, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING, CONST_SLOT_AMMO}


local item = player:getSlotItem(Slott)
item:remove()

eERqzD.png

You always need to check for a value before you use it. This is a fail safe mechanism so whatever scripts you write don't throw errors.
Example with comments
Lua:
 -- all slots to look for
local slots = {1, 2, 3, 5, 6, 9}
-- cycle through the slots table and store the slot id in slot
for _, slot in pairs(slots) do
    -- get the player's slot item and store it in item
    local item = player:getSlotItem(slot)
    -- if the item exists meaning its not nil then continue
    if item then
        -- if it exists then remove the item
        item:remove()
    end
end
 
You always need to check for a value before you use it. This is a fail safe mechanism so whatever scripts you write don't throw errors.
Example with comments
Lua:
 -- all slots to look for
local slots = {1, 2, 3, 5, 6, 9}
-- cycle through the slots table and store the slot id in slot
for _, slot in pairs(slots) do
    -- get the player's slot item and store it in item
    local item = player:getSlotItem(slot)
    -- if the item exists meaning its not nil then continue
    if item then
        -- if it exists then remove the item
        item:remove()
    end
end

You cod works man, ty ... but you know why dont delete the armor slot ?? o_O"


Lua:
local slots = {1, 2, 3, 5, 6, 7, 8, 9, 10}
for _, slot in pairs(slots) do
    local item = player:getSlotItem(slot)
    if item then
        item:remove()
    end
end
 
Back
Top