1
[Talkaction] Comando, TP modalWindow el Mar Ene 23, 2018 11:46 am
[Adm] SevuOT
![[Adm] SevuOT](https://2img.net/u/2712/30/40/04/avatars/10743-22.jpg)
Miembro

Aqui estan los codigos:
--> Talkaction
XML
- Código:
<talkaction words="!teleport" separator=" " script="teleport_modal.lua" />
LUA
- Código:
---@Tabla de destinos
--# Las posiciones se configuran en el archivo ( creaturescripts/script )
local destinos = {
{ name = 'Temple', inpz = true, inlvl = 0, inprmy = false },
{ name = 'Depot', inpz = true, inlvl = 50, inprmy = false },
{ name = 'Skills', inpz = true, inlvl = 100, inprmy = true }
}
---@Variable en segundos
local delaySayCommand = 20
local delaySayStorage = 77000
---@Talkaction Teleport por ventanas modal
--#Devuelve boolean
--#Modal_Window_Teleports
function onSay(player, words, param)
local delaySay = player:getStorageValue(delaySayStorage)
if delaySay > os.time() then
player:sendCancelMessage('Exaust command.')
return false
end
local modalWindow = ModalWindow(1000, 'Teleport Modal Window System', 'Elige algun destino al que quieras ir.')
for index, destino in pairs(destinos) do
local msg = {
inpz = (destino.inpz and '[yes]' or '[no]'),
inlvl = destino.inlvl,
inprmy = (destino.inprmy and '[yes]' or '[no]')
}
local msgOut = '[ ' .. destino.name .. ' ]' .. msg.inpz .. ', lvl:[' .. msg.inlvl .. '], ' .. msg.inprmy
modalWindow:addChoice(index, msgOut)
end
modalWindow:addButton(1, 'Go')
modalWindow:addButton(2, 'Cancel')
modalWindow:setDefaultEnterButton(1)
modalWindow:setDefaultEscapeButton(2)
player:registerEvent('WindowTeleports')
modalWindow:sendToPlayer(player)
return false
end
--> Creaturescripts
XML
- Código:
<event type="modalwindow" name="WindowTeleports" script="windows/window teleport.lua"/>
LUA
- Código:
---@Tabla de destinos
local destinos = {
{ 'Temple', Position(1000, 1000, 7), inpz = true, inlvl = 0, inprmy = false },
{ 'Depot', Position(1000, 1000, 7), inpz = true, inlvl = 50, inprmy = false },
{ 'Skills', Position(1000, 1000, 7), inpz = true, inlvl = 100, inprmy = true }
}
function onModalWindow(player, modalWindowId, buttonId, choiceId)
if modalWindowId == 1000 then
if buttonId == 1 then
local destino = destinos[choiceId]
if destino ~= nil then
if destino.inpz and player:isPzLocked() then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'No esta permitido viajar a este sitio con Pz.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
if destino.inlvl > player:getLevel() then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'No esta permitido viajar a este sitio si no eres lvl' .. destino.inlvl .. '.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
if destino.inprmy and player:getPremiumDays() > 0 then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'No esta permitido viajar a este sitio si no eres premium.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
local toPosition = destino[2]
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:teleportTo(toPosition, true)
toPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
end
end
return true
end
Última edición por The_Pain el Mar Ene 23, 2018 5:24 pm, editado 1 vez (Razón : Actualizado!!!)

Si tu cuenta de PayPal no esta verificada no importara, igual aceptan pagos con cuentas no verificadas.
![[Talkaction] Comando, TP modalWindow TRJEB8aSRYK5IulEU6ilJw](https://2img.net/image.prntscr.com/image/TRJEB8aSRYK5IulEU6ilJw.png)