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

TFS 1.X+ Edron rock lever

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,759
Solutions
31
Reaction score
999
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
1720568665130.png


Hi! I need a little support with this lever, I wonder how can I avoid players from pulling the lever if a player is standing on the rock position? This way the player doesn't stand on the stone if someone else pulls the lever (if it also sends a return message will be nice!). Like is shown here:

1720568797577.png

Here's the script
LUA:
local stonePosition = Position(1055, 946, 10)
local relocatePosition = Position(1055, 946, 10)

local orcLeverRemoveStone = Action()

function orcLeverRemoveStone.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(Position(1055, 946, 10))
    if item.itemid == 1945 then
        local stoneItem = tile:getItemById(1285)
        if stoneItem then
            stoneItem:remove()
            item:transform(1946)
        end
    else
        tile:relocateTo(relocatePosition, true)
        Game.createItem(1285, 1, stonePosition)
        item:transform(1945)
    end
    return true
end

orcLeverRemoveStone:uid(9192)
orcLeverRemoveStone:register()

Thanks in advance! Regards ^^
 
Try
LUA:
local stonePosition = Position(1055, 946, 10)
local relocatePosition = Position(1055, 946, 10)

local orcLeverRemoveStone = Action()

function orcLeverRemoveStone.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(stonePosition)
    if tile then
        local creatures = tile:getCreatures()
        if creatures and #creatures > 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "You cannot pull the lever while someone is standing on the stone position.")
            return true
        end
    end

    if item.itemid == 1945 then
        local stoneItem = tile:getItemById(1285)
        if stoneItem then
            stoneItem:remove()
            item:transform(1946)
        end
    else
        Game.createItem(1285, 1, stonePosition)
        item:transform(1945)
    end
    return true
end

orcLeverRemoveStone:uid(9192)
orcLeverRemoveStone:register()
 
Last edited:
Back
Top