-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
44 lines (40 loc) · 1.88 KB
/
server.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
local banned_chars = {'"', "'", "<", ">", "=", "script"}
local kick_when_found = true
local check_on_connect = true
local check_during_playing = true
local function checkName(name)
for key, ply in pairs(GetPlayers()) do
if string.find(name, name) then
return true
end
end
return false
end
AddEventHandler('playerConnecting', function(playername, setKickReason)
if check_on_connect then
if checkName(playername) then
if kick_when_found then
TriggerClientEvent('chatMessage', -1, ':fsn_server:', {255,0,0}, GetPlayerIdentifiers(source)[1]..' was removed from the server due to disallowed characters in their Steam name.')
DropPlayer(source, '[SERVER] You have been removed from the session due to your Steam name.')
setKickReason('[SERVER] You have been removed from the session due to your Steam name.')
else
TriggerClientEvent('chatMessage', -1, ':fsn_server:', {255,0,0}, GetPlayerIdentifiers(source)[1]..' has disallowed characters in their Steam name but was not removed due to server configuration.')
end
end
end
end)
Citizen.CreateThread(function()
while check_during_playing do
Citizen.Wait(1)
for key, player in pairs(GetPlayers()) do
if checkName(GetPlayerName(player)) then
if kick_when_found then
TriggerClientEvent('chatMessage', -1, ':fsn_server:', {255,0,0}, GetPlayerIdentifiers(player)[1]..' was removed from the server due to disallowed characters in their Steam name.')
DropPlayer(player, '[SERVER] You have been removed from the session due to your Steam name.')
else
TriggerClientEvent('chatMessage', -1, ':fsn_server:', {255,0,0}, GetPlayerIdentifiers(player)[1]..' has disallowed characters in their Steam name but was not removed due to server configuration.')
end
end
end
end
end)