Blumlaut / anticheese-anticheat

the FiveM anticheat, actively fighting against cheaters in FiveM.
The Unlicense
85 stars 43 forks source link

Remove flag after a moment #2

Closed by-nari closed 2 weeks ago

by-nari commented 5 years ago

How can I reset flag from the last time player take flag? Just want to make sure the player won't be banned by teleport to jail or revive in the hospital

by-nari commented 5 years ago

My solution

    function WarnPlayer(playername, reason)
        local isKnown = false
        local isKnownCount = 1
        local isKnownExtraText = ""
        for i,thePlayer in ipairs(violations) do
            if thePlayer.name == name then
                isKnown = true
                if (os.time() - violations[i].lastupdate) < 1800 then
                    if violations[i].count == 3 then
                        TriggerEvent("banCheater", source,"Cheating")
                        isKnownCount = violations[i].count
                        table.remove(violations,i)
                        isKnownExtraText = ", was banned."
                    else
                        violations[i].count = violations[i].count+1
                        violations[i].lastupdate = os.time()
                        isKnownCount = violations[i].count
                    end
                else
                    violations[i].count = 1
                    violations[i].lastupdate = os.time()
                    isKnownCount = 1
                end
            end
        end

        if not isKnown then
            table.insert(violations, { name = name, count = 1, lastupdate = os.time() })
        end

        return isKnown, isKnownCount,isKnownExtraText
    end