Integration with your server's scripts

A script that heals, teleports, makes someone invisible or spawns vehicles does, from the game's point of view, the same thing as a cheat. This page shows how the script tells the Shield that the action is its own.

The rule

The server is what allows an action. Every export on this page is called on the server side of your script.

  • On the server, the Shield knows for sure which resource made the call. It cannot be faked.
  • The client allows nothing. A cheat runs on the client and could call the same notice.

That is why there is no allow export on the client. If your action happens on the client, the path is: the client asks the server, the server checks whether the player is allowed, tells the Shield, and only then tells the client to run it.

Lua
-- server.lua of your script
RegisterNetEvent("hospital:tratar", function()
	local src = source
	if not estaNoHospital(src) then return end              -- 1. check that the player is allowed

	exports['mengazo-shield']:notifyAction(src, "heal")     -- 2. tell the Shield
	TriggerClientEvent("hospital:aplicarCura", src)         -- 3. tell the client to run it
end)

The check in step 1 is yours. An event that tells the Shield without checking anything allows the action for anyone who triggers the event.

What already works without code

With the companion installed in the resources (the Shield installs it on its own, see Installation), the Shield already recognizes:

  • Actions done on the script's server side: SetEntityCoords, SetEntityHealth, SetPedArmour, GiveWeaponToPed, RemoveWeaponFromPed, RemoveAllPedWeapons, FreezeEntityPosition and instance changes (SetPlayerRoutingBucket).
  • Teleports with the coordinates in the event: the server sends TriggerClientEvent (or a vRP Tunnel) with a vector3 or x, y, z. Arriving near that point is not suspicious.
  • Known heal, armour and speed names sent by the server: setHealth, revive, setArmour, setRunSpeed and similar. Your server's own names go in Bridge.pushKinds (see Configuration).
  • Respawning after going down and entering an instance (house, prison, event).
  • Heavily used teleport points: a destination where many players arrive becomes a known point.

So, before writing code, see what is left:

Console
shield_compat

The command lists the resources whose client actions did not come from the server. Those are the ones that need one of the exports below.

Quick guide

The script...Use
Turns on godmode, invisibility, spectate, noclip, freecamnotifyAction and clearAction
Heals, gives armour, repairs a vehicle, changes speednotifyAction
Teleports to a known placenotifyTeleportTo
Changes the player's pednotifyPedChange or allowPed
Spawns vehicles, props or peds from the clientauthorizeSpawn
Uses a blacklisted model in an eventallowModel
Gives a weapon, or allows a banned weapon for someoneallowWeapon and giveWeapon
Shows blips on other playersallowBlips
Has its own scene (character selector, minigame)notifyContext
Calls an event many times per secondEvent limit
Wants to ban or record the screen through the ShieldBan, video and ban event

Actions: notifyAction and clearAction

Lua
exports['mengazo-shield']:notifyAction(src, tipo, tempoMs, valor)
exports['mengazo-shield']:clearAction(src, tipo)
ArgumentWhat it is
srcthe player's source (number)
tipoone of the types in the tables below
tempoMsoptional; how long it lasts, in milliseconds. Capped at 30 seconds
valoroptional; only for armour, heal and movemod

A type that is not in the tables is ignored.

States that turn on and off

notifyAction turns it on. clearAction turns it off. Without tempoMs, the state lasts until clearAction, until the player leaves or until your script stops.

TypeWhat for
godInvincible
invisibleInvisible
spectateWatching another player
noclipFlying without collision
freecamFree camera
freezeFrozen in place
nightvisionNight vision
thermalThermal vision
downedDown, waiting for help
cuffedHandcuffed
Lua
-- staff noclip command
local emNoclip = {}

RegisterCommand("nc", function(source)
	if not ehStaff(source) then return end

	emNoclip[source] = not emNoclip[source]
	if emNoclip[source] then
		exports['mengazo-shield']:notifyAction(source, "noclip")
	else
		exports['mengazo-shield']:clearAction(source, "noclip")
	end
	TriggerClientEvent("staff:noclip", source, emNoclip[source])
end)

