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

Passing tile only possible wearing specific item id TFS 1.2

froy

Active Member
Joined
Sep 30, 2009
Messages
151
Solutions
3
Reaction score
36
Hey!
Used search function but without succés.
Im looking for script where x position cannot be passed without wearing x item in specific armor_const_slot.

Has this alrdy been Done?
Cannot find it..
 
Solution
Hey!
Used search function but without succés.
Im looking for script where x position cannot be passed without wearing x item in specific armor_const_slot.

Has this alrdy been Done?
Cannot find it..
Lua:
local required_armor = 2463

function onStepIn(creature, item, toPosition, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end

    local armor = player:getSlotItem(CONST_SLOT_ARMOR)
    if not armor or armor.itemid ~= required_armor then
        player:teleportTo(fromPosition, true)
        player:sendCancelMessage("You do not have the required item.")
    end
    return true
end
Code:
function onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() and CONST_SLOT_HELMET == Itemid. then
        item:transform(453, 1)
        item:decay()
    end
end

function onStepOut(creature, item, position, fromPosition)
    item:transform(452, 1)
    item:decay()
end

Something like this?
Due to not being an expert I'd appreciate some help to finish this up! :)
 
Hey!
Used search function but without succés.
Im looking for script where x position cannot be passed without wearing x item in specific armor_const_slot.

Has this alrdy been Done?
Cannot find it..
Lua:
local required_armor = 2463

function onStepIn(creature, item, toPosition, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end

    local armor = player:getSlotItem(CONST_SLOT_ARMOR)
    if not armor or armor.itemid ~= required_armor then
        player:teleportTo(fromPosition, true)
        player:sendCancelMessage("You do not have the required item.")
    end
    return true
end
 
Solution
Code:
local required_armor = 2463

function onStepIn(creature, item, toPosition, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end

    local armor = player:getSlotItem(CONST_SLOT_ARMOR)
    if not armor or armor.itemid ~= required_armor then
        player:teleportTo(fromPosition, true)
        player:sendCancelMessage("You do not have the required item.")
    end
    return true
end

Thanks, working perfectly! If someone wishes to use this with other armor slots it's easy configurable just edit the const_slot_
to whatever your distrb is using and edit local required_armor = (desired id of the item required).
Thanks @Apollos !
 
The armor :)
Try this:
Lua:
local required_armor = 2463

function onStepIn(creature, item, toPosition, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end

    local armor = player:getSlotItem(CONST_SLOT_ARMOR)
    if armor and armor.itemid == required_armor then
        armor:remove(1)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Armor item accepted.")
    else
        player:teleportTo(fromPosition, true)
        player:sendCancelMessage("You do not have the required item.")
    end
    return true
end
 
Back
Top