Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. function Player:sendProxyModalWindow()
  2.     local proxyList = configManager.getString(configKeys.PROXY_LIST)
  3.     if #proxyList > 0 then
  4.         local proxies = proxyList:split(";")
  5.         local window = ModalWindow {
  6.             title = "Select a proxy",
  7.             message = "Please select a proxy, keep in mind that" ..
  8.             "\nthe proxy will only start working once you" ..
  9.             "\nlogout and type your account details again."
  10.         }
  11.         local accountId = self:getAccountId()
  12.         local playerId = self:getId()
  13.  
  14.         local noProxyChoice = window:addChoice("No Proxy Server")
  15.         noProxyChoice.proxyId = 0
  16.         noProxyChoice.proxyName = "No server"
  17.  
  18.         for i = 1, #proxies do
  19.             local proxyInfo = proxies[i]:split(",")
  20.             local choice = window:addChoice(proxyInfo[4] .. " Proxy Server")
  21.             choice.proxyId = proxyInfo[1]
  22.             choice.proxyName = proxyInfo[4]
  23.         end
  24.  
  25.         window:addButton("Select",
  26.             function(button, choice)
  27.                 db.query("UPDATE `accounts` SET `proxy_id` = " .. choice.proxyId .. " WHERE `id` = " .. accountId)
  28.                 local player = Player(playerId)
  29.                 if player then
  30.                     player:sendTextMessage(MESSAGE_INFO_DESCR, choice.proxyName .. " Proxy Server selected. Logout and type your account details again to start using it!")
  31.                 end
  32.             end)
  33.  
  34.         window:addButton("Cancel")
  35.         window:setDefaultEscapeButton('Cancel')
  36.         window:setDefaultEnterButton('Select')
  37.         window:sendToPlayer(self)
  38.     end
  39. end
  40.  
  41. function onSay(player, words, param)
  42.     return player:sendProxyModalWindow()
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement