From f68d1259752030026e6ea5f430a6ff77ef976502 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Tue, 12 Sep 2023 18:40:44 +0500 Subject: [PATCH] Add babygod for dm and datatheft --- .../gamemodes/beatrun/gamemode/sv/spawn.lua | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/beatrun/gamemodes/beatrun/gamemode/sv/spawn.lua b/beatrun/gamemodes/beatrun/gamemode/sv/spawn.lua index cfa826b..6437d44 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sv/spawn.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sv/spawn.lua @@ -1,9 +1,45 @@ DEFINE_BASECLASS("gamemode_base") +-- successfully yonked from DarkRP, thanks <3 +function fp(tbl) + local func = tbl[1] + + return function(...) + local fnArgs = {} + local arg = {...} + local tblN = table.maxn(tbl) + + for i = 2, tblN do fnArgs[i - 1] = tbl[i] end + for i = 1, table.maxn(arg) do fnArgs[tblN + i - 1] = arg[i] end + + return func(unpack(fnArgs, 1, table.maxn(fnArgs))) + end +end + +local function disableBabyGod(ply) + if not IsValid(ply) or not ply.Babygod then return end + + ply.Babygod = nil + ply:GodDisable() +end + +local function enableBabyGod(ply) + timer.Remove(ply:EntIndex() .. "babygod") + + ply.Babygod = true + ply:GodEnable() + + timer.Create(ply:EntIndex() .. "babygod", 5, 1, fp({disableBabyGod, ply})) +end + function GM:PlayerSpawn(ply, transition) player_manager.SetPlayerClass(ply, "player_beatrun") ply:StripAmmo() BaseClass.PlayerSpawn(self, ply, transition) + + if GetGlobalBool("GM_DEATHMATCH") or GetGlobalBool("GM_DATATHEFT") then + enableBabyGod(ply) + end end \ No newline at end of file