shared
CancelEvent
FiveM shared native documentation with a Lua example.
Summary
Cancels the currently handled event where cancellation is supported (e.g. some game events, entity creation). Used to block unwanted default behavior.
Returns
void
Example
AddEventHandler('entityCreating', function(entity)
if IsThisBad(entity) then
CancelEvent()
end
end)Common pitfalls
- Only works inside events that support cancellation.
- Common in anti-cheat / entity governance to block disallowed spawns.
Related natives
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →