Advertisement
Carontee

Password ModalWindow

Feb 12th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.81 KB | None | 0 0
  1. --[[ Visite Xtibia.com para saber mais.
  2.            Créditos Caronte ]]
  3.  
  4. -- Crie um arquivo.lua em Creaturescripts/scripts
  5. -- Nele adicione:
  6.  
  7. --------------------------------
  8. function onModalWindow(player, modalWindowId, buttonId, choiceId)  
  9.     if modalWindowId == 5468 then
  10.    
  11.         local entry = player:getStorageValue(5468)
  12.        
  13.         if (entry == (nil or -1)) or tonumber(entry) > 123 then
  14.             entry = ""
  15.         end
  16.        
  17.         if buttonId == 100 then
  18.             dofile('data/movements/scripts/passwordTile.lua')
  19.             --creature:setNoMove(false)
  20.             if tonumber(entry) == password then
  21.                 player:sendTextMessage(MESSAGE_STATUS_SMALL, "Welcome")
  22.                 player:getPosition():sendMagicEffect(13)
  23.                 player:unregisterEvent("modal_password")
  24.                 addEvent(function() player:setStorageValue(5468, -1) end, 10000)
  25.                
  26.             else
  27.                 player:teleportTo(fromPos)
  28.                 player:getPosition():sendMagicEffect(14)
  29.                 player:sendTextMessage(MESSAGE_STATUS_SMALL, "Get OFF")
  30.                 player:unregisterEvent("modal_password")
  31.                 player:setStorageValue(5468, -1)
  32.             end
  33.            
  34.            
  35.         else
  36.             entry = entry .."".. (buttonId - 100)
  37.             player:setStorageValue(5468, (tonumber(entry)))
  38.            
  39.             return pass_window:sendToPlayer(player)
  40.         end
  41.     end
  42.    
  43.     if modalWindowId == 5469 then
  44.         pass_window:sendToPlayer(player)
  45.     end
  46.  
  47.     return
  48. end
  49. -------------------------
  50.  
  51.  
  52. --[[ Agora em creaturescripts.xml adicione a seguinte tag:
  53.  
  54. <event type="ModalWindow" name="modal_password" script="modalpass.lua" />
  55.  
  56. ]]
  57.  
  58.  
  59.  
  60. -- Crie um arquivo.lua em Movements/scripts
  61. -- Nele adicione:
  62.  
  63. -----------------------
  64. function onStepIn(creature, item, position, fromPosition)
  65.  
  66.     password = 123
  67.     if creature:getStorageValue(5468) == password then
  68.         creature:sendTextMessage(MESSAGE_STATUS_SMALL, "Welcome")
  69.         creature:getPosition():sendMagicEffect(13)
  70.         return true
  71.     end
  72.     dofile('data/lib/passwordWindow.lua')
  73.      creature:registerEvent("modal_password")
  74.       fpass_window:sendToPlayer(creature)
  75.       --creature:setNoMove(true)
  76.     fromPos = fromPosition 
  77.     return true
  78. end
  79. --------------------------
  80.  
  81.  
  82. --[[ Agora em movements.xml adicione a seguinte tag:
  83.  
  84.     <movevent event="StepIn" actionid="5468" script="passwordTile.lua" />
  85.  
  86. ]]
  87.  
  88.  
  89. -- Por último e não menos importante, crie um aquivo em data/lib, e adicione isto dentro:
  90.  
  91.     pass_title = "Password Please!"
  92.     pass_message = "To pass, you have to digit your password!"
  93.  
  94.     pass_window = ModalWindow(5468, pass_title, pass_message)  
  95.        
  96.     pass_window:addButton(103, "3")
  97.     pass_window:addButton(100, "Ok")
  98.     pass_window:addButton(102, "2")
  99.     pass_window:addButton(101, "1")
  100.    
  101.  
  102.     pass_window:setDefaultEnterButton(100)
  103.    
  104.    
  105.     fpass_window = ModalWindow(5469, "Notification", "Opsss, to continue you have to digit password!") 
  106.     fpass_window:addButton(100, "Ok")
  107.     fpass_window:setDefaultEnterButton(100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement