Fix kick message & ability

This commit is contained in:
Mitch Durso 2022-06-11 12:33:48 +01:00
parent 565f8df116
commit 48119d1aee

View File

@ -209,10 +209,20 @@ function onChatMessage(id, name, message)
if checkAdmin(identifiers) then if checkAdmin(identifiers) then
local players = MP.GetPlayers() local players = MP.GetPlayers()
for playerID, playerName in pairs(players) do for playerID, playerName in pairs(players) do
if message[1] == ''..playerID then print(playerID, message[1])
MP.DropPlayer(message[1]) if message[1] == tostring(playerID) then
if message[2] then
message[0] = ''
message[1] = ''
msg = table.concat(message, ' ')
MP.DropPlayer(tonumber(playerID), msg)
MP.SendChatMessage(-1, playerName..' was kicked from the server.') MP.SendChatMessage(-1, playerName..' was kicked from the server.')
MP.SendChatMessage(-1, 'Reason: '..message[1]) MP.SendChatMessage(-1, 'Reason: '..msg)
else
MP.DropPlayer(tonumber(playerID))
MP.SendChatMessage(-1, playerName..' was kicked from the server.')
end
end end
end end
else else
@ -231,14 +241,19 @@ function onChatMessage(id, name, message)
-- Do not allow admins to ban admins -- Do not allow admins to ban admins
MP.SendChatMessage(id, '^4You cannot ban another server admin.') MP.SendChatMessage(id, '^4You cannot ban another server admin.')
else else
MP.DropPlayer(message[1]) MP.DropPlayer(tonumber(message[1]))
local file = io.open("bans.txt", "a"); local file = io.open("bans.txt", "a");
for TYPE, ID in pairs(ids) do for TYPE, ID in pairs(ids) do
file:write(ID, "\n") file:write(ID, "\n")
table.insert (bans, ID); table.insert (bans, ID);
end end
MP.SendChatMessage(-1, playerName..' was banned.') MP.SendChatMessage(-1, playerName..' was banned.')
MP.SendChatMessage(-1, 'Reason: '..message[1]) if message[2] then
message[0] = ''
message[1] = ''
msg = table.concat(message, ' ')
MP.SendChatMessage(-1, 'Reason: '..msg)
end
end end
end end
end end