mirror of
https://github.com/JonnyBro/beatrun.git
synced 2024-12-29 05:13:02 +05:00
getting ready for new courses database update
This commit is contained in:
parent
0e362a4b41
commit
233204feae
1 changed files with 20 additions and 6 deletions
|
@ -1,6 +1,21 @@
|
|||
local apikey = CreateClientConVar("Beatrun_Apikey", "0", true, false, "API key")
|
||||
local domain = CreateClientConVar("Beatrun_Domain", "courses.beatrun.ru", true, false, "Online courses domain")
|
||||
|
||||
local function GetCurrentMapWorkshopID()
|
||||
for _, addon in pairs(engine.GetAddons()) do
|
||||
if not addon or not addon.title or not addon.wsid or not addon.mounted or not addon.downloaded then continue end
|
||||
|
||||
_, addon_folders = file.Find("*", addon.title)
|
||||
|
||||
for _, dir in ipairs(addon_folders) do
|
||||
if dir ~= "maps" then continue end
|
||||
if file.Exists("maps/" .. game.GetMap() .. ".bsp", addon.title) then return addon.wsid end
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function UploadCourse()
|
||||
if Course_Name == "" or Course_ID == "" then return print("Can't upload in Freeplay") end
|
||||
|
||||
|
@ -11,16 +26,15 @@ function UploadCourse()
|
|||
http.Post(url, {
|
||||
key = apikey:GetString(),
|
||||
map = string.Replace(game.GetMap(), " ", "-"),
|
||||
course_data = util.Base64Encode(filedata, true)
|
||||
},
|
||||
function(body, length, headers, code) -- onSuccess function
|
||||
course_data = util.Base64Encode(filedata, true),
|
||||
mapid = GetCurrentMapWorkshopID()
|
||||
}, function(body, length, headers, code) -- onSuccess function
|
||||
if code == 200 then
|
||||
print("Response: " .. body)
|
||||
else
|
||||
print("Error (" .. code .. "): " .. body)
|
||||
end
|
||||
end,
|
||||
function(message) -- onFailure function
|
||||
end, function(message) -- onFailure function
|
||||
print("Unexpected error: " .. message)
|
||||
end)
|
||||
end
|
||||
|
@ -94,6 +108,6 @@ function UpdateCourse(course_code)
|
|||
end)
|
||||
end
|
||||
|
||||
concommand.Add("Beatrun_UpdateCourse", function(ply, cmd, args, argstr)
|
||||
concommand.Add("Beatrun_UpdateCode", function(ply, cmd, args, argstr)
|
||||
UpdateCourse(args[1])
|
||||
end)
|
Loading…
Reference in a new issue