Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- https://www.blast.hk/threads/59236/
- script_version('1.1')
- require "lib.sampfuncs"
- require "lib.moonloader"
- local imgui = require 'imgui'
- local encoding = require 'encoding'
- local memory = require "memory"
- encoding.default = 'CP1251'
- u8 = encoding.UTF8
- local objects = {}
- local auth = false
- local txd_panel = {}
- local iScreenWidth, iScreenHeight = getScreenResolution()
- local status = false
- local sampev = require 'lib.samp.events'
- local l_start = false
- local ip = 'ws://45.140.167.12:27802'
- local websocket = require 'websocket'
- local client = websocket.client.copas({timeout = 2})
- local res, https = pcall(require, 'ssl.https')
- assert(res, 'Library ssl.https not found')
- -----------------CONFIG--------------------
- local inicfg = require 'inicfg'
- if not doesFileExist('moonloader\\config\\FactoryBot\\FactoryBot.ini') then
- if not doesDirectoryExist('moonloader\\config\\FactoryBot') then
- createDirectory('moonloader\\config\\FactoryBot')
- end
- local ini ={ config = { } }
- inicfg.save(ini, 'FactoryBot\\FactoryBot')
- end
- local directIni = 'moonloader\\config\\FactoryBot\\FactoryBot.ini'
- local mainIni = inicfg.load(nil, directIni)
- ------------ImGUI-----------
- local password = imgui.ImBuffer((mainIni.config.password and mainIni.config.password or '') ,256)
- local auth_status = imgui.ImBool(false)
- function main()
- while not isSampAvailable() do wait(100) end
- sampRegisterChatCommand('fbstart', function()
- status = not status
- if status then
- sampAddChatMessage('{00ff00}[F-BOT]{ffffff} - Бот включен', -1)
- writeMemory(7634870, 1, 1, 1)
- writeMemory(7635034, 1, 1, 1)
- memory.fill(7623723, 144, 8)
- memory.fill(5499528, 144, 6)
- else
- sampAddChatMessage('{00ff00}[F-BOT]{ffffff} - Бот выключен', -1)
- writeMemory(7634870, 1, 0, 0)
- writeMemory(7635034, 1, 0, 0)
- memory.hex2bin('5051FF1500838500', 7623723, 8)
- memory.hex2bin('0F847B010000', 5499528, 6)
- end
- end)
- autoupdate("No links", '['..string.upper(thisScript().name)..']: ', "No links")
- local connected, err = client:connect(ip, '')
- if err then print(err) end
- if connected then
- if not connected then
- sampAddChatMessage('{B40431}[FY-BOT]{ffffff} - Ошибка соединения с сервером.',-1)
- else
- sampAddChatMessage('{B40431}[FY-BOT]{ffffff} - Вы успешно подключились к серверу ZAKO. Ожидание данных авторизации...',-1)
- sampSendChat('/stats')
- lua_thread.create(function()
- while true do wait(0)
- imgui.Process = auth_status.v
- local message, opcode = client:receive()
- if message then
- local result = decodeJson(message)
- if result['action']=='auth' then
- auth_status.v = false
- auth = true
- elseif result['action']=='chatmessage' then
- sampAddChatMessage('{B40431}[FY-BOT]{ffffff} - '..u8:decode(result['message']),-1)
- elseif result['action']=='error' then
- sampAddChatMessage('{ff0000}(FY-BOT) [ERROR] - {ffffff}'..u8:decode(result['text']), -1)
- elseif result['action']=='clicktxd' then
- sampSendClickTextdraw(result['id'])
- elseif result['action']=='ping' then
- client:send(encodeJson({action='pong'}))
- end
- end
- end
- end)
- end
- end
- end
- function sampev.onServerMessage(color,text)
- if text:find('Добро пожаловать на Diamond Role Play!') then
- _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
- user = sampGetPlayerNickname(my_id)
- auth_status.v = true
- elseif text:find('Администратор [A-Za-z_%d+]+%[%d+%]:') then
- lua_thread.create(function()
- local _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
- sendvkmessage('[FY-BOT] | '..sampGetPlayerNickname(my_id)..'<br>Пишет администратор: '..text)
- end)
- end
- end
- function sampev.onCreateObject(id,data)
- if status then
- if #objects == 0 then
- lua_thread.create(function()
- wait(1500)
- if #objects > 0 then
- _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
- user = sampGetPlayerNickname(my_id)
- local server,port = sampGetCurrentServerAddress()
- client:send(encodeJson({
- soft='fybot',
- action = 'validobject',
- password = password.v,
- user = tostring(user),
- server = tostring(server),
- txd = txd_panel,
- objects = objects
- }))
- objects={}
- end
- end)
- end
- local dist = getDistanceBetweenCoords3d(data.position.x ,data.position.y ,data.position.z ,getCharCoordinates(playerPed))
- if dist <= 6.6 and dist > 3 then
- table.insert(objects,{data.modelId,data.position.z})
- end
- end
- end
- function sampev.onShowDialog(id,style,title,button1,button2,text)
- if title:find('Статистика') and not auth then
- auth_status.v = true
- sampSendDialogResponse(id)
- return false
- end
- end
- function sampev.onShowTextDraw(id,data)
- if status then
- if data.position.y == 206 then
- txd_panel['start'] = id
- elseif data.position.x==549 then
- txd_panel['good'] = id
- elseif data.position.x == 599 then
- txd_panel['bad'] = id
- elseif data.text == 'START' then
- sampSendClickTextdraw(txd_panel['start'])
- l_start = true
- end
- end
- end
- function imgui.OnDrawFrame()
- if auth_status.v then imgui.ShowCursor = true end
- if auth_status.v then
- imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth/2,iScreenHeight/2), imgui.Cond.FirstUseEver,imgui.ImVec2(0.5, 0.5))
- imgui.SetNextWindowSize(imgui.ImVec2(200, 100), imgui.Cond.FirstUseEver)
- imgui.Begin(u8"FactoryBot | Auth",-1, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse+imgui.WindowFlags.NoTitleBar)
- imgui.CenterText(u8'Введите пароль')
- imgui.PushItemWidth(170)
- imgui.InputText('##password',password)
- imgui.PopItemWidth()
- imgui.NewLine()
- imgui.SameLine(45)
- if imgui.Button(u8'Войти',imgui.ImVec2(100, 25)) then
- mainIni.config.password = password.v
- inicfg.save(mainIni, directIni)
- lua_thread.create(function()
- _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
- user = sampGetPlayerNickname(my_id)
- local server,port = sampGetCurrentServerAddress()
- client:send(encodeJson({
- soft='fybot',
- action = 'auth',
- password = password.v,
- user = tostring(user),
- server = tostring(server)
- }))
- end)
- end
- imgui.End()
- end
- end
- function imgui.CenterText(text)
- imgui.SetCursorPosX((imgui.GetWindowSize().x/2) - (imgui.CalcTextSize(text).x / 2))
- imgui.Text(text)
- end
- function apply_custom_style()
- imgui.SwitchContext()
- local style = imgui.GetStyle()
- local colors = style.Colors
- local clr = imgui.Col
- local ImVec4 = imgui.ImVec4
- style.WindowPadding = imgui.ImVec2(15, 15)
- style.WindowRounding = 15.5
- style.FramePadding = imgui.ImVec2(5, 5)
- style.FrameRounding = 4.0
- style.ItemSpacing = imgui.ImVec2(12, 8)
- style.ItemInnerSpacing = imgui.ImVec2(8, 6)
- style.IndentSpacing = 25.0
- style.ScrollbarSize = 15.0
- style.ScrollbarRounding = 9.0
- style.GrabMinSize = 5.0
- style.GrabRounding = 3.0
- colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
- colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
- colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
- colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
- colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
- colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
- colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
- colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
- colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
- colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
- colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
- colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
- colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
- colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
- colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
- colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
- colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
- colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
- colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
- colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
- colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
- colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
- colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
- colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
- colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
- colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
- colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
- colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
- colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
- colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
- colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
- colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
- colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
- colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
- colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
- end
- apply_custom_style()
- function sendvkmessage(text)
- _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
- user = sampGetPlayerNickname(my_id)
- local result,code,err_msg = client:send(encodeJson({soft='fybot',
- action='vk',
- user=tostring(user),
- password = password.v,
- text=u8:encode(tostring(text))}))
- if not result then
- print('ERROR VK MESS: '..err_msg)
- end
- end
- function autoupdate(json_url, prefix, url)
- local dlstatus = require('moonloader').download_status
- local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
- if doesFileExist(json) then os.remove(json) end
- downloadUrlToFile(json_url, json,
- function(id, status, p1, p2)
- if status == dlstatus.STATUSEX_ENDDOWNLOAD then
- if doesFileExist(json) then
- local f = io.open(json, 'r')
- if f then
- local info = decodeJson(f:read('*a'))
- updatelink = info.updateurl
- updateversion = info.latest
- f:close()
- os.remove(json)
- print(updateversion)
- if updateversion ~= thisScript().version then
- lua_thread.create(function(prefix)
- local dlstatus = require('moonloader').download_status
- local color = -1
- wait(250)
- downloadUrlToFile(updatelink, thisScript().path,
- function(id3, status1, p13, p23)
- if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
- print(string.format('Загружено %d из %d.', p13, p23))
- elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
- print('Загрузка обновления завершена.')
- goupdatestatus = true
- lua_thread.create(function() wait(500) thisScript():reload() end)
- end
- if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
- if goupdatestatus == nil then
- update = false
- end
- end
- end
- )
- end, prefix
- )
- else
- update = false
- end
- end
- else
- print('v'..thisScript().version..': Не могу проверить обновление. Смиритесь или проверьте самостоятельно на '..url)
- update = false
- end
- end
- end
- )
- while update ~= false do wait(100) end
- end
Add Comment
Please, Sign In to add comment