ayuda con scrip the supreme cube (modal window teleport) a corregirlo correctamente para que solo vips y que no estén en batle, puedan usarlo, canary

LOLO

Mordragor Chronicles
Member
Messages
28
Points
133
ayuda con scrip the supreme cube (modal window teleport) a corregirlo correctamente para que solo vips y que no estén en batle, puedan usarlo, CANARY, 13.32, por favor, y de antemano, muchas gracias.
JavaScript:
local teleportLocations  = {
    { name="Thais", position = Position(32369, 32241, 7) },
    { name="Edron", position = Position(33217, 31814, 8) },
    { name="Carlin", position = Position(32360, 31782, 7) },
    { name="Venore", position = Position(32957, 32076, 7) },
    { name="Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name="Port Hope", position = Position(32594, 32745, 7) },
    { name="Yalahar", position = Position(32787, 31276, 7) },
    { name="Kazordoon", position = Position(32649, 31925, 11) },
    { name="Darashia", position = Position(33213, 32454, 1) },
    { name="Rathleton", position = Position(33594, 31899, 6) },
    { name="Svargrond", position = Position(32212, 31132, 7) },
    { name="Farmine", position = Position(33023, 31521, 11) },
    { name="Ankrahmun", position = Position(33194, 32853, 8) },
    { name="Liberty Bay", position = Position(32317, 32826, 7) },
    { name="Roshamuul", position = Position(33513, 32363, 6) },
    { name="Gray beach", position = Position(33447, 31323, 9) },
    { name="Issavi", position = Position(33921, 31477, 5) },
    { name="Krailos", position = Position(33655, 31666, 8) },
    { name="Hunts Teleports", position = Position(31891, 32024, 8) },
    { name="Forge", position = Position(31646, 32043, 8) },
}



local teleportEvent = Action()

local teleportItemID = 31633 -- Replace with the actual item ID


function teleportEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- if not player:isPlayer() then
    if not player:isVip() then
      player:sendCancelMessage("Somente players Vip podem usar este item!")
        return false
    end

    player:registerEvent("TeleportModalWindowLocations")

    local teleportWindow = ModalWindow(1, "Select a Location")
    for i, location in ipairs(teleportLocations) do
        teleportWindow:addChoice(i, location.name)
    end
    teleportWindow:addButton(0, "Select")
    teleportWindow:addButton(1, "Cancel")
    teleportWindow:setDefaultEnterButton(0)
    teleportWindow:setDefaultEscapeButton(1)
    teleportWindow:sendToPlayer(player)

    return true
end

function Player.ProcessTeleport(self, position)
    if not self or not position then return false end
    if self:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        self:sendTextMessage(MESSAGE_FAILURE, "Voce nao pode usar enquanto esta¡ em battle")
        return false
    end
    if self:isPzLocked() then
        self:sendTextMessage(MESSAGE_FAILURE, "Voce nao pode usar enquanto esta¡ em battle")
        return false
    end
    self:teleportTo(position)
    return true
end
    

teleportEvent:id(teleportItemID)
teleportEvent:register()

-- Create a modal window event
local modalEvent = CreatureEvent("TeleportModalWindowLocations")

function modalEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("TeleportModalWindowLocations")
    if buttonId == 0 then
        local selectedLocation = teleportLocations[choiceId]
        if selectedLocation then
            player:teleportTo(selectedLocation.position)
        end
    end
    return true
end

modalEvent:type("modalwindow")
modalEvent:register()
 
Solution
me ayudaron a repararlo, en otland.
créditos:

JavaScript:
local teleportLocations  = {
    { name="Thais", position = Position(32369, 32241, 7) },
    { name="Edron", position = Position(33217, 31814, 8) },
    { name="Carlin", position = Position(32360, 31782, 7) },
    { name="Venore", position = Position(32957, 32076, 7) },
    { name="Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name="Port Hope", position = Position(32594, 32745, 7) },
    { name="Yalahar", position = Position(32787, 31276, 7) },
    { name="Kazordoon", position = Position(32649, 31925, 11) },
    { name="Darashia", position = Position(33213, 32454, 1) },
    { name="Rathleton", position =...
me ayudaron a repararlo, en otland.
créditos:

JavaScript:
local teleportLocations  = {
    { name="Thais", position = Position(32369, 32241, 7) },
    { name="Edron", position = Position(33217, 31814, 8) },
    { name="Carlin", position = Position(32360, 31782, 7) },
    { name="Venore", position = Position(32957, 32076, 7) },
    { name="Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name="Port Hope", position = Position(32594, 32745, 7) },
    { name="Yalahar", position = Position(32787, 31276, 7) },
    { name="Kazordoon", position = Position(32649, 31925, 11) },
    { name="Darashia", position = Position(33213, 32454, 1) },
    { name="Rathleton", position = Position(33594, 31899, 6) },
    { name="Svargrond", position = Position(32212, 31132, 7) },
    { name="Farmine", position = Position(33023, 31521, 11) },
    { name="Ankrahmun", position = Position(33194, 32853, 8) },
    { name="Liberty Bay", position = Position(32317, 32826, 7) },
    { name="Roshamuul", position = Position(33513, 32363, 6) },
    { name="Gray beach", position = Position(33447, 31323, 9) },
    { name="Issavi", position = Position(33921, 31477, 5) },
    { name="Krailos", position = Position(33655, 31666, 8) },
    { name="Hunts Teleports", position = Position(31891, 32024, 8) },
    { name="Forge", position = Position(31646, 32043, 8) },
}

local teleportItemID = 31633 -- Replace with the actual item ID

local teleportEvent = Action()

function teleportEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:isVip() then
        player:sendCancelMessage("Somente jogadores VIP podem usar este item!")
        return true
    end
  
    player:registerEvent("TeleportModalWindowLocations")
  
    local teleportWindow = ModalWindow(1, "Selecione um Local")
    for i, location in ipairs(teleportLocations) do
        teleportWindow:addChoice(i, location.name)
    end
    teleportWindow:addButton(1, "Selecionar")
    teleportWindow:addButton(2, "Cancelar")
    teleportWindow:setDefaultEnterButton(1)
    teleportWindow:setDefaultEscapeButton(2)
    teleportWindow:sendToPlayer(player)
  
    return true
end

teleportEvent:id(teleportItemID)
teleportEvent:register()

local modalEvent = CreatureEvent("TeleportModalWindowLocations")

function modalEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("TeleportModalWindowLocations")
  
    if buttonId == 1 then
        local selectedLocation = teleportLocations[choiceId]
        if selectedLocation then
            return player:ProcessTeleport(selectedLocation.position)
        end
    end
  
    return true
end

modalEvent:type("modalwindow")
modalEvent:register()

function Player.ProcessTeleport(self, position)
    if not self or not position then return false end
    if self:getCondition(CONDITION_INFIGHT) then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Você não pode se teleportar enquanto está em combate.")
        return false
    end
    if self:isPzLocked() then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Você não pode se teleportar enquanto está protegido por uma zona de paz.")
        return false
    end
  
    self:teleportTo(position)
    self:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  
    return true
end
 
Solution
me ayudaron a repararlo, en otland.
créditos:

JavaScript:
local teleportLocations  = {
    { name="Thais", position = Position(32369, 32241, 7) },
    { name="Edron", position = Position(33217, 31814, 8) },
    { name="Carlin", position = Position(32360, 31782, 7) },
    { name="Venore", position = Position(32957, 32076, 7) },
    { name="Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name="Port Hope", position = Position(32594, 32745, 7) },
    { name="Yalahar", position = Position(32787, 31276, 7) },
    { name="Kazordoon", position = Position(32649, 31925, 11) },
    { name="Darashia", position = Position(33213, 32454, 1) },
    { name="Rathleton", position = Position(33594, 31899, 6) },
    { name="Svargrond", position = Position(32212, 31132, 7) },
    { name="Farmine", position = Position(33023, 31521, 11) },
    { name="Ankrahmun", position = Position(33194, 32853, 8) },
    { name="Liberty Bay", position = Position(32317, 32826, 7) },
    { name="Roshamuul", position = Position(33513, 32363, 6) },
    { name="Gray beach", position = Position(33447, 31323, 9) },
    { name="Issavi", position = Position(33921, 31477, 5) },
    { name="Krailos", position = Position(33655, 31666, 8) },
    { name="Hunts Teleports", position = Position(31891, 32024, 8) },
    { name="Forge", position = Position(31646, 32043, 8) },
}

local teleportItemID = 31633 -- Replace with the actual item ID

local teleportEvent = Action()

function teleportEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:isVip() then
        player:sendCancelMessage("Somente jogadores VIP podem usar este item!")
        return true
    end
 
    player:registerEvent("TeleportModalWindowLocations")
 
    local teleportWindow = ModalWindow(1, "Selecione um Local")
    for i, location in ipairs(teleportLocations) do
        teleportWindow:addChoice(i, location.name)
    end
    teleportWindow:addButton(1, "Selecionar")
    teleportWindow:addButton(2, "Cancelar")
    teleportWindow:setDefaultEnterButton(1)
    teleportWindow:setDefaultEscapeButton(2)
    teleportWindow:sendToPlayer(player)
 
    return true
end

teleportEvent:id(teleportItemID)
teleportEvent:register()

local modalEvent = CreatureEvent("TeleportModalWindowLocations")

function modalEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("TeleportModalWindowLocations")
 
    if buttonId == 1 then
        local selectedLocation = teleportLocations[choiceId]
        if selectedLocation then
            return player:ProcessTeleport(selectedLocation.position)
        end
    end
 
    return true
end

modalEvent:type("modalwindow")
modalEvent:register()

function Player.ProcessTeleport(self, position)
    if not self or not position then return false end
    if self:getCondition(CONDITION_INFIGHT) then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Você não pode se teleportar enquanto está em combate.")
        return false
    end
    if self:isPzLocked() then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Você não pode se teleportar enquanto está protegido por uma zona de paz.")
        return false
    end
 
    self:teleportTo(position)
    self:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
 
    return true
end

Para lo que era registrar o verificar si esta en batalla o en PZ con esta linea bastaba:

JavaScript:
if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
En el caso, ahi en el script, lo separaron, en funcion, para mandar un mensaje distinto.
No respondí porque el script que tengo de supreme cube, no es para canary y no funciona debido al modal windows, es distinto del servidor Endless y no funciona en canary.
 
gracias, y si, como quedaría?
JavaScript:
local teleportLocations = {
    { name = "Thais", position = Position(32369, 32241, 7) },
    { name = "Edron", position = Position(33217, 31814, 8) },
    { name = "Carlin", position = Position(32360, 31782, 7) },
    { name = "Venore", position = Position(32957, 32076, 7) },
    { name = "Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name = "Port Hope", position = Position(32594, 32745, 7) },
    { name = "Yalahar", position = Position(32787, 31276, 7) },
    { name = "Kazordoon", position = Position(32649, 31925, 11) },
    { name = "Darashia", position = Position(33213, 32454, 1) },
    { name = "Rathleton", position = Position(33594, 31899, 6) },
    { name = "Svargrond", position = Position(32212, 31132, 7) },
    { name = "Farmine", position = Position(33023, 31521, 11) },
    { name = "Ankrahmun", position = Position(33194, 32853, 8) },
    { name = "Liberty Bay", position = Position(32317, 32826, 7) },
    { name = "Roshamuul", position = Position(33513, 32363, 6) },
    { name = "Gray beach", position = Position(33447, 31323, 9) },
    { name = "Issavi", position = Position(33921, 31477, 5) },
    { name = "Krailos", position = Position(33655, 31666, 8) },
    { name = "Hunts Teleports", position = Position(31891, 32024, 8) },
    { name = "Forge", position = Position(31646, 32043, 8) },
}

local teleportItemID = 31633 -- Replace with the actual item ID

local teleportEvent = Action()

function teleportEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:isVip() then
        player:sendCancelMessage("Somente jogadores VIP podem usar este item!")
        return true
    end
 
    player:registerEvent("TeleportModalWindowLocations")
 
    local teleportWindow = ModalWindow(1, "Selecione um Local")
    for i, location in ipairs(teleportLocations) do
        teleportWindow:addChoice(i, location.name)
    end
    teleportWindow:addButton(1, "Selecionar")
    teleportWindow:addButton(2, "Cancelar")
    teleportWindow:setDefaultEnterButton(1)
    teleportWindow:setDefaultEscapeButton(2)
    teleportWindow:sendToPlayer(player)
 
    return true
end

teleportEvent:id(teleportItemID)
teleportEvent:register()

local modalEvent = CreatureEvent("TeleportModalWindowLocations")

function modalEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("TeleportModalWindowLocations")
 
    if buttonId == 1 then
        local selectedLocation = teleportLocations[choiceId]
        if selectedLocation then
            if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
                return player:ProcessTeleport(selectedLocation.position)
            else
                player:sendCancelMessage("You cannot teleport under these conditions.")
            end
        end
    end
 
    return true
end

modalEvent:type("modalwindow")
modalEvent:register()

function Player.ProcessTeleport(self, position)
    if not self or not position then return false end
 
    self:teleportTo(position)
    self:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
 
    return true
end
 
JavaScript:
local teleportLocations = {
    { name = "Thais", position = Position(32369, 32241, 7) },
    { name = "Edron", position = Position(33217, 31814, 8) },
    { name = "Carlin", position = Position(32360, 31782, 7) },
    { name = "Venore", position = Position(32957, 32076, 7) },
    { name = "Ab'Dendriel", position = Position(32732, 31634, 7) },
    { name = "Port Hope", position = Position(32594, 32745, 7) },
    { name = "Yalahar", position = Position(32787, 31276, 7) },
    { name = "Kazordoon", position = Position(32649, 31925, 11) },
    { name = "Darashia", position = Position(33213, 32454, 1) },
    { name = "Rathleton", position = Position(33594, 31899, 6) },
    { name = "Svargrond", position = Position(32212, 31132, 7) },
    { name = "Farmine", position = Position(33023, 31521, 11) },
    { name = "Ankrahmun", position = Position(33194, 32853, 8) },
    { name = "Liberty Bay", position = Position(32317, 32826, 7) },
    { name = "Roshamuul", position = Position(33513, 32363, 6) },
    { name = "Gray beach", position = Position(33447, 31323, 9) },
    { name = "Issavi", position = Position(33921, 31477, 5) },
    { name = "Krailos", position = Position(33655, 31666, 8) },
    { name = "Hunts Teleports", position = Position(31891, 32024, 8) },
    { name = "Forge", position = Position(31646, 32043, 8) },
}

local teleportItemID = 31633 -- Replace with the actual item ID

local teleportEvent = Action()

function teleportEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:isVip() then
        player:sendCancelMessage("Somente jogadores VIP podem usar este item!")
        return true
    end
 
    player:registerEvent("TeleportModalWindowLocations")
 
    local teleportWindow = ModalWindow(1, "Selecione um Local")
    for i, location in ipairs(teleportLocations) do
        teleportWindow:addChoice(i, location.name)
    end
    teleportWindow:addButton(1, "Selecionar")
    teleportWindow:addButton(2, "Cancelar")
    teleportWindow:setDefaultEnterButton(1)
    teleportWindow:setDefaultEscapeButton(2)
    teleportWindow:sendToPlayer(player)
 
    return true
end

teleportEvent:id(teleportItemID)
teleportEvent:register()

local modalEvent = CreatureEvent("TeleportModalWindowLocations")

function modalEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("TeleportModalWindowLocations")
 
    if buttonId == 1 then
        local selectedLocation = teleportLocations[choiceId]
        if selectedLocation then
            if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
                return player:ProcessTeleport(selectedLocation.position)
            else
                player:sendCancelMessage("You cannot teleport under these conditions.")
            end
        end
    end
 
    return true
end

modalEvent:type("modalwindow")
modalEvent:register()

function Player.ProcessTeleport(self, position)
    if not self or not position then return false end
 
    self:teleportTo(position)
    self:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
 
    return true
end
donde se meteria ese codigo?
 

Tibia Server Lists

#1 FEATURED US Ultron OT 1,493 / 5,000Online EXPStages PROTO8.6 ENGINEUltron OT RANK PTS5.9 +100% VOTES0 #2 FEATURED US Nefera 161 / 0Online EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.1 +100% VOTES0 #3 FEATURED ES Deixis 1 / 0Online EXPStages PROTO1098 ENGINETFS RANK PTS3.7 +100% VOTES1 #4 FEATURED ES Maeli 9 / 150Online EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.7 +100% VOTES0 #5 MX Marlboro War 30 / 300Online EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -33% VOTES0 #6 BR Tibinha YurOts 18 / 150Online EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.2 -14% VOTES0 #7 US Halera 2 / 0Online EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.9 -83% VOTES0 #8 BR Exordion Legacy 52 / 2,000Online EXPx2 PROTO7.72 ENGINEExordion RANK PTS4.9 +100% VOTES0 #9 PL Lubelski 7 / 1,000Online EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.6 -15% VOTES0 #10 DE DBU Online 0 / 400Online EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS4.3 +100% VOTES0 #11 PL ReWar 0 / 2,000Online EXPcustom PROTO8.6 ENGINEOther RANK PTS4.3 0% VOTES0 #12 PL Velesta 0 / 1,000Offline EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.3 -99% VOTES0 #13 ES JustRL FreeTC 1530 22 / 250Online EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS4.3 +100% VOTES0 #14 ES Farlia Global 2026 0 / 333Offline EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS3.9 -22% VOTES0 #15 SE MortalisOT Custom 0 / 500Offline EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS3.8 +100% VOTES0 #16 US Rommania 0 / 500Online EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.6 +100% VOTES0 #17 US BerethaOnline 1 / 2,000Online EXPStages PROTO10.98 ENGINETFS RANK PTS3.5 +100% VOTES0
Top