F5 StudioF5 Studio
Skip to main content

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.

Protection is client-side

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:

SystemFlag(s)DefaultEffect
Pass-throughcollisionDisabledtrueDisables collision between zone members. No transparency.
TransparencyenableGhosting / enableVehicleGhostingfalseMakes players / vehicles semi-transparent. No collision effect.
InvincibilityenableInvincibility / enableVehicleInvincibilitytrueDamage/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 (default false) makes the safezone player and other in-zone players semi-transparent (playerAlpha, default 200).
  • enableVehicleGhosting (default false) 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:

NativeEffect
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:

NativeEffect
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.

caution

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 disableVehicleWeapons enabled (default)

Disabled Controls

The following control groups are disabled while in a safezone:

Control IDAction
24, 25Attack / Aim
37Select Weapon
47Weapon (alternate)
58Enter/exit vehicle weapon mode
140, 141, 142Melee attacks
257Attack 2
263, 264Melee
114Vehicle fly attack
331Vehicle mouse control
99, 100Vehicle weapons
357Vehicle 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:

  1. Validates the zone name exists and is active
  2. Retrieves the player's actual server-side coordinates
  3. Verifies the player is actually within the zone boundaries
  4. Rejects the entry if verification fails, triggering f5_safezones:entryRejected on 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:

WorkCadencePurpose
Pass-through re-applyEvery frameNo-collision for the local player and their vehicle against all zone members — guarantees no bumping and instant restore on exit
Vehicle detection200 msHow often the zone volume is scanned for vehicles entering/leaving
Invincibility + transparencyvehicleEnforce (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:

  1. All ghosted entities have their collision restored
  2. All entity transparency is reset to original values
  3. Vehicle weapon restrictions are removed
  4. Player invincibility is removed
  5. 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