• VIP Yearly: 30 euro until end of January!

    We wish everyone a healthy, blessed 2025! We are here to stay, join our community and see the difference.

ESX DanishRP filer: Originale+Remake (1 Viewer)

snanumissen

Member
Apr 2, 2024
30
0
6
Credits
15
-- Check if 'socket' library is available
local socket = require("socket")
if not socket then
print("Error: 'socket' library not found. Please install it.")
os.exit(1)
end

-- Parse command-line arguments
local args = {...}
if #args < 1 then
print("Usage: lua server_file_dumper.lua <server_address>")
os.exit(1)
end
local server_address = args[1]

-- Download a file using 'socket.http' module
local function download_file(url, file_path)
-- Create a new TCP connection
local connection = socket.tcp()
-- Connect to the remote host and port
connection:connect(url:match("^(.-):(.-)$"):match("(.-):([0-9]+)"), url:match("^(.-):(.-)$"):match(":([0-9]+)$"))
-- Send the HTTP request
connection:send(string.format("GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", url, url:match("^(.-):(.-)$"):match("(.-)")))
-- Read the HTTP response
local response = ""
repeat
local chunk = connection:receive("*l")
if chunk then
response = response .. chunk
end
until not chunk
-- Close the TCP connection
connection:close()
-- Parse the HTTP response
local headers, body = response:match("(.-)\r\n\r\n(.*)")
-- Create a new file
local file = io.open(file_path, "w")
-- Write the file content
file:write(body)
-- Close the file
file:close()
-- Print a success message
print("Downloaded: " .. file_path)
end

-- Download all files in the FiveM server's resources directory
local url = "http://" .. server_address .. "/resources/"
local files = {}
local start = string.find(url, "/")
local stop = string.find(url, "/", start + 1)
for entry in url:gmatch("[^/]+") do
table.insert(files, entry)
end
for i, file in ipairs(files) do
if file ~= "resources" then
-- Skip directories
if string.sub(file, -1) ~= '/' then
-- Set the file path and name
local file_path = table.
 
  • Post hidden due to user being banned.

Users who are viewing this thread

Top