• 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 [TFS 1.4.2] Shows a modalwindow when onStepIn

F

Fairytail

Guest
looking for a script, when player step in portal tile, it send small module window asking 'are you sure you want to leave?' 'yes' 'no'
yes, steps on tile
no, closes module and not step on tile
 
Solution
I'm going to ask the TFS ChatBot:
fbtty.gif

I'm going to test it:

fdgt.gif
Omg
925488627608326204.webp


Only for TFS 1.5+

script.lua
Lua:
local moveEvent = MoveEvent()
function moveEvent.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local modalWindow = ModalWindow{
        title = "Teleport",
        message = "Are you sure you want to teleport?",
    }

    modalWindow:addButton("Yes", function(player, button, choice)
        player:teleportTo(Position(x, y, z))
    end)

    modalWindow:addButton("No")
    modalWindow:setDefaultEnterButton("Yes")...
Lua:
local action = 50045

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)
    if not isPlayer(cid) or isPlayerGhost(cid) then
        return true
    end

    if item.actionid == action then
        local title = "Teleport Confirmation"
        local message = "Are you sure you want to be teleported?"
        local window = ModalWindow(1001, title, message)

        window:addButton(100, "Yes")
        window:addButton(101, "No")

        window:setDefaultEnterButton(100)
        window:setDefaultEscapeButton(101)

        window:sendToPlayer(cid)
        return true
    end

    return true
end

function onModalWindow(cid, modalWindowId, buttonId, choiceId)
    if modalWindowId == 1001 then
        if buttonId == 100 then
            doTeleportThing(cid, {x = 100, y = 100, z = 7})
        end
    end
end
 
I'm going to ask the TFS ChatBot:
fbtty.gif

I'm going to test it:

fdgt.gif
Omg
925488627608326204.webp


Only for TFS 1.5+

script.lua
Lua:
local moveEvent = MoveEvent()
function moveEvent.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local modalWindow = ModalWindow{
        title = "Teleport",
        message = "Are you sure you want to teleport?",
    }

    modalWindow:addButton("Yes", function(player, button, choice)
        player:teleportTo(Position(x, y, z))
    end)

    modalWindow:addButton("No")
    modalWindow:setDefaultEnterButton("Yes")
    modalWindow:setDefaultEscapeButton("No")
    modalWindow:sendToPlayer(player)
    return true
end

moveEvent:position(Position(x, y, z))
moveEvent:register()
 
Solution
Funny how people will not share information. But are willing to make script for you. I am using chat gpt. Just google it. What is that TFS chat bot I dunno. Can be a bot simply called TFS chatbot..
i believe its TFS Chatbot cuz they arleady provided all functions within TFS enviroment, if you use ChatGPT you need to Teach GPT how to Correctly Code & Provide The Lua Functions from yout OT or Project, if you fal to do so GPT will Make Random Functions That Doesnt Exist AT ALL on TFS but at the end you may be able to figureout how to make that script work correctly but for sure i would love to have acess to that tfs bot hehe
 
Back
Top