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

Action [TFS 1.0] Elevator System

EverClaw

New Member
Joined
Apr 26, 2014
Messages
36
Reaction score
4
CURRENT POSTING DATE/TIME
6/8/2014 - 4:32 PM
So far this works for my purposes, but i would like to get some optimization..

Would be interested to know if there was any other butons like:
Code:
modalWindow:addButton(0x00, "Select")
modalWindow:setDefaultEnterButton(0x00)
modalWindow:addButton(0x01, "Cancel")
modalWindow:setDefaultEscapeButton(0x01)
{OR}
Maybe a button that executes a custom function?!
{AND}

I would like to know if its possible to get the house information, if there is any.


Map Setup

2582kn7.jpg


Every Floor with Elevator access should look like this.
ta63yu.png


Each Floor is Auto selected inside the Modal Pop-up Window!
v4ro9e.png


IF YOU WANT IT TO BE ON-CLICK INSTEAD OF ON STEP-IN:

<action actionid="20202" script="Custom Actions/Elevator_System.lua"/>
actions/script/Elevator_System.lua
Code:
--  Elevator System TFS 1.0
--~ Walk in and Click Wheelie to open up the level selector.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local Elevator_Lever_Pos = getThingPos(item.uid)
    local Players_Pos = getCreaturePosition(cid)
    local Elevator_Storage = 25368
    local tag = ''
    function isHousetile(position)
        local t = Tile(position)
        if t == nil then
            return false
        end
        return t:hasFlag(TILESTATE_HOUSE)
    end
    if isHousetile(getCreaturePosition(cid)) then -- is inside a house
        tag = tag.. '~ House ~'
    else
        tag = tag.. 'Building'
    end
    setPlayerStorageValue(cid, Elevator_Storage, 0)
    if (getPlayerStorageValue(cid, Elevator_Storage) == 0) and ((Players_Pos.x+1 == Elevator_Lever_Pos.x) and (Players_Pos.y == Elevator_Lever_Pos.y) and (Players_Pos.z == Elevator_Lever_Pos.z)) then
        local player = Player(cid)
        local modal = ModalWindow(2, "Elevator Systems", "Select which Floor would you like to go to:")
        local Player_Org_Pos = getPlayerPosition(cid)
        for i = 0, 15 do
            if(getTileThingByPos({x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=i, stackpos=1}).itemid == 20261) then
                modal:addChoice(i, "[".. tag .."] Floor ["..i.."]")
            end
        end
        setPlayerStorageValue(cid, Elevator_Storage, 1)
        modal:addButton(0x00, "Select")
        modal:setDefaultEnterButton(0x00)
        modal:addButton(0x01, "Cancel")
        modal:setDefaultEscapeButton(0x01)
        modal:sendToPlayer(player)
        return true
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Stand inside Elevator!")
    end
end

IF YOU WANT IT TO BE ON-STEP IN INSTEAD OF ON CLICK:
<movevent event="StepIn" itemid="20261" script="Custom/Elevator_System.lua"/>
movements/scripts/Elevator_System.lua
[For Both Scripts, Remove the "setPlayerStorageValue(cid, Elevator_Storage, 0)" here]
Code:
--  Elevator System TFS 1.0
--~ Walk in to open up the elevator level selector.
function onStepIn(cid, item, position, fromPosition)
    local Elevator_Lever_Pos = getThingPos(item.uid)
    local Players_Pos = getCreaturePosition(cid)
    local Elevator_Storage = 25368
    local tag = ''
    function isHousetile(position)
        local t = Tile(position)
        if t == nil then
            return false
        end
        return t:hasFlag(TILESTATE_HOUSE)
    end
    if isHousetile(getCreaturePosition(cid)) then -- is inside a house
        tag = tag.. '~ House ~'
    else
        tag = tag.. 'Building'
    end
setPlayerStorageValue(cid, Elevator_Storage, 0)
    if (getPlayerStorageValue(cid, Elevator_Storage) == 0)then
        local player = Player(cid)
        local modal = ModalWindow(2, "Elevator Systems", "Select which Floor would you like to go to:")
        local Player_Org_Pos = getPlayerPosition(cid)
        for i = 0, 15 do
            if(getTileThingByPos({x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=i, stackpos=1}).itemid == 20261) then
                modal:addChoice(i, "[".. tag .."] Floor ["..i.."]")
            end
        end
        modal:addButton(0x00, "Select")
        modal:setDefaultEnterButton(0x00)
        modal:addButton(0x01, "Cancel")
        modal:setDefaultEscapeButton(0x01)
        modal:sendToPlayer(player)
        return true
    end
