mirror of
https://github.com/kythre/Buildmode-ULX.git
synced 2025-03-04 03:03:04 -05:00
Added spawn protection. quick and dirty. probably needs refined. #27
This commit is contained in:
parent
d1dfceb5be
commit
03ebaabc4c
@ -331,6 +331,11 @@ local function _kyle_Buildmode_Enable(z)
|
||||
end
|
||||
|
||||
local function _kyle_Buildmode_Disable(z)
|
||||
local timername = "_Kyle_Buildmode_spawnprotection_" .. z:GetName()
|
||||
if timer.Exists(timername) then
|
||||
timer.Destroy(timername)
|
||||
end
|
||||
|
||||
z.buildmode = false
|
||||
|
||||
--second buildmode variable for halos and status text on hover
|
||||
@ -475,6 +480,26 @@ hook.Add("PlayerSpawn", "kyleBuildmodePlayerSpawn", function(z)
|
||||
--z:GetNWBool("_kyle_died") makes sure that the player is spawning after an actual death and not the ulib respawn function
|
||||
if ((_Kyle_Buildmode["spawnwithbuildmode"]=="1" and not z:GetNWBool("_Kyle_pvpoverride")) or z:GetNWBool("_Kyle_Buildmode")) and z:GetNWBool("_kyle_died") then
|
||||
_kyle_Buildmode_Enable(z)
|
||||
elseif (not z:GetNWBool("_Kyle_Buildmode")) and z:GetNWBool("_kyle_died") then
|
||||
if tonumber(_Kyle_Buildmode["spawnprotection"])>0 then
|
||||
z:SendLua("GAMEMODE:AddNotify(\"".._Kyle_Buildmode["spawnprotection"].." seconds of Spawn Protection enabled. Type !pvp to disable\",NOTIFY_GENERIC, 5)")
|
||||
z.buildmode = true
|
||||
z:SetNWBool("_Kyle_Buildmode", true)
|
||||
local timername = "_Kyle_Buildmode_spawnprotection_" .. z:GetName()
|
||||
if timer.Exists(timername) then
|
||||
timer.Destroy(timername)
|
||||
end
|
||||
timer.Create(timername, _Kyle_Buildmode["spawnprotection"], 1, function()
|
||||
z:SetNWBool("_Kyle_Buildmode", false)
|
||||
z.buildmode = false
|
||||
if _Kyle_Buildmode["restrictweapons"]=="1" then
|
||||
z:ConCommand("kylebuildmode defaultloadout")
|
||||
end
|
||||
z:SendLua("GAMEMODE:AddNotify(\"Spawn protection ended\",NOTIFY_GENERIC, 5)")
|
||||
end)
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
z:SetNWBool("_kyle_died", false)
|
||||
|
||||
@ -488,6 +513,12 @@ end )
|
||||
|
||||
hook.Add("PostPlayerDeath", "kyleBuildmodePostPlayerDeath", function(z)
|
||||
z:SetNWBool("_kyle_died", true)
|
||||
local timername = "_Kyle_Buildmode_spawnprotection_" .. z:GetName()
|
||||
if timer.Exists(timername) then
|
||||
z:SetNWBool("_Kyle_Buildmode", false)
|
||||
z.buildmode = false
|
||||
timer.Destroy(timername)
|
||||
end
|
||||
end, HOOK_HIGH )
|
||||
|
||||
hook.Add("PlayerGiveSWEP", "kylebuildmoderestrictswep", function(y, z)
|
||||
@ -508,7 +539,7 @@ end)
|
||||
|
||||
hook.Add("PlayerCanPickupWeapon", "kylebuildmoderestrictswep", function(y, z)
|
||||
if not _kyle_builder_spawn_weapon(y, string.Split(string.Split(tostring(z),"][", true)[2],"]", true)[1]) then
|
||||
return false
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -17,6 +17,7 @@ xgui.addSVModule( "kylebuildmode_load", function()
|
||||
xgui.addDataType( "_Kyle_Buildmode", function() end, "kylebuildmodesettings", 0, -10 )
|
||||
|
||||
--Load defaults in to settings table
|
||||
_Kyle_Buildmode["spawnprotection"] = 0
|
||||
_Kyle_Buildmode["restrictweapons"] = 0
|
||||
_Kyle_Buildmode["restrictsents"] = 0
|
||||
_Kyle_Buildmode["restrictvehicles"] = 0
|
||||
@ -37,7 +38,6 @@ xgui.addSVModule( "kylebuildmode_load", function()
|
||||
_Kyle_Buildmode["weaponlistmode"] = 0
|
||||
_Kyle_Buildmode["entitylistmode"] = 1
|
||||
_Kyle_Buildmode["vehiclelistmode"] = 1
|
||||
_Kyle_Buildmode["test"] = 1
|
||||
_Kyle_Buildmode["highlightbuilderscolor"]= "0,128,255"
|
||||
_Kyle_Buildmode["highlightpvperscolor"]= "255,0,0"
|
||||
_Kyle_Buildmode["builddelay"] = 0
|
||||
|
@ -15,6 +15,16 @@ number_buildmodedelay.OnValueChanged = function(y, z)
|
||||
RunConsoleCommand("kylebuildmode", "set", "builddelay", z)
|
||||
end
|
||||
end
|
||||
local number_spawnprotection = xlib.makenumberwang {x=5, y=70, w=35, parent=panel_entering }
|
||||
local label_spawnprotection = xlib.makelabel{ x=number_spawnprotection.x+40, y=number_spawnprotection.y+2, w=500, h=15, parent=panel_entering, label="Spawn Protection" }
|
||||
number_spawnprotection.OnValueChanged = function(y, z)
|
||||
if _Kyle_Buildmode["spawnprotection"] != z then
|
||||
RunConsoleCommand("kylebuildmode", "set", "spawnprotection", z)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--"While IN Buildmdode" Panel
|
||||
local panel_whilein = xlib.makepanel{ x=160, y=5, w=425, h=322, parent=b}
|
||||
local check_restrictweapons = xlib.makecheckbox{ x=5, y=5, label="Restrict weapons with 'Builder Weapons'", parent=panel_whilein, repconvar="rep_kylebuildmode_restrictweapons"}
|
||||
|
Loading…
Reference in New Issue
Block a user