diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties index 8b48a87..4e8283b 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/en/beatrun.properties @@ -83,6 +83,7 @@ beatrun.toolsmenu.courses.changeapikey=Change API Key beatrun.toolsmenu.courses.enterapikey=Enter your API key beatrun.toolsmenu.courses.savecourse=Save Currently Running Course to a File +beatrun.toolsmenu.courses.savesetspeed=Set speed beatrun.toolsmenu.courses.namesavecourse=Enter a name for your course beatrun.toolsmenu.courses.loadcourse=Load a Course from the Online Database diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/it/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/it/beatrun.properties index 320b654..275d9f1 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/it/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/it/beatrun.properties @@ -80,6 +80,7 @@ beatrun.toolsmenu.courses.changeapikey=Cambia API Key beatrun.toolsmenu.courses.enterapikey=Inserisci your API key beatrun.toolsmenu.courses.savecourse=Salva la corsa attualmente in esecuzione in un file +beatrun.toolsmenu.courses.savesetspeed=Set speed beatrun.toolsmenu.courses.namesavecourse=Inserisci un nome per la tua corsa beatrun.toolsmenu.courses.loadcourse=Carica una corsa dal Database Online diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/pl/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/pl/beatrun.properties index 1bba6a4..0b5b97a 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/pl/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/pl/beatrun.properties @@ -83,6 +83,7 @@ beatrun.toolsmenu.courses.changeapikey=Zmień klucz API beatrun.toolsmenu.courses.enterapikey=Wpisz swój klucz API beatrun.toolsmenu.courses.savecourse=Zapisz aktualnie biegnięty bieg do pliku +beatrun.toolsmenu.courses.savesetspeed=Set speed beatrun.toolsmenu.courses.namesavecourse=Wprowadź nazwę biegu beatrun.toolsmenu.courses.loadcourse=Załaduj bieg z internetowej bazy danych diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/pt-BR/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/pt-BR/beatrun.properties index 0953544..d45946d 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/pt-BR/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/pt-BR/beatrun.properties @@ -80,6 +80,7 @@ beatrun.toolsmenu.courses.changeapikey=Mudar chave API beatrun.toolsmenu.courses.enterapikey=Entre sua chave API beatrun.toolsmenu.courses.savecourse=Salvar o Percurso Atual para um Arquivo +beatrun.toolsmenu.courses.savesetspeed=Set speed beatrun.toolsmenu.courses.namesavecourse=Nomeie o seu Percurso beatrun.toolsmenu.courses.loadcourse=Carregar um Percurso da Database Online diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/ru/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/ru/beatrun.properties index d738f03..b520447 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/ru/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/ru/beatrun.properties @@ -83,6 +83,7 @@ beatrun.toolsmenu.courses.changeapikey=Изменить API Ключ beatrun.toolsmenu.courses.enterapikey=Введите ваш API ключ beatrun.toolsmenu.courses.savecourse=Сохранить Текущий Курс в Файл +beatrun.toolsmenu.courses.savesetspeed=Макс. скорость beatrun.toolsmenu.courses.namesavecourse=Введите название для курса beatrun.toolsmenu.courses.loadcourse=Загрузить Курс из Базы @@ -133,9 +134,9 @@ beatrun.toolsmenu.hud.floatxpcolor=Цвет Всплывающего XP в HUD beatrun.toolsmenu.camera.name=Камера beatrun.toolsmenu.camera.desc=Настройки камеры -beatrun.toolsmenu.camera.stabilization=Стабилизация Покачивания +beatrun.toolsmenu.camera.stabilization=Стабилизация покачивания beatrun.toolsmenu.camera.stabilizationdesc=Включите чтобы снизить покачивание камеры центрируя её -beatrun.toolsmenu.camera.intensity=Интенсивность Покачивания Камеры +beatrun.toolsmenu.camera.intensity=Интенсивность покачивания камеры beatrun.toolsmenu.camera.fov=Угол Обзора beatrun.toolsmenu.camera.fovdesc=Изменяет ваш Угол Обзора diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/tr/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/tr/beatrun.properties index 501d6ce..b312749 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/tr/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/tr/beatrun.properties @@ -80,6 +80,7 @@ beatrun.toolsmenu.courses.changeapikey=API Anahtarını Değiştir beatrun.toolsmenu.courses.enterapikey=API anahtarınızı girin beatrun.toolsmenu.courses.savecourse=Şu Anda Devam Eden Koşuyu Bir Dosyaya Kaydet +beatrun.toolsmenu.courses.savesetspeed=Set speed beatrun.toolsmenu.courses.namesavecourse=Koşunuz için bir ad girin beatrun.toolsmenu.courses.loadcourse=Çevrim içi Veritabandan Koşu Yükle diff --git a/beatrun/gamemodes/beatrun/content/resource/localization/uk/beatrun.properties b/beatrun/gamemodes/beatrun/content/resource/localization/uk/beatrun.properties index 13abfea..687e16c 100644 --- a/beatrun/gamemodes/beatrun/content/resource/localization/uk/beatrun.properties +++ b/beatrun/gamemodes/beatrun/content/resource/localization/uk/beatrun.properties @@ -81,6 +81,7 @@ beatrun.toolsmenu.courses.changeapikey=Змінити API Ключ beatrun.toolsmenu.courses.enterapikey=Введіть ваш API ключ beatrun.toolsmenu.courses.savecourse=Зберегти Поточний Курс у Файл +beatrun.toolsmenu.courses.savesetspeed=Макс. швидкість beatrun.toolsmenu.courses.namesavecourse=Введіть назву для курсу beatrun.toolsmenu.courses.loadcourse=Завантажити Курс з Бази diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua b/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua index ecd7e0d..4071d4d 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua @@ -228,7 +228,7 @@ local function BuildModeElements() local obsolete = Material("editor/obsolete") - for k, v in pairs(buildmode_ents) do + for k, _ in pairs(buildmode_ents) do local img = AEUI:AddImage(propspanel, buildmode_enticons[k] or obsolete, BMPropClick, 64 * row, 64 * col, 64, 64) img.prop = k img.hover = buildmode_entnames[k] or scripted_ents.GetMember(k, "PrintName") diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua b/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua index f2abf27..55ddf08 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/ToolMenuSettings.lua @@ -63,22 +63,36 @@ hook.Add("PopulateToolMenu", "Beatrun_ToolMenu", function() saveCourseButton.DoClick = function() local frame = vgui.Create("DFrame") frame:SetTitle("#beatrun.toolsmenu.courses.namesavecourse") - frame:SetSize(300, 100) + frame:SetSize(300, 110) frame:SetDeleteOnClose(true) frame:Center() frame:MakePopup() - local TextEntry = vgui.Create("DTextEntry", frame) - TextEntry:Dock(TOP) + local text = vgui.Create("DTextEntry", frame) + text:Dock(TOP) + + local checkbox = vgui.Create("DCheckBox", frame) + checkbox:SetPos(5, 55) + checkbox:SetValue(false) + + local slider = vgui.Create("DNumSlider", frame) + slider:SetText("#beatrun.toolsmenu.courses.savesetspeed") + slider:SetPos(25, 55) + slider:SetSize(280, 20) + slider:SetDecimals(0) + slider:SetMin(325) + slider:SetMax(1000) + slider:SetValue(325) local okButton = vgui.Create("DButton", frame) okButton:SetText("#beatrun.misc.ok") - okButton:SetPos(25, 60) - okButton:SetSize(250, 30) + okButton:SetPos(25, 80) + okButton:SetSize(250, 25) okButton.DoClick = function() - local name = string.Replace(TextEntry:GetValue(), " ", "_") + local name = string.Replace(text:GetValue(), " ", "_") + local speed = tostring(slider:GetValue()) - RunConsoleCommand("Beatrun_SaveCourse", name) + RunConsoleCommand("Beatrun_SaveCourse", name, checkbox:GetChecked() and speed or 0) frame:Close() end end diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua index 8497a50..4b3ce8d 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua @@ -336,6 +336,7 @@ if SERVER then net.WriteFloat(Course_StartAng) net.WriteString(Course_Name) net.WriteString(Course_ID) + net.WriteInt(Course_Speed, 11) net.Broadcast() end @@ -344,6 +345,11 @@ if SERVER then Course_Name = "" Course_ID = "" + Course_Speed = 0 + + for _, plr in ipairs(player.GetAll()) do + plr:ConCommand("Beatrun_SpeedLimit 325") + end game.CleanUpMap() Course_Sync() @@ -572,6 +578,8 @@ if SERVER then local data = util.Decompress(net.ReadData(len)) + if not data then return print("[BR] Error while loading a course") end + Beatrun_ReadCourse(data) end @@ -579,29 +587,21 @@ if SERVER then local dir = "beatrun/courses/" .. string.Replace(game.GetMap(), " ", "-") .. "/" local save = file.Read(dir .. id .. ".txt", "DATA") - if not save then - print("NON-EXISTENT SAVE", id) - - return - end + if not save then return print("[BR] Non-existent save with id: " .. tostring(id)) end Course_ID = id - Beatrun_ReadCourse(save) + + Beatrun_ReadCourse(save, id) end - function Beatrun_ReadCourse(data) + function Beatrun_ReadCourse(data, id) game.CleanUpMap() - local a = util.Decompress(data) or data - local id = util.CRC(a) - local data = util.JSONToTable(a) + local decompress = util.Decompress(data) or data + id = id or util.CRC(decompress) + local courseData = util.JSONToTable(decompress) - local props = data[1] - local cp = data[2] - local pos = data[3] - local ang = data[4] - local name = data[5] - local entities = data[6] + local props, cp, pos, ang, name, entities, speed = unpack(courseData) for _, v in pairs(props) do local a = ents.Create("prop_physics") @@ -665,10 +665,15 @@ if SERVER then Course_StartAng = ang Course_Name = name Course_ID = id + Course_Speed = speed Course_Sync() for _, v in pairs(player.GetAll()) do + if Course_Speed and Course_Speed ~= 0 then + v:ConCommand("Beatrun_SpeedLimit " .. tostring(Course_Speed)) + end + v:SetNW2Float("PBTime", 0) v:SetNW2Int("CPNum", 1) v:SetMoveType(MOVETYPE_WALK) @@ -897,21 +902,23 @@ if CLIENT then playerstart:DrawModel() end - function CourseData(name) - local save = {{}, {}, Course_StartPos, Course_StartAng, name or os.date("%H:%M:%S - %d/%m/%Y", os.time()), {}} + function CourseData(name, speed) + -- [1] = Props, [2] = Checkpoints, [3] = Starting pos, [4] = Starting ang, [5] = Name, [6] = Entities, [7] = Restricted player's speed (0 = unrestricted) + local save = {{}, {}, Course_StartPos, Course_StartAng, name or os.date("%H:%M:%S - %d/%m/%Y", os.time()), {}, speed or 0} for _, v in pairs(buildmode_placed) do if not IsValid(v) then continue end if v:GetNW2Bool("BRProtected") then - print("ignoring protected ent") + print("[BR] Ignoring protected ent") else local class = v:GetClass() if class == "prop_physics" then local hr = false + if v:GetMaterial() == "medge/redplainplastervertex" then hr = true end - //if v.buildmode_placed_manually then hr = false end + -- if v.buildmode_placed_manually then hr = false end table.insert(save[1], { model = v:GetModel():lower(), @@ -940,21 +947,15 @@ if CLIENT then return save end - function SaveCourse(name, compress) - local save = CourseData(name) + function SaveCourse(name, speed) + local save = CourseData(name, speed) local jsonsave = util.TableToJSON(save) local id = util.CRC(jsonsave) local dir = "beatrun/courses/" .. string.Replace(game.GetMap(), " ", "-") .. "/" - if compress == nil then compress = true end - file.CreateDir(dir) - if compress then - file.Write(dir .. id .. ".txt", util.Compress(jsonsave)) - else - file.Write(dir .. id .. ".txt", jsonsave) - end + file.Write(dir .. id .. ".txt", util.Compress(jsonsave)) print("Save created: " .. id .. ".txt") end @@ -962,7 +963,7 @@ if CLIENT then concommand.Add("Beatrun_SaveCourse", function(ply, cmd, args, argstr) local name = args[1] or os.date("%H:%M:%S - %d/%m/%Y", os.time()) - SaveCourse(name, tobool(args[2])) + SaveCourse(name, args[2] or 0) end) function LoadCourse(id) @@ -1032,12 +1033,14 @@ if CLIENT then local ang = net.ReadFloat() local name = net.ReadString() local id = net.ReadString() + local speed = net.ReadInt(11) Course_StartPos:SetUnpacked(x, y, z) Course_StartAng = ang Course_Name = name Course_ID = id or Course_ID + Course_Speed = speed end) buildmodeinputs = { @@ -1319,7 +1322,7 @@ if CLIENT then end if BuildModeIndex == 0 then - local svec = gui.ScreenToVector(gui.MouseX(), gui.MouseY()) //util.AimVector(LocalPlayer():EyeAngles(), 133, mousex, mousey, ScrW(), ScrH()) + local svec = gui.ScreenToVector(gui.MouseX(), gui.MouseY()) -- util.AimVector(LocalPlayer():EyeAngles(), 133, mousex, mousey, ScrW(), ScrH()) svec:Mul(100000) local start = LocalPlayer():EyePos() diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua index 4f2dd84..565e8b5 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua @@ -6,6 +6,7 @@ Course_GoTime = 0 Course_EndTime = 0 Course_ID = Course_ID or "" Course_Name = Course_Name or "" +Course_Speed = Course_Speed or 0 local cptimes = {} local lastcptime = 0 local pbtimes = nil diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/MP_Sync.lua b/beatrun/gamemodes/beatrun/gamemode/sh/MP_Sync.lua index 843b3d5..7295383 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/MP_Sync.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/MP_Sync.lua @@ -17,6 +17,7 @@ if SERVER then net.WriteFloat(Course_StartAng) net.WriteString(Course_Name) net.WriteString(Course_ID) + net.WriteInt(Course_Speed, 11) net.Send(ply) ply.Synced = true diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Sliding.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Sliding.lua index 36a4295..e49b1b2 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Sliding.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Sliding.lua @@ -522,7 +522,7 @@ hook.Add("SetupMove", "qslide", function(ply, mv, cmd) if not slippery and pos.z > ply:GetSlidingLastPos().z + 1 then ply:SetSlidingTime(ply:GetSlidingTime() - 0.025) elseif slippery or slidedelta < 1 and pos.z < ply:GetSlidingLastPos().z - 0.25 then - ply:SetSlidingTime(CT + slidetime) --[[ GetConVar("Beatrun_SpeedLimit"):GetInt() ]] + ply:SetSlidingTime(CT + slidetime) --[[ GetConVar("Beatrun_SpeedLimit"):GetInt() ]] ply:SetSlidingVel(math.min(mv:GetVelocity():Length() * 0.865, 450 * ply:GetOverdriveMult())) end