This repository was archived by the owner on Mar 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnpcspawner2_cl.lua
More file actions
146 lines (124 loc) · 3.39 KB
/
npcspawner2_cl.lua
File metadata and controls
146 lines (124 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
--[[
NPC Spawn Platforms - lua/autorun/client/npcspawner2_cl.lua
Copyright 2009-2017 Lex Robinson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]] --
local cvarstr = "npcspawner_config_"
local function cvar(id)
return cvarstr .. id
end
local function callback(cvar, old, new)
local name = cvar:gsub(cvarstr, "")
local value = tonumber(new)
if (not value or value == npcspawner.config[name]) then
return
end
RunConsoleCommand("npcspawner_config", name, value)
end
for name, default in pairs(npcspawner.config) do
name = cvar(name)
CreateConVar(name, tostring(default))
cvars.AddChangeCallback(name, callback)
end
npcspawner.recieve(
"NPCSpawner Config", function(data)
npcspawner.config = data
npcspawner.debug("Just got new config vars.")
for name, value in pairs(npcspawner.config) do
RunConsoleCommand(cvar(name), tostring(value))
end
end
)
-----------------------------------
-- Lexical Patented Corpse Eater --
-----------------------------------
CreateConVar("cleanupcorpses", 1)
timer.Create(
"Dead Body Deleter", 60, 0, function()
if (GetConVarNumber("cleanupcorpses") < 1) then
return
end
for _, ent in pairs(ents.FindByClass("class C_ClientRagdoll")) do
ent:Remove()
end
end
)
local function lang(id)
return "#utilities.spawnplatform." .. id
end
local function clientOptions(panel)
panel:AddControl(
"CheckBox",
{Label = lang("cleanupcorpses"), Help = true, Command = "cleanupcorpses"}
)
end
local function adminOptions(panel)
panel:AddControl(
"CheckBox",
{Label = lang("adminonly"), Command = cvar("adminonly"), Help = true}
)
panel:AddControl(
"CheckBox",
{Label = lang("callhooks"), Command = cvar("callhooks"), Help = true}
)
panel:AddControl(
"Slider", {
Label = lang("maxinplay"),
Command = cvar("maxinplay"),
Help = true,
Type = "Int",
Min = "1",
Max = "50",
}
)
panel:AddControl(
"Slider", {
Label = lang("mindelay"),
Command = cvar("mindelay"),
Help = true,
Type = "Float",
Min = "0.1",
Max = "10",
}
)
panel:AddControl(
"CheckBox", {Label = lang("cami"), Command = cvar("cami"), Help = true}
)
local dzpanel = panel:AddControl(
"ControlPanel", {Label = lang("dangerzone"), Closed = true}
)
dzpanel:AddControl(
"CheckBox", {Label = lang("sanity"), Command = cvar("sanity"), Help = true}
)
dzpanel:AddControl(
"CheckBox",
{Label = lang("rehydrate"), Command = cvar("rehydrate"), Help = true}
)
--[[
dzpanel:AddControl("CheckBox", {
Label = lang("debug"),
Command = cvar("debug"),
Help = true,
})
]] --
end
hook.Add(
"PopulateToolMenu", "NPCSpawner Options", function()
spawnmenu.AddToolMenuOption(
"Utilities", "User", "NPC Spawn Platforms User",
"#spawnmenu.utilities.spawnplatform", "", "", clientOptions
)
spawnmenu.AddToolMenuOption(
"Utilities", "Admin", "NPC Spawn Platforms Admin",
"#spawnmenu.utilities.spawnplatform", "", "", adminOptions
)
end
)