end

CODE TO MAKE THE WINDOWS WORK [Will Work For All Modal Windows]
<event type="modalwindow" name="ModalWindow" script="modal.lua"/>
creaturescripts/scripts/modal.lua
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
    if modalWindowId == 1 then
        local choiceMsg = choiceMsg..""
        if choiceId == 1 then
            choiceMsg = choiceMsg.."I want to live"
        elseif choiceId == 2 then
            choiceMsg = choiceMsg.."Pft, I don't give a f*ck"
        elseif choiceId == 3 then
            choiceMsg = choiceMsg.."Please... NO!"
        else
            choiceMsg ="Be my guest."
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've Selected Floor #" .. choiceId.. ".\n Message: " ..choiceMsg..".")
    end
    -- IF ELEVATOR
    if modalWindowId == 2 then
        local Player_Org_Pos = getPlayerPosition(cid)
        local t = Player_Org_Pos.z
        local choiceMsg = ""
        local tag = ''
        if buttonId == 0x00 then -- Select
            doPlayerPopupFYI(cid, "  -~!~- Please Wait -~!~-\n-~! Elevator Starting !~-\n  -~! Floor #" .. t .. " -> #" .. choiceId .. " !~-")
        end
        if buttonId == 0x01 then -- Cancel
            return false
        end
        function isHousetile(position)
            local t = Tile(position)
            if t == nil then
                return false
            end
            return t:hasFlag(TILESTATE_HOUSE)
        end
        if isHousetile(getCreaturePosition(cid)) then -- is inside a house
            tag = tag.. '~ House #XXXX ~'
        else
            tag = tag.. 'Building'
        end
        for q = 0, 15 do
            if choiceId == q then
                choiceMsg = choiceMsg.."[".. tag.. "] Floor ["..q.."]"
                if (Player_Org_Pos.z == q) then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your already on this floor.")
                    return true
                else
                    if Player_Org_Pos.z <= q then
                        for i = Player_Org_Pos.z, q do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=i}, TRUE)
                        end
                    else
                        for i = q, Player_Org_Pos.z do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=t}, TRUE)
                            t = t - 1
                        end
                    end
                end
            elseif (choiceId == 6 or choiceId == 7) then
                local Elevator_6 = getTileInfo({x=Player_Org_Pos.x+1, y=Player_Org_Pos.y, z=6}).itemid
                local Elevator_6 = getTileInfo({x=Player_Org_Pos.x+1, y=Player_Org_Pos.y, z=6}).itemid
                if (Player_Org_Pos.z ~= 6) or (Player_Org_Pos.z == 7) then
                    if (Player_Org_Pos.z <= 6) then
                        for i = Player_Org_Pos.z, 6 do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=i}, TRUE)
                        end
                    else
                        for i = 6, Player_Org_Pos.z do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=t}, TRUE)
                            t = t - 1
                        end
                    end
                    choiceMsg ="[".. tag.. "] Floor [6]"
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've Selected Floor #" .. choiceId.. ".\n Message: " ..choiceMsg..".")
                    return true
                elseif (Player_Org_Pos.z == 6) or (Player_Org_Pos.z ~= 7) then
                    if (Player_Org_Pos.z <= 7) then
                        for i = Player_Org_Pos.z, 7 do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=i}, TRUE)
                        end
                    else
                        for i = 7, Player_Org_Pos.z do
                            addEvent(doTeleportThing, i * 250 , cid, {x=Player_Org_Pos.x, y=Player_Org_Pos.y, z=t}, TRUE)
                            t = t - 1
                        end
                    end
                    choiceMsg ="[".. tag.. "] Floor [7]"
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've Selected Floor #" .. choiceId.. ".\n Message: " ..choiceMsg..".")
                    return true
                end
            end
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've Selected Floor #" .. choiceId.. ".\n Message: " ..choiceMsg..".")
    end
    return true
end
 
Last edited:
Come back sometime tomorrow, and ill probably have most of the things that i can do to it done, ill start keeping a timestame on the Update log/reason
 
Hopeing This can be updated...
I am currently using OTX Server 3 with game Version 10.98-10.99 and the only part of this that works is the pop-up box, once you change the stackpos to 0, but cannot get it to teleport the player =(
 
Back
Top