Collision System
The collision system is the core protection mechanism of F5 Safezones. It manages entity ghosting, client-side invincibility, weapon restrictions, and server-side position verification to create a safe, non-violent area.
Damage prevention is applied on each client using GTA invincibility natives while the player is inside a zone. The server verifies positions and coordinates ghosting, but it does not intercept damage or explosion events.
Overview
When a player enters a safezone, the following systems activate:
Independent Protection Systems
The three protection layers are fully decoupled — each is controlled by its own flag and does exactly one thing:
| System | Flag(s) | Default | Effect |
|---|---|---|---|
| Pass-through | collisionDisabled | true | Disables collision between zone members. No transparency. |
| Transparency | enableGhosting / enableVehicleGhosting | false | Makes players / vehicles semi-transparent. No collision effect. |
| Invincibility | enableInvincibility / enableVehicleInvincibility | true | Damage/death protection only. |
So by default, players and vehicles pass through each other while staying fully opaque. Enable transparency separately if you want a visual cue that ghosting is active.
Pass-Through (No-Collision)
Controlled by collisionDisabled (default true). This is the only system that disables collision. It disables collision for exactly these pairs, among entities inside the zone:
- player ↔ player
- player ↔ vehicle
- vehicle ↔ vehicle
Collision with everything else is never touched:
- World geometry, buildings, and map props (
CObject) stay solid — players and vehicles cannot phase through walls, fences, or barriers. - Ambient pedestrians (NPCs on foot) stay solid.
Every vehicle physically inside the zone volume — including players' vehicles, empty/parked vehicles, and ambient NPC traffic — is included in pass-through while it remains inside the zone.
Membership is server-authoritative
Which players count as "in the zone" is decided by the server, not by each client guessing from local positions. The server tracks every player's zone and pushes the member list to each client (receivePlayersInZone / playerEnteredSameZone / playerLeftSameZone). Both clients then disable collision against the same member set, so pass-through is symmetric — you will not get the case where two players collide on one screen but phase through on the other.
Reliability
No-collision is re-applied every frame for all pairs involving the local player and their vehicle. SetEntityNoCollisionEntity only holds for the frame it is called on, so a slower interval would let even a slow-moving car briefly contact and shove a player. Re-applying per frame guarantees the player is never bumped while inside the zone.
Collision is restored automatically the instant an entity leaves the zone, the zone is deactivated, or the zone is removed — the system simply stops re-applying and collision returns on the next frame. (This is why pass-through uses per-frame re-application rather than a permanent disable, which cannot be cleanly reverted and would cause phasing to persist after leaving.)
Transparency (Ghosting)
Ghosting is purely cosmetic — it changes opacity and nothing else.
enableGhosting(defaultfalse) makes the safezone player and other in-zone players semi-transparent (playerAlpha, default 200).enableVehicleGhosting(defaultfalse) makes in-zone vehicles semi-transparent (vehicleAlpha, default 200).
Neither flag affects collision. With both off (the default), everyone stays fully opaque and still passes through each other via collisionDisabled.
Damage Prevention
All damage prevention is client-side, applied through GTA invincibility natives while the player is inside the zone. There is no server-side weapon-damage, vehicle-damage, or explosion-event interception.
Player Invincibility
Gated by the zone's enableInvincibility flag (default true). Applied on entry and re-asserted in the safezone loop, then removed on exit:
| Native | Effect |
|---|---|
SetEntityInvincible(ped, true) | Entity-level invincibility |
SetPlayerInvincible(playerId, true) | Player-level invincibility (GTA native) |
SetEntityCanBeDamaged(ped, false) | Ped is flagged as non-damageable |
Vehicle Invincibility
Gated by the zone's separate enableVehicleInvincibility flag (default true) — independent from player invincibility, so vehicles can be protected even when players are not (or vice versa). Every vehicle inside the zone volume — players' vehicles, empty vehicles, and ambient NPC traffic — is protected:
| Native | Effect |
|---|---|
SetEntityInvincible(vehicle, true) | Vehicle cannot be damaged, deformed, or destroyed |
SetEntityCanBeDamaged(vehicle, false) | Vehicle is flagged as non-damageable |
SetVehicleTyresCanBurst(vehicle, false) | Tyres cannot burst or pop (from shots, spikes, or explosions) |
In-zone vehicles are found by a zone-volume scan and the protection is re-asserted on a short interval (see Update Intervals). When a vehicle leaves the zone — or the player exits — invincibility is removed and the vehicle becomes damageable again.
enableInvincibility controls players and enableVehicleInvincibility controls vehicles, independently — set either to false to disable that side only. Pass-through is separate: it is controlled by collisionDisabled, not by these invincibility flags.
Weapon Restrictions
Inside a safezone:
- The player's weapon is forced to
WEAPON_UNARMED - Firing controls are disabled (triggers, aiming)
- Drive-by is disabled
- Cover system is disabled
- Vehicle weapons are disabled if the zone has
disableVehicleWeaponsenabled (default)
Disabled Controls
The following control groups are disabled while in a safezone:
| Control ID | Action |
|---|---|
| 24, 25 | Attack / Aim |
| 37 | Select Weapon |
| 47 | Weapon (alternate) |
| 58 | Enter/exit vehicle weapon mode |
| 140, 141, 142 | Melee attacks |
| 257 | Attack 2 |
| 263, 264 | Melee |
| 114 | Vehicle fly attack |
| 331 | Vehicle mouse control |
| 99, 100 | Vehicle weapons |
| 357 | Vehicle fly weapon |
Server-Side Verification
F5 Safezones includes server-side anti-cheat verification:
Entry Verification
When a player claims to have entered a safezone, the server:
- Validates the zone name exists and is active
- Retrieves the player's actual server-side coordinates
- Verifies the player is actually within the zone boundaries
- Rejects the entry if verification fails, triggering
f5_safezones:entryRejectedon the client
Periodic Verification
A server-side thread runs every 5 seconds to verify all players in safezones:
- Checks if the player is still connected
- Checks if the player's ped still exists
- Checks if the zone still exists and is active
- Verifies the player's coordinates are still within the zone
Players who fail verification are forcefully exited from the safezone.
Position Tolerance
Server-side position checks include a 5.0 unit tolerance to account for network latency and minor desynchronization.
Update Intervals
The protection systems run on different cadences to balance reliability and performance:
| Work | Cadence | Purpose |
|---|---|---|
| Pass-through re-apply | Every frame | No-collision for the local player and their vehicle against all zone members — guarantees no bumping and instant restore on exit |
| Vehicle detection | 200 ms | How often the zone volume is scanned for vehicles entering/leaving |
| Invincibility + transparency | vehicleEnforce (50 ms) | How often vehicle invincibility and (if enabled) vehicle transparency are re-asserted |
See Configuration — Performance for the tunable intervals.
Cleanup
When a player exits a safezone or the resource stops:
- All ghosted entities have their collision restored
- All entity transparency is reset to original values
- Vehicle weapon restrictions are removed
- Player invincibility is removed
- Vehicle invincibility is removed and every affected vehicle is made damageable again
The cleanup runs immediately on exit with a comprehensive multi-pass sweep: ghosted players, in-zone vehicles, tracked entities, and all vehicles, peds, and objects in range are restored in a single operation.
See Also
- Zone Types — Protection Options — per-zone collision settings
- Configuration — Collision System — global collision settings
- Configuration — Performance — tune update intervals