Пытаюсь отправить запрос через mimgui: в консоле пишет [ML] (script) test.lua: Lua_State = 0x01fd01c0 !
а callback вызывается только при выгрузке скрипта
local httplib = require('HTTP_ASYNC')
local imgui = require("mimgui")
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
function main()
while true do wait(1000)
httplib.http_async_process_callbacks()
end
end
function onScriptTerminate(LuaScript, quitGame)
if LuaScript == thisScript() then
httplib.http_async_cleanup()
end
end
local success = nil
imgui.OnFrame(function() return not isPauseMenuActive() and not sampIsScoreboardOpen() end, function(self)
imgui.Begin("her", nil, imgui.WindowFlags.AlwaysAutoResize)
if imgui.Button("sumbit") then
success = nil
httplib.http_async_request("https://www.blast.hk/threads/234784/", function(response)
print(response)
if response.error then
success = false
print(response.error)
else
print("ААААААААААААААААХУЙ", response.status)
success = true
end
end, {
method = "GET",
timeout = 5
})
end
imgui.Text(success == nil and "wait" or (success and "success" or "not success"))
imgui.End()
end)
Не получается скачать jpg, видимо с бинарными файлами работать не получится
local http = require('HTTP_ASYNC')
function main()
http.http_async_request("https://lea-script.tech/avatars/avatar_24_1749997478600.jpg", function(response)
if response.error then
print(response.error)
else
print("ААААААААААААААААХУЙ", response.status, response.data.raw)
local f = io.open('moonloader/picture.jpg', "wb")
if f then
print('записан')
f:write(response.data.raw)
f:close()
end
end
end, {
method = "GET",
timeout = 5,
verify_ssl = false
})
while true do wait(0)
http.http_async_process_callbacks()
end
end
function onScriptTerminate(LuaScript, quitGame)
if LuaScript == thisScript() then
http.http_async_cleanup()
end
end
Не помешало бы добавить headers в response
Json парсер такой себе: добавляет в каждой таблице ключ is_json
Он тут не так уж и необходим, когда в мунлоадере есть decodeJson
Похоже парсер json экранирует "\" из-за чего не работает перенос строки \n