Advertisement
Rawoas13

auth

Oct 22nd, 2020
2,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. -- authData is generated in another script
  2.  
  3. local textId = {
  4.     authorization = 777
  5. }
  6.  
  7. local authData = {
  8.     "|14010|20858|20858|20430|21072|21072|21072|20430|21286|21286|21286|20430|21500|21500|21500|7590|10800|11870|12084|11014|6948|9730|6948|11656|17648|11442|14010|24496|11870|21500|25994|16792|25138",
  9.     "|17862|25994|24496|25780|24924|7590|10372|10372|10372|10372|6948|9730|6948|15080|12298|19146|17434|10800|16792|23640|25780|25780|17648",
  10.     "|16364|22570|24068|22570|22998|22570|23640|22142|7590|11228|10586|10586|10800|6948|9730|6948|24710|21286|17434|18076|24924|11014|16150|15936|14224|25994",
  11.     "|18504|22570|23212|23212|20858|20858|20858|23426|7590|10372|10372|10372|10372|6948|9730|6948|15294|15080|21286|23640|25780|15722|17434|12084|21286|12084"
  12. }
  13.  
  14. gen = function()
  15.     local x = tonumber(string.byte('G'))*((math.sqrt(math.sqrt(1/3^-1)*math.sqrt(1/3^-1))*math.sqrt(math.sqrt(1/9^-1)))) + (9/math.sqrt(1/9^-1^1/9^-1))
  16.     return x
  17. end
  18.  
  19. function gen_decode(b)
  20.     local c = ""
  21.  
  22.     for d,e in next,b do
  23.         c=c..string.char(e/gen())
  24.     end
  25.  
  26.     return c
  27. end
  28.  
  29. function getInfo(str)
  30.     local chars = {}
  31.     for char in str:gmatch("%d+[^|]") do
  32.         chars[#chars + 1] = tonumber(char)
  33.     end
  34.  
  35.     return chars
  36. end
  37.  
  38.  
  39. function eventPopupAnswer(popupID, playerName, answer)
  40.  
  41.     if popupID == textId.authorization then
  42.         local key
  43.         local name
  44.         local authPos
  45.  
  46.         for i = 1, #authData do
  47.             local index = gen_decode(getInfo(authData[i])):match("([%w_+]+#%d%d%d%d)")
  48.             if index == playerName then
  49.                 authPos = i
  50.             end
  51.         end
  52.  
  53.         if not authPos then
  54.             print("<R>Name not found in database. Exiting... <N>["..playerName.."]")
  55.             return
  56.         else
  57.             print("<BV>Name found in database. Confirming the key... <N>["..playerName.."]")
  58.         end
  59.  
  60.         for nick, tag, auth in gen_decode(getInfo(authData[authPos])):gmatch("([%w_+]+)#(%d%d%d%d)(.*)") do
  61.             name = nick .. "#" .. tag
  62.             key = auth:match("[%w_+]+")
  63.         end
  64.        
  65.         if answer == key and playerName == name then
  66.             print("<J>"..answer.."</J> <VP>[CORRECT]</VP>")
  67.             print('<VP>Authorized succesfully. Initializing the script</VP>')
  68.         elseif answer == key and playerName ~= name then
  69.             print("<J>"..answer.."</J>")
  70.             print('<R>Name not valid. Exiting the script...</R>')
  71.         elseif answer ~= key and playerName == name then
  72.             print("<R>"..answer.." [INCORRECT]</R>")
  73.             print('<R>Authorization key not valid. Exiting the script...</R>')
  74.         end
  75.  
  76.     end
  77.  
  78. end
  79.  
  80.  
  81. function eventChatCommand(name, cmd)
  82.  
  83.     if cmd == "auth" then
  84.         ui.addPopup(textId.authorization, 2, "<j>Enter auth key</j>", name, 350, 150, 125, false)
  85.     end
  86.  
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement