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

Lua check item pos/stackpos? TFS 1.3x

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
Hello, I'm trying to disable the player from using an item unless he has it on the inventory, the first method that comes to my mind is checking for item position but I can't find out how to do that in multiple ways like, checking if item is in depot, check if item is in ground, check if item is in monster body, check if item is in some random container on the ground...
 
Solution
E
look firework script for example:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if fromPosition.x ~= CONTAINER_POSITION then
        fromPosition:sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
    else
        local position = player:getPosition()
        position:sendMagicEffect(CONST_ME_HITBYFIRE)
        position:sendMagicEffect(CONST_ME_EXPLOSIONAREA)
        player:say("Ouch! Rather place it on the ground next time.", TALKTYPE_MONSTER_SAY)
        player:addHealth(-10)
        player:addAchievementProgress("Rocket in Pocket", 3)
    end
    player:addAchievementProgress("Fireworks in the Sky", 250)
    item:remove()
    return true
end
look firework script for example:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if fromPosition.x ~= CONTAINER_POSITION then
        fromPosition:sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
    else
        local position = player:getPosition()
        position:sendMagicEffect(CONST_ME_HITBYFIRE)
        position:sendMagicEffect(CONST_ME_EXPLOSIONAREA)
        player:say("Ouch! Rather place it on the ground next time.", TALKTYPE_MONSTER_SAY)
        player:addHealth(-10)
        player:addAchievementProgress("Rocket in Pocket", 3)
    end
    player:addAchievementProgress("Fireworks in the Sky", 250)
    item:remove()
    return true
end
 
Solution
Back
Top