AddEventHandler("playerDropped", function() emNoclip[source] = nil end)

Without this notice, the command's noclip is treated as a cheat: after a few seconds of flying the player goes back to the starting point.

If your script has no clear "turn off" moment, pass a duration and renew it while the state lasts:

Lua
-- renews every 20 s; if the script stops renewing, the state drops on its own
exports['mengazo-shield']:notifyAction(src, "invisible", 25000)

Instant actions

They open a short window: 6 seconds by default, 30 at most. Call it right before the action happens.

TypeWhat for
healHeal, revive
armourArmour
fixVehicle repair
teleportTeleport with no known destination
movemodOn-foot speed change (drug, energy drink, skill)
staminaInfinite or increased stamina
weaponWeapon handed out
removeweaponWeapon removed
changepedPlayer model change
taskmodCarrying, cuffing, attaching the player to another
explosionExplosion created by the script
instanceInstance change
Lua
-- mechanic
exports['mengazo-shield']:notifyAction(src, "fix")
TriggerClientEvent("mecanica:consertar", src)

-- carry a player on the shoulder for up to 20 s
exports['mengazo-shield']:notifyAction(alvo, "taskmod", 20000)

Actions with a value

For armour, healing and speed, say how much. The Shield accepts up to that value for longer, and anything above it is still suspicious.

Lua
exports['mengazo-shield']:notifyAction(src, "armour", nil, 100)   -- armour up to 100, for 2 minutes
exports['mengazo-shield']:notifyAction(src, "heal", nil, 200)     -- health up to 200, for 20 seconds
exports['mengazo-shield']:notifyAction(src, "movemod", nil, 1.3)  -- run up to 1.3x, for 5 minutes

Full example, an armour item in the inventory:

Lua
-- server.lua
RegisterNetEvent("inventario:usarColete", function()
	local src = source
	if not removerItem(src, "colete", 1) then return end    -- only players who have the item

	exports['mengazo-shield']:notifyAction(src, "armour", nil, 100)
	TriggerClientEvent("inventario:aplicarColete", src, 100)
end)
Lua
-- client.lua
RegisterNetEvent("inventario:aplicarColete", function(valor)
	SetPedArmour(PlayerPedId(), valor)
end)

Shortcuts

They do the same as notifyAction for a single case. They take the duration in milliseconds as the second argument.

Lua
exports['mengazo-shield']:notifyHeal(src)        -- 4 s by default
exports['mengazo-shield']:notifyArmour(src)      -- 4 s by default
exports['mengazo-shield']:notifyPedChange(src)   -- 15 s by default
exports['mengazo-shield']:notifyTeleport(src)    -- 8 s by default

Teleport

When you know the destination, pass it. The Shield only accepts it if the player arrives at that point, so a cheat cannot use the window to go somewhere else.

Lua
exports['mengazo-shield']:notifyTeleportTo(src, x, y, z, raio, tempoMs)
  • raio: accepted distance around the destination, in meters. Default 50.
  • tempoMs: time limit to arrive. Default 15 seconds.
Lua
-- entering an interior
RegisterNetEvent("casas:entrar", function(casaId)
	local src = source
	local casa = Casas[casaId]
	if not casa or not temChave(src, casaId) then return end

	exports['mengazo-shield']:notifyTeleportTo(src, casa.x, casa.y, casa.z, 30.0, 10000)
	TriggerClientEvent("casas:irPara", src, casaId)
end)

If the server already sends the coordinates inside the event, you do not need the export: the Shield reads the destination on its own.

Lua
-- this is enough
TriggerClientEvent("casas:irPara", src, vector3(casa.x, casa.y, casa.z))

With no known destination (a /tpway to the map marker, for example), use the simple window. It is weaker, because it accepts any destination while it is open.

Lua
exports['mengazo-shield']:notifyTeleport(src, 8000)

