-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathamtk.lua
144 lines (108 loc) · 3.44 KB
/
amtk.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
local util = require("util")
local response = require("response")
local cfg = require("config")
release = "2.0.0"
function onInit()
print("\n")
print("AMTKit " .. release .. " Loaded")
MP.RegisterEvent("onPlayerAuth", "onPlayerAuth")
MP.RegisterEvent("onChatMessage", "onChatMessage")
MP.RegisterEvent("onVehicleSpawn", "onVehicleSpawn")
util.initList()
beamcfg = util.readConfig()
print("AMTKit: All systems go!")
end
function onPlayerAuth(name, role, isGuest)
local playersCurrent = MP.GetPlayerCount()
local name = util.parseName(name)
if isGuest and not cfg.allowGuests then
return "You must be signed in to join this server!"
end
if cfg.staffSlot then
if playersCurrent == (beamcfg.playerLimit - 1) and not string.match(util.readAuthFile(), name) then
return "The server is full. Last slot is reserved for staff."
end
end
print("AMTKit: Checking player blacklist for " .. name)
if string.match(util.readBanFile(), name) then
return "You have been banned from the server."
else
print("AMTKit: All good, user clear to join.")
end
end
function onVehicleSpawn(playerID)
local playerVehicles = MP.GetPlayerVehicles(playerID)
local playerCarCount = 0
if playerVehicles then
for _ in pairs(playerVehicles) do playerCarCount = playerCarCount + 1 end
end
-- + 1 to account for unicycle
-- Attempted fix for unicycle spam bug:
if (playerCarCount + 1) > beamcfg.carLimit + 1 then
MP.DropPlayer(playerID)
MP.SendChatMessage(-1, "Player " .. MP.GetPlayerName(playerID) .. " was kicked for spawning more than " .. beamcfg.carLimit + 1 .. " cars.")
print("AMTKit: Player " .. MP.GetPlayerName(playerID) .. " was kicked for spawning too many cars.")
end
end
function onChatMessage(playerID, senderName, message)
local msgTxt = string.match(message, "%s(.*)")
local msgNum = tonumber(string.match(message, "%d+"))
-- Check message for nativeCommands
for command, match in pairs(response.nativeCommands) do
local cmdMatch = string.match(message, match)
if cmdMatch then
if command == "id" then
util.id(playerID, beamcfg.playerLimit)
return -1
elseif command == "countdown" then
util.countdown()
return -1
elseif command == "dm" then
local dmTxt = string.sub(message, 6)
util.dmsg(playerID, msgNum, dmTxt)
return -1
end
break
end
end
-- Check message for chatCommands
for command, match in pairs(response.chatCommands) do
local cmdMatch = string.match(message, match)
if cmdMatch then
util.msgSelect(playerID, command)
return -1
end
end
-- Check if sender has elevated permissions
if util.isAuthorized(senderName) then
-- Check message for elevChatCommands
for command, match in pairs(response.elevChatCommands) do
local cmdMatch = string.match(message, match)
if cmdMatch then
util.elevMsgSelect(playerID, command, msgNum)
return -1
end
end
-- Todo: make below into above and add countdown and DM system
-- Check message for elevated native commands
for command, match in pairs(response.nativeCommands) do
local cmdMatch = string.match(message, match)
if cmdMatch then
if command == "kick" then
util.kickPlayer(playerID, msgNum)
return -1
elseif command == "kban" then
util.kbanPlayer(playerID, msgNum)
return -1
elseif command == "ban" then
util.banPlayer(playerID, msgTxt)
return -1
elseif command == "version" then
util.ver(playerID)
return -1
end
break
end
end
end
end