This commit is contained in:
Jonny_Bro (Nikita) 2023-08-29 17:36:57 +05:00
parent 8afb6853dd
commit 55de9fc0fa

View file

@ -3,6 +3,7 @@ local domain = CreateClientConVar("Beatrun_Domain", "courses.beatrun.ru", true,
function UploadCourse() function UploadCourse()
if Course_Name == "" or Course_ID == "" then return print("Can't upload in Freeplay") end if Course_Name == "" or Course_ID == "" then return print("Can't upload in Freeplay") end
local url = domain:GetString() .. "/upload.php" local url = domain:GetString() .. "/upload.php"
local data = file.Open("beatrun/courses/" .. game.GetMap() .. "/" .. Course_ID .. ".txt", "rb", "DATA") local data = file.Open("beatrun/courses/" .. game.GetMap() .. "/" .. Course_ID .. ".txt", "rb", "DATA")
local filedata = util.Decompress(data:Read(data:Size())) local filedata = util.Decompress(data:Read(data:Size()))
@ -72,6 +73,7 @@ end)
function UpdateCourse(course_code) function UpdateCourse(course_code)
if Course_Name == "" or Course_ID == "" then return print("Can't upload in Freeplay") end if Course_Name == "" or Course_ID == "" then return print("Can't upload in Freeplay") end
local url = domain:GetString() .. "/updatecourse.php" local url = domain:GetString() .. "/updatecourse.php"
local data = file.Open("beatrun/courses/" .. game.GetMap() .. "/" .. Course_ID .. ".txt", "rb", "DATA") local data = file.Open("beatrun/courses/" .. game.GetMap() .. "/" .. Course_ID .. ".txt", "rb", "DATA")
local filedata = util.Decompress(data:Read(data:Size())) local filedata = util.Decompress(data:Read(data:Size()))
@ -81,15 +83,13 @@ function UpdateCourse(course_code)
map = string.Replace(game.GetMap(), " ", "-"), map = string.Replace(game.GetMap(), " ", "-"),
course_data = util.Base64Encode(filedata, true), course_data = util.Base64Encode(filedata, true),
code = course_code code = course_code
}, }, function(body, length, headers, code) -- onSuccess function
function(body, length, headers, code) -- onSuccess function
if code == 200 then if code == 200 then
print("Response: " .. body) print("Response: " .. body)
else else
print("Error (" .. code .. "): " .. body) print("Error (" .. code .. "): " .. body)
end end
end, end, function(message) -- onFailure function
function(message) -- onFailure function
print("Unexpected error: " .. message) print("Unexpected error: " .. message)
end) end)
end end