Ped change

Lua
-- the player is about to change model now (selector, ped shop, staff command)
exports['mengazo-shield']:notifyPedChange(src)

-- this player can always use this model (VIP ped, event mascot)
exports['mengazo-shield']:allowPed(src, "a_c_chimp")
exports['mengazo-shield']:disallowPed(src, "a_c_chimp")
  • allowPed lasts until the player leaves or until disallowPed. Call it again when they join.
  • With allowPed, the model is allowed even if it is on the banned peds list, but only on the player's own ped.
  • Changing to one of the default models (mp_m_freemode_01 and mp_f_freemode_01) is never suspicious.
Lua
-- VIP ped allowed on login
AddEventHandler("meu_core:jogadorEntrou", function(src, dados)
	if dados.pedVip then
		exports['mengazo-shield']:allowPed(src, dados.pedVip)
	end
end)

Spawning vehicles, objects and peds

A vehicle, object or ped created by the script's server side already has an origin. The export is for when the client creates it (a garage that creates the car on the client, house furniture, props for a job).

Lua
exports['mengazo-shield']:authorizeSpawn(src, modelo, quantidade, tempoMs)
exports['mengazo-shield']:authorizeSpawnBatch(src, lista, tempoMs)
ArgumentWhat it is
srcsource of the player who will create it. -1 = any client (then the model is required)
modeloname or hash. nil or 0 = any model
quantidadehow many spawns the credit covers. Default 10, max 100
tempoMshow long the credit is valid. Default 10 seconds, max 30

Both return true when the credit was accepted. notifySpawn is another name for authorizeSpawn.

Lua
-- garage: the player's client creates the vehicle
RegisterNetEvent("garagem:retirar", function(placa)
	local src = source
	local veiculo = buscarVeiculo(src, placa)
	if not veiculo then return end

	exports['mengazo-shield']:authorizeSpawn(src, veiculo.modelo, 1, 10000)
	TriggerClientEvent("garagem:criar", src, veiculo)
end)
Lua
-- garage: the SERVER creates it with CreateVehicle
-- the one that actually creates it is a client near the point, not always the one who asked: use -1 and the model
exports['mengazo-shield']:authorizeSpawn(-1, veiculo.modelo, 1, 10000)
local veh = CreateVehicle(GetHashKey(veiculo.modelo), x, y, z, heading, true, true)
Lua
-- furniture: several models at once
exports['mengazo-shield']:authorizeSpawnBatch(src, {
	{ model = "prop_chair_01a", count = 4 },
	{ model = "prop_table_03",  count = 1 },
	{ model = 0, count = 2 },   -- 2 of any model
}, 15000)

The credit allows the burst of that moment. The general caps still apply: active count per player, per area and across the whole server.

Blacklisted model in an event

Lua
-- allows the model for 10 minutes; without the duration, it lasts until the Shield restarts
exports['mengazo-shield']:allowModel("stt_prop_stunt_tube_s", 600000)

To allow it permanently, use Allowlist.models or Config > Allowed models in the panel.


Weapons

Giving a weapon

A weapon given by the script's server side (GiveWeaponToPed on the server) already has an origin. If your inventory hands it out from the client, register it on the server:

Lua
-- you hand it out your own way; the Shield just gets told
exports['mengazo-shield']:allowWeapon(src, "WEAPON_PISTOL")

-- or let the Shield hand it out from the server (weapon, ammo, already in hand?)
exports['mengazo-shield']:giveWeapon(src, "WEAPON_PISTOL", 250, true)

-- took the weapon away from the player
exports['mengazo-shield']:disallowWeapon(src, "WEAPON_PISTOL")

-- reload from the server; returns false if the weapon is not theirs
local ok = exports['mengazo-shield']:reloadWeapon(src, "WEAPON_PISTOL", 60)
if not ok then devolverMunicao(src) end

It takes the weapon name or hash. The registration lasts until the player leaves.

