Advertisement
NonSequitur

Untitled

Dec 11th, 2015
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. function onModalWindow(player, modalWindowId, buttonId, choiceId)
  2.     local modalWindow
  3.     for _, window in ipairs(modalWindows.windows) do
  4.         if window.id == modalWindowId then
  5.             modalWindow = window
  6.             break
  7.         end
  8.     end
  9.  
  10.     if not modalWindow then
  11.         return true
  12.     end
  13.  
  14.     local playerId = player:getId()
  15.     if not modalWindow.players[playerId] then
  16.         return true
  17.     end
  18.     modalWindow.players[playerId] = nil
  19.  
  20.     local choice = modalWindow.choices[choiceId]
  21.  
  22.     for _, button in ipairs(modalWindow.buttons) do
  23.         if button.id == buttonId then
  24.             local callback = button.callback or modalWindow.defaultCallback
  25.             if callback then
  26.                 callback(button, choice)
  27.                 break
  28.             end
  29.         end
  30.     end
  31.  
  32.     return true
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement