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,515 / 5,000 EXPStages PROTO8.6 ENGINEUltron OT RANK PTS6.6 -9% VOTES0 #2 FEATURED US Nefera 192 / 0 EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.9 +25% VOTES0 #3 FEATURED CL ZHYRAVEX 13 / 500 EXPx5 PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.7 +100% VOTES0 #4 FEATURED ES Deixis 0 / 0 EXPStages PROTO1098 ENGINETFS RANK PTS4.0 -61% VOTES1 #5 DE DBU Online 207 / 400 EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS6.1 +1,000% VOTES0 #6 BR Exordion Legacy 82 / 2,000 EXPx2 PROTO7.72 ENGINEExordion RANK PTS5.7 +2% VOTES0 #7 MX Marlboro War 33 / 300 EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -28% VOTES0 #8 BR Tibinha YurOts 28 / 150 EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.5 +3% VOTES0 #9 ES JustRL FreeTC 1530 21 / 250 EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS5.0 +19% VOTES0 #10 US Wiki Ots 55 / 1,000 EXPx9999 PROTOcustom client ENGINETFS 1.4.2 RANK PTS5.0 +100% VOTES0 #11 PL Lubelski 11 / 1,000 EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.9 -17% VOTES0 #12 BR Turion Server 0 / 2,000 EXPx1 PROTO7.4 ENGINETurion 7.7 Project RANK PTS4.6 +253% VOTES0 #13 PL ReWar 0 / 2,000 EXPcustom PROTO8.6 ENGINEOther RANK PTS4.6 +100% VOTES0 #14 US Halera 0 / 0 EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.4 -80% VOTES0 #15 PL Velesta 0 / 1,000 EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.4 -100% VOTES0 #16 US BerethaOnline 0 / 2,000 EXPStages PROTO15.0 ENGINETFS RANK PTS4.3 -76% VOTES0 #17 ES Farlia Global 2026 0 / 333 EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS4.0 -100% VOTES0 #18 SE MortalisOT Custom 0 / 500 EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS4.0 -100% VOTES0 #19 RU Oldavia | 8.60 0 / 0 EXPx9999 PROTO8.6 ENGINETFS 1.3 RANK PTS3.9 +100% VOTES0 #20 US Rommania 0 / 3,000 EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.6 -89% VOTES0 #21 MX Maeli 2 / 150 EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.5 -33% VOTES0 #22 ES DarkDragon EXPx10 PROTO8.6 ENGINECanary RANK PTS0.0 0% VOTES0
Top