Banned weapon allowed for one player

Weapons in Blacklists.playerWeapons are removed from any player's hand. To allow one of them for someone:

Lua
-- minigun allowed for the event
exports['mengazo-shield']:allowWeapon(src, "WEAPON_MINIGUN")
-- end of the event
exports['mengazo-shield']:disallowWeapon(src, "WEAPON_MINIGUN")

Addon weapon or changed damage

This is not a case for an export. The Shield needs to know the weapon's base damage on your server:

  • In the panel: Config > Base damage per weapon.
  • Or in the file: Allowlist.overrides.weaponDamage (see Configuration).

Do not use notifyAction(src, "weapon") to deal with a weapon that is too strong. That opens an exemption window and hides a real damage multiplier.


Blips on players

Seeing a blip on another player is how map ESP works. If your script does this on purpose (gang radar, police GPS), there are three ways:

Lua
-- 1. through the script: this player can see blips
exports['mengazo-shield']:allowBlips(src)           -- until they leave, or until disallowBlips
exports['mengazo-shield']:allowBlips(src, 600000)   -- for 10 minutes
exports['mengazo-shield']:disallowBlips(src)
server.cfg
# 2. through server.cfg: a whole group
add_ace group.police mengazo.shield.bypass.blips allow
Lua
-- 3. by sprite: in config/allowlist.lua (or Config > Server blip sprites)
blipSprites = { 9, 225 },
Lua
-- example: GPS only for on-duty police
RegisterNetEvent("policia:servico", function(entrando)
	local src = source
	if not ehPolicial(src) then return end

	if entrando then
		exports['mengazo-shield']:allowBlips(src)
	else
		exports['mengazo-shield']:disallowBlips(src)
	end
end)

Custom scenes and states: notifyContext

For a situation that touches several things at once and does not fit a single type. You say which detections are covered and for how long.

Lua
local ok = exports['mengazo-shield']:notifyContext(src, nome, tempoMs, deteccoes)
exports['mengazo-shield']:clearContext(src, nome)
  • nome: a name of your choice for the situation.
  • tempoMs: from 1 to 60 seconds. Default 15.
  • deteccoes: list with the names of the covered detections. Required.
  • Only the script that opened it can close it.
Lua
-- character selector: the player is invisible, gets moved and changes ped
RegisterNetEvent("personagens:abrir", function()
	local src = source
	exports['mengazo-shield']:notifyContext(src, "seletor", 30000, {
		"INVISIBILITY", "TELEPORT", "NOCLIP_SUSPECT", "CHANGE_PED",
	})
end)

RegisterNetEvent("personagens:escolhido", function()
	exports['mengazo-shield']:clearContext(source, "seletor")
end)

If the scene lasts more than 60 seconds, renew the context while it is open.

Most used detection names:

NameDetection
TELEPORTTeleport
NOCLIP_SUSPECTNoclip
MOVEMENT_SPEEDOn-foot speed
SUPER_JUMPSuper jump
INVISIBILITYInvisible
GODMODE_SUSPECTGodmode
ILLEGAL_HEALHeal with no origin
ILLEGAL_ARMOURArmour with no origin
CHANGE_PEDPed change
FREECAMFree camera
SPECTATORSpectator
VEHICLE_SPEEDVehicle speed
VEHICLE_TELEPORTVehicle teleport
VEHICLE_REPAIRVehicle repair

The name of each detection shows up in the Blocks records in the panel.


Events called many times

The Shield limits how many times a player can call each server event. A HUD or inventory that calls a lot can hit the limit. The call is just refused, with no punishment.

  1. Run shield_gate in the console. It shows the events with refusals and the suggested adjustment.
  2. Paste the suggestion into Config.RemoteGate.overrides:
Lua
overrides = {
	["meu_hud"] = {
		["meu_hud:atualizar"] = { maxCalls = 120, burst = 30 },
	},
},

Even better is for the script to call less: send the state only when it changes, instead of every second.

Details in Configuration.


Official player ID

With vRP, Creative, QBCore and Qbox the Shield finds the ID on its own. On a custom framework, pass it on login and on character change:

Lua
exports['mengazo-shield']:setPlayerId(source, user_id, "Passaporte")   -- the 3rd argument is how the ID is labeled
exports['mengazo-shield']:setPlayerId(source, nil)                     -- clears it (back to the selector)

local id = exports['mengazo-shield']:getPlayerId(source)

It is only for display and filtering. The ban still applies to the player's accounts (license, steam, discord).


Ban, video and ban event

Banning through the Shield

Lua
local ok, resultado = exports['mengazo-shield']:banPlayer(source, "Dinheiro duplicado no caixa")
if ok then
	print("banido, ID " .. resultado)        -- the ID the player sees on screen
else
	print("ban recusado: " .. resultado)     -- reason for the refusal
end
  • It follows the same path as the automatic ban: it goes to the website, records the screen before the kick and applies to the account and to the PC.
  • The reason is only shown to staff (up to 200 characters). The player only sees the ban ID.
  • Staff can see which script made the ban.
RefusalReason
inactiveInvalid license, Shield stopped
player_offlineThe player is not on the server
reason_requiredEmpty reason
already_bannedThe player is already being kicked with a ban
no_identifiersThe player has no identifiable account
rate_limitedMore than 20 bans from the same script in 1 minute

Recording the player's screen

Lua
-- 10 s before the request and 5 s after
exports['mengazo-shield']:captureVideo(source, 10, 5, function(result)
	if result.ok then
		print(("clipe %s: %s"):format(result.id, result.url))
	else
		print("sem clipe: " .. result.error)
	end
end, { title = "Report #42" })
  • There is only a "before" if recording was already on. Turn it on when the situation starts:
Lua
exports['mengazo-shield']:startReplay(source)   -- starts keeping the last few seconds
exports['mengazo-shield']:stopReplay(source)
  • Before: up to 12 seconds. After: up to 15 seconds.
  • With no destination, the video goes to the player's profile on the website. To send it to a Discord channel, pass webhook in the last argument: { title = "Report #42", webhook = "https://discord.com/api/webhooks/..." }.
  • Limits: 1 clip at a time per player, 3 per minute per player, 10 per minute per script.

Knowing when someone is banned

Lua
AddEventHandler("mengazo_shield:playerBanned", function(source, reason, data)
	if GetInvokingResource() ~= "mengazo-shield" then return end   -- only the Shield triggers it

	-- source: the player, still online, or nil if they are not on the server
	-- data.banId, data.origin, data.name, data.frameworkId, data.identifiers
	if source then
		registrarNoMeuLog(data.frameworkId, reason, data.banId)
	end
end)
  • Use AddEventHandler. Never RegisterNetEvent on this name: it would become an event the client can trigger.
  • Use the first argument, not the global source.
  • It fires once per ban, before the kick. There is time to read the player's data from your framework.
  • data.origin says where it came from: automatic, staff, script, site, aar or hwid.

How to check

  1. Do the action with an account without bypass. A staff account in bypass tests nothing.
  2. Run shield_watch <id> in the console to follow the player live.
  3. Look at Blocks in the panel. Nothing new: the integration worked.
  4. If a record showed up, open the evidence. The claimedBy field shows which script did the action from the client without telling the server.
  5. shield_compat shows the summary per resource.

Common mistakes

  • Calling the export on the client. It does not exist. Call it on the server.
  • Telling the Shield after the action. The window has to be open when the action happens. Tell it before you tell the client to run it.
  • Telling the Shield without checking. An event that allows the action without checking permission allows it for the cheat too.
  • Forgetting clearAction. The player keeps the state allowed until they leave.
  • A big window "just in case". The bigger the window, the more time a cheat has to take advantage of it. Use the time the action takes.
  • Putting the script in trusted resources to avoid integrating. It works, but it removes protection from everything that goes through that script.