Advertisement
imring

AutoLogin [ SA:MP ] for Pears Project

Dec 15th, 2017
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.71 KB | None | 0 0
  1. script_name('AutoLoginForPP')
  2. script_author('imring')
  3. script_version('1.2.1')
  4.  
  5. boolmsg = true
  6. -- true - включить сообщения
  7. -- false - выключить сообщения
  8.  
  9. colorTexts = 0xFF8C00
  10. serversPP = {
  11.     ['176.32.37.62'] = 'Pears Project 1',
  12.     ['176.32.39.34'] = 'Pears Project 2',
  13.     ['176.32.37.63'] = 'Pears Project 3'
  14. }
  15.  
  16. function main()
  17.     while not isSampAvailable() do wait(0) end
  18.     while sampGetCurrentServerAddress() == nil do wait(0) end
  19.     local server = serversPP[sampGetCurrentServerAddress()]
  20.     if server == nil then
  21.         if boolmsg then sampAddChatMessage('Скрипт '..thisScript().name..' не загружён [ '..thisScript().version..' ]. Причина: подключённый сервер НЕ Pears Project.', colorTexts) end
  22.         thisScript():unload()
  23.     else if boolmsg then  sampAddChatMessage('Скрипт '..thisScript().name..' загружён [ '..thisScript().version..' ]. Сервер: '..server..'. Команда: [ /autolog ]', colorTexts) end end
  24.     if not doesFileExist("moonloader\\autologPP.txt") then
  25.         local f = io.open('moonloader/autologPP.txt', 'a')
  26.         local nick = 'nick: nil'
  27.         f:write(nick..'\n')
  28.         local pass = 'pass: nil'
  29.         f:write(pass..'\n')
  30.         local pin = 'pin: nil'
  31.         f:write(pin)
  32.         f:close()
  33.     end
  34.     sampRegisterChatCommand('autolog', autoLogin)
  35.     wait(-1)
  36. end
  37.  
  38. function autoLogin(gacode)
  39.     local googlecode = string.match(gacode, '(%d+)')
  40.     local text = ''
  41.     local f = io.open('moonloader/autologPP.txt', 'r')
  42.     for lines in f:lines() do
  43.         local i = string.match(lines, '.+: (.*)')
  44.         text = text..' '..i
  45.     end
  46.     text = text..' '..tostring(googlecode)
  47.     lua_thread.create(loginPlayer, text)
  48. end
  49.  
  50. function loginPlayer(text)
  51.     local _, idme = sampGetPlayerIdByCharHandle(playerPed)
  52.     local nickname, password, pincode, gacode = string.match(text, ' (.*) (.*) (.*) (.*)')
  53.     if not sampTextdrawIsExists(292) and sampTextdrawGetString ~= 'PEARS' then
  54.         if nickname == sampGetPlayerNickname(idme) and string.lower(password) ~= 'nil' then
  55.             if sampTextdrawIsExists(232) then
  56.                 sampSendClickTextdraw(232)
  57.                 wait(100)
  58.                 if not sampIsDialogActive() and sampGetCurrentDialogId() ~= 1 then return end
  59.                 sampSendDialogResponse(1, 1, 0, password)
  60.                 wait(100)
  61.                 sampCloseCurrentDialogWithButton(0)
  62.             end
  63.             if sampTextdrawIsExists(233) then
  64.                 sampSendClickTextdraw(233)
  65.                 wait(100)
  66.                 if sampTextdrawIsExists(269) then
  67.                     if string.lower(pincode) ~= 'nil' then
  68.                         for i = 1, tonumber(#pincode) do
  69.                             local pin = string.sub(pincode, i, i)
  70.                             for i = 0, 8 do
  71.                                 local tdnumb = 2099+i
  72.                                 if sampTextdrawGetString(tdnumb) == pin then
  73.                                     sampSendClickTextdraw(tdnumb)
  74.                                 end
  75.                             end
  76.                         end
  77.                         sampSendClickTextdraw(269)
  78.                     else if boolmsg then sampAddChatMessage(thisScript().name..' не выполнин ввод кода. Причина: Код - \'nil\'.', colorTexts) end end
  79.                 end
  80.             end
  81.             wait(100)
  82.             if sampIsDialogActive() and sampGetCurrentDialogId() == 798 then
  83.                 if gacode ~= 'nil' then
  84.                     sampSendDialogResponse(798, 1, 0, gacode)
  85.                     wait(100)
  86.                     sampCloseCurrentDialogWithButton(0)
  87.                 else if boolmsg then sampAddChatMessage(thisScript().name..' не выполнин ввод Google Auth кода. Причина: Вы не введи Google Auth код.', colorTexts) end end
  88.             end
  89.         else if boolmsg then  sampAddChatMessage(thisScript().name..' не выполнен. Причина: Pass - \'nil\', или Nick не совпадает, измените в autologPP.txt Ваш ник и пароль.', colorTexts) end end
  90.     else if boolmsg then  sampAddChatMessage(thisScript().name..' не выполнен. Причина: Вы авторизированы.', colorTexts) end end
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement