-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntiFlood.lua
51 lines (46 loc) · 1.58 KB
/
AntiFlood.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
script_name("AntiFlood")
script_description("Anti-flood for samp-rp")
script_version_number(1)
script_version("v1.0")
script_author("Und3X")
-- Load libraries
local moonloader = require "moonloader"
local sampev = require "samp.events"
-- Global variables
local MESSAGES = {}
local TIMEOUT = 10
-- AntiFlood patterns
local PATTERNS = {
"([%a_]+).*: (.*)$",
"%(%( ([%a_]+)%[(%d+)%] %)%) (.*)$",
"([%a_]+) êðèêíóë: (.*)$",
}
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage("AntiFlood by {ff69b4}Und3X{ffd700} {ffffff}çàãðóæåí!",0xffd700)
end
-- Events
function sampev.onServerMessage(color, message)
for key, value in pairs(PATTERNS) do
if message:find(PATTERNS[key]) then
local Player, Msg = message:match(PATTERNS[key])
if MESSAGES[Player] ~= nil then
if MESSAGES[Player].Message == Msg and MESSAGES[Player].Timestamp >= os.time() then
--print(string.format("[AntiFlood] Player: %s, send message: %s. Timestamp: %d.", Player, Msg, os.time()))
return false
else
MESSAGES[Player] = {
Message = Msg,
Timestamp = os.time()+TIMEOUT
}
end
else
MESSAGES[Player] = {
Message = Msg,
Timestamp = os.time()+TIMEOUT
}
end
end
end
end