I’m trying to make a script for my FiveM server that runs through my PHP script on my web server. It creates a JSON file on the web server but is there any way I can use just normal LUA to download the file to the FiveM resource on the server? I’ve tried regular LUA but it just throws an error. Any ideas?
Current Code that doesn’t work:
RegisterCommand("testcommand", function()
local http = require("socket.http")
local body, code = http.request("http://ryzenrp.cf/ryzenrp/banktransfers/test.json")
if not body then error(code) end
-- save the content to a file
local f = assert(io.open('test.json', 'wb')) -- open in "binary" mode
f:write(body)
f:close()
TriggerEvent("chatMessage", "SERVER", {255, 0, 0}, "Test Done")
end, false)