For Developers - How2add own detection (or cheat prevention)
Pastebin Version: https://pastebin.com/UPqk5u1n
-- Setup the DucksDetector
local DucksDetector = LSAC.detections:Register("Detect people saying ducks in chat too often")
DucksDetector:SetDescription("Detects people saying the word ducks in chat")
-- The default value
local MaxRepetitions = 2
-- AddSetting(name, type, defaultvalue, description, callback)
DucksDetector:AddSetting("Maximum Per Player Ducks in Chat", "number", 2, "If you say ducks more than twice in a minute you're a meanie", function(_, val)
MaxRepetitions = val
end)
-- localize for speedup, this is more useful in scenarios where you're hooking stuff like Tick or StartCommand
local stringlower = string.lower
local stringfind = string.find
local stringTrim = string.Trim
-- This is the main function for this detection
local function PlayerSay(ply, txt)
txt = stringlower(txt)
if (not txt or stringTrim(txt) == "") then
return
end
-- he said it... he said ducks in chat!
-- note, we do not really need IsVolatile here because this detection is not based of player movement whatsoever, it's just for example purposes
if (stringfind(txt, 1, true) and not DucksDetector:IsVolatile(ply)) then
DucksDetector:FlagInc(ply)
if (DucksDetector:FlagGet(ply) >= MaxRepetitions) then
-- 70 as in we are 70% sure that guy is a cheater because he said ducks too often
-- logsonly is false, we want it to do more than just log
-- kickonly is true, we want it to do nothing more than kicking the user
-- as extra information we use the current message he wrote in chat
LSAC.infractions:TriggerInfraction(ply, DucksDetector, 70, false, true, txt)
end
else
-- okey... good boy.. he did not say ducks in chat
DucksDetector:FlagDec(ply)
end
end
-- Don't forget to add the hook to the anticheats hooks
DucksDetector:AddHook("PlayerSay", function(...)
PlayerSay(...)
end)
-- Just to be extra sure, we clear every players flags every minute
LSAC:timerCreate("DucksDetector.ClearPlayerDucks", 60, 0, function()
for k,v in ipairs(player.GetAll()) do
DucksDetector:FlagReset(v)
end
end)