Mad Development
  • 👋About Mad Developments
  • Script Guides
    • 🔓Safe Events
Powered by GitBook
On this page
  • Client-Side
  • Before:
  • After:
  • Server-Side
  • Config (server-side)
  • Dependacies
  1. Script Guides

Safe Events

This script protects your server from cheaters who use LUA executers to abuse events that you have unprotected, it has been tested on servers with +300 players and I can guarantee that it works well, it uses fivem's native DropPlayer so if your log system is prepared for it you will receive the logs automatically.

Client-Side

You need to change the TriggerServerEvent of the events you want to secure, like the example below.

Before:

TriggerServerEvent("testevent:server", "arg1", "arg2")

After:

This must be called on the top of client file like the core object

local token = exports.mad_safeevents:getToken()

This is called to replace the TriggerServerEvent

exports.mad_safeevents:ExecuteServerEvent("testevent:server", token, "arg1", "arg2")

Server-Side

You need to edit your server event to get ready to handle the event safer

You need to place this on top of your server event, this export return true or false and drop the player if needed

if not exports.mad_safeevents:verifyToken(src, token, "testevent:server") then 
        return print("player: "..src.." just got dropped") 
end

Example:

You need to receive the token and args (args are optional)

RegisterServerEvent("testevent:server", function(token, args)
    local src = source
    local x, y = table.unpack(args)
    print(x, y)
    --this will print "arg1" and "arg2"
    if not exports.mad_safeevents:verifyToken(src, token, "testevent:server") then 
        return print("player: "..src.." just got dropped") 
    end
 
 
 
     --Do what ever you want to do
end)

Config (server-side)

Config = {}

--Make sure that those events dont exist in your server, they are fake just to make cheater execute them and get dropped

Config.FakeServerEvents = {  
    "banking:server:addmoney",
    "hunting:server:addmoney",
    "police:server:addmoney",

}

--Message that the cheater will get when gets droped, remember that if your log system its prepered to handle DropPlayer function you will get the log of it

Config.DropPlayerMessage = "U have been dropped cheater :)"
Config.InvalidTokenMessage = "You dont remember your token lil bro?"


-- You must register here the events that you want to be safe

Config.SafeEvents = {
    ['namevent'] = {
        checkdimension = true,      --almost always true, only set to false if you are triggering a event that the player can be in a diferent dimension
        checkcoords = vec3(200.0, 100.0, 41.0),       --coords where the player should be or false
        maxdist = 100       --maximum distance that player can be from the coords above
    },

    ['test'] = {
        checkdimension = true,      --almost always true, only set to false if you are triggering a event that the player can be in a diferent dimension
        checkcoords = vec3(200.0, 100.0, 41.0),       --coords where the player should be or false
        maxdist = 100       --maximum distance that player can be from the coords above
    },

    ['testevent:server'] = {
        checkdimension = true,      --almost always true, only set to false if you are triggering a event that the player can be in a diferent dimension
        checkcoords = false,       --coords where the player should be or false
        maxdist = 10       --maximum distance that player can be from the coords above
    },
}

Dependacies

  • ox_lib

  • ESX or QBCORE or QBOX

PreviousAbout Mad Developments

Last updated 11 months ago

🔓