Fiveguard Docs
  • Get Started
  • Installation
  • Sub Users
  • Customer Rank
  • FAQ
  • Safe Events
    • Manual Safe Events
    • Auto Safe Events
  • Exports
    • Server-Side Exports
    • Client-Side Exports
  • Event Handlers
    • Server-Side Events
  • Permission System
    • Ace Permissions
    • Alternative Permissions
    • Custom Permissions (ACE)
  • Fiveguard Commands
    • Server Commands
    • Client Commands
  • Admin Menu
  • Performance
  • False Bans
Powered by GitBook
On this page
  • Exports for Safe Events
  • Example Of Code
  1. Safe Events

Manual Safe Events

With Safe Events you can protect your events from being abused by cheaters.

To use Manual Safe Events you have to enable Safe Events in config

Server Event sent by Safe Events System has token on 33 index argument, if your resource sends more arguments than 32 then argument index 33 will be overwritten with token

Exports for Safe Events

-- CLIENT-SIDE
exports["anticheat-name"]:ExecuteServerEvent(EventName, ...)
exports["anticheat-name"]:ExecuteLatentServerEvent(EventName, bps, ...)
-- SERVER-SIDE
exports["anticheat-name"]:RegisterSafeEvent(EventName, config, cross_scripts)
exports["anticheat-name"]:VerifyToken(source)
-- RegisterSafeEvent default config :
{
    log = true,
    ban = true
}

ExecuteServerEvent export:

Executes Safe Event

RegisterSafeEvent export:

Registers Event in Safe Events System

VerifyToken export:

Stops the event from being executed if the player got banned by Safe Events System

Example Of Code

local money = 200

exports["anticheat-name"]:ExecuteServerEvent("taxi:pay", money)
local allEvents = {
    ["taxi:pay"] = false
}
local fiveguard_resource = ""
AddEventHandler("fg:ExportsLoaded", function(fiveguard_res, res)
    if res == "*" or res == GetCurrentResourceName() then
        fiveguard_resource = fiveguard_res
        for event,cross_scripts in pairs(allEvents) do
            local retval, errorText = exports[fiveguard_res]:RegisterSafeEvent(event, {
                ban = true,
                log = true
            }, cross_scripts)
            if not retval then
                print("[fiveguard safe-events] "..errorText)
            end
        end
    end
end)

RegisterNetEvent("taxi:pay")
AddEventHandler("taxi:pay", function(money)
    local source = source
    if not exports[fiveguard_resource]:VerifyToken(source) then return end
    print("user", source)
    print("money", money)
end)
PreviousSafe EventsNextAuto Safe Events

Last updated 10 months ago