-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKillOnSight.lua
More file actions
125 lines (102 loc) · 3.13 KB
/
KillOnSight.lua
File metadata and controls
125 lines (102 loc) · 3.13 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
--[==[
EasternBloxxer, 8ch_32bit
Astra Defense Network
TODO: notify only onduty users of that specific subgroup and the user itself (Would require a onduty playerfinder)
Place this in a ModuleScript under Adonis_Loader > Config > Plugins and named "Server-KillOnSight"
--]==]
return function(Vargs)
local server = Vargs.Server
local service = Vargs.Service
local Core = server.Core
local Admin = server.Admin
local Process = server.Process
local Settings = server.Settings
local Functions = server.Functions
local Commands = server.Commands
local Remote = server.Remote
local Deps = server.Deps
local Logs = server.Logs
local Variables = server.Variables
local Functions = server.Functions
local koslist = {
TMS = {};
PBST = {};
PET = {};
}
local methods = {
add = function(p:Player,name:string,list,group)
assert(name,"The username is required when adding a KOS!")
if table.find(list,name) then
return error('Player is already on KOS!')
end
table.insert(list,name)
Functions.Hint(`{name} is now on {group} KOS!`, service.GetPlayers())
end,
remove = function(p:Player,name:string,list)
assert(name,"The username is required when removing a KOS!")
if not table.find(list,name) then
return error('Player is not on KOS!')
end
table.remove(list,list[name])
end,
clear = function(p:Player, name:string, list)
table.clear(list)
end,
open = function(p:Player,list,group,AutoUpdate)
Remote.MakeGui(p, "List", {
Title = `{group} KOS`;
TextSelectable = true;
AutoUpdate = AutoUpdate;
Tab = Logs.ListUpdaters[`view{string.lower(group)}kos`]();
Update = `view{string.lower(group)}kos`;
})
end,
}
for name, list in pairs(koslist) do
local Name = `{name}kos`;
server.Commands[Name] = {
Prefix = server.Settings.Prefix;
Commands = {string.lower(Name)};
Args = {"method", "optional argument"};
Description = "Manages a KOS";
Hidden = false;
Fun = false;
AdminLevel = "Mods"; --TODO: Custom permission checks for commands such as group ranks
Function = function(plr,args)
local method = string.lower(assert(args[1], "Method argument missing!"));
local arg = args[2];
local Method = assert(methods[method], "Invalid method! Valid methods: add/remove/clear")
Method(plr, arg, list, name);
end
}
server.Commands[`view{string.lower(Name)}`] = {
Prefix = server.Settings.PlayerPrefix;
Commands = {string.lower(`view{Name}`)};
Args = {"autoupdate"};
Description = "View a KOS";
Hidden = false;
Fun = false;
AdminLevel = "Players";
ListUpdater = function(plr: Player, selection: string?)
local tab = {
{
Text = `{#list} player(s) on {name} KOS`;
},
{
Text = `―――――――――――――――――――――――`;
}
}
for _, v: Player in list do
table.insert(tab, {
Text = v;
})
end
return tab
end;
Function = function(plr,args)
local AutoUpdate = if args[1] and (args[1]:lower() == "true" or args[1]:lower() == "yes") then 1 else nil;
methods["open"](plr,list,name,AutoUpdate)
end
}
end
end