-
Notifications
You must be signed in to change notification settings - Fork 61
/
doorextensions.lua
145 lines (120 loc) · 4.28 KB
/
doorextensions.lua
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
PLUGIN.name = "Door Extensions"
PLUGIN.author = "Zoephix"
PLUGIN.description = "A extension for the doors plugin, adding easy commands that target every door."
PLUGIN.license = [[
Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
© Copyright 2020 by Zoephix
This plugin is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/]]
ix.lang.AddTable("english", {
cmdDoorsSetUnownable = "Makes every door unownable.",
cmdDoorsSetOwnable = "Makes every door ownable.",
cmdDoorsSetDisabled = "Disallows any commands to be ran on every door.",
cmdDoorsSetHidden = "Hides the description of every door, but still allows it to be ownable.",
})
ix.lang.AddTable("dutch", {
cmdDoorsSetUnownable = "Maakt elke deur onkoopbaar.",
cmdDoorsSetOwnable = "Maakt elke deur koopbaar.",
cmdDoorsSetDisabled = "Staat niet toe dat opdrachten op elke deur worden uitgevoerd.",
cmdDoorsSetHidden = "Verbergt de beschrijving van elke deur, maar laat deze toch koopbaar zijn.",
})
local PLUGIN = PLUGIN
function PLUGIN:InitializedPlugins()
local doorPlugin = ix.plugin.Get("doors")
if (!doorPlugin) then return end
ix.command.Add("DoorSetUnownableAll", {
description = "@cmdDoorsSetUnownable",
privilege = "Manage Doors",
adminOnly = true,
arguments = ix.type.text,
OnRun = function(self, client, arguments)
-- Get every door entity
for _, entity in pairs(ents.GetAll()) do
-- Validate it is a door.
if (IsValid(entity) and entity:IsDoor() and !entity:GetNetVar("disabled")) then
-- Set it so it is unownable.
entity:SetNetVar("ownable", nil)
doorPlugin:CallOnDoorChildren(entity, function(child)
child:SetNetVar("ownable", nil)
end)
doorPlugin:SaveDoorData()
end
end
-- Tell the player they have made the doors unownable.
return ix.util.Notify("You have made every door unownable.", client)
end
})
ix.command.Add("DoorSetOwnableAll", {
description = "@cmdDoorsSetOwnable",
privilege = "Manage Doors",
adminOnly = true,
arguments = ix.type.text,
OnRun = function(self, client, arguments)
-- Get every door entity
for _, entity in pairs(ents.GetAll()) do
-- Validate it is a door.
if (IsValid(entity) and entity:IsDoor() and !entity:GetNetVar("disabled")) then
-- Set it so it is ownable.
entity:SetNetVar("ownable", true)
doorPlugin:CallOnDoorChildren(entity, function(child)
child:SetNetVar("ownable", true)
end)
doorPlugin:SaveDoorData()
end
end
-- Tell the player they have made the doors ownable.
return ix.util.Notify("You have made every door ownable.", client)
end
})
ix.command.Add("DoorSetDisabledAll", {
description = "@cmdDoorsSetDisabled",
privilege = "Manage Doors",
adminOnly = true,
arguments = ix.type.bool,
OnRun = function(self, client, bDisabled)
-- Get every door entity
for _, entity in pairs(ents.GetAll()) do
-- Validate it is a door.
if (IsValid(entity) and entity:IsDoor()) then
-- Set it so it is ownable.
entity:SetNetVar("disabled", bDisabled)
doorPlugin:CallOnDoorChildren(entity, function(child)
child:SetNetVar("disabled", bDisabled)
end)
doorPlugin:SaveDoorData()
end
end
-- Tell the player they have made the doors (un)disabled.
if (bDisabled) then
return ix.util.Notify("You have disabled every door.", client)
else
return ix.util.Notify("You have undisabled every door.", client)
end
end
})
ix.command.Add("DoorSetHiddenAll", {
description = "@cmdDoorsSetHidden",
privilege = "Manage Doors",
adminOnly = true,
arguments = ix.type.bool,
OnRun = function(self, client, bHidden)
-- Get every door entity
for _, entity in pairs(ents.GetAll()) do
-- Validate it is a door.
if (IsValid(entity) and entity:IsDoor()) then
entity:SetNetVar("visible", !bHidden)
doorPlugin:CallOnDoorChildren(entity, function(child)
child:SetNetVar("visible", !bHidden)
end)
doorPlugin:SaveDoorData()
end
end
-- Tell the player they have made the doors (un)hidden.
if (bHidden) then
return ix.util.Notify("You have made every door hidden.", client)
else
return ix.util.Notify("You have made every door no longer hidden.", client)
end
end
})
end