F5 StudioF5 Studio
Skip to main content

Collision System

The collision system is the core protection mechanism of F5 Safezones. It manages entity ghosting, damage prevention, weapon restrictions, and server-side verification to create a safe, non-violent area.

Overview

When a player enters a safezone, the following systems activate:

Ghosting

Ghosting makes entities non-collidable with the safezone player. Ghosted entities become semi-transparent to visually indicate the effect.

How It Works

  1. The system scans for vehicles and NPCs within the configured range (default 100m)
  2. Collision is disabled between the player and detected entities using SetEntityNoCollisionEntity
  3. Entity transparency is set to the configured vehicleAlpha (default 200/255)
  4. When a vehicle is very close (< 5m), its transparency increases further (to 150/255) for visual clarity
  5. Player ghosting is handled separately — players in the same zone also become non-collidable

Player-to-Player Ghosting

When multiple players are in the same zone:

  • Each player's collision with others in the zone is disabled
  • Players appear semi-transparent to each other (configurable playerAlpha)
  • The server coordinates ghosting by notifying all players in the zone when someone enters or leaves
  • If a player's vehicle is ghosted, the vehicle is also ghosted for all zone occupants

Disabling Ghosting

Set enableGhosting = false on a zone to disable player and vehicle ghosting for that zone. Players will still be invincible and unable to use weapons, but they will collide normally with vehicles and other players.

Full Ghost Mode

Set collisionDisabled = true on a zone to enable full ghost mode. In this mode, the player passes through all nearby entities — vehicles, NPCs, and world objects (CObject) within the configured range (default 100m). This is the most aggressive collision mode available.

caution

The field name is misleading — collisionDisabled = true does not skip collision processing. It enables maximum ghosting where all collisions are disabled for the player. The collision system runs at full capacity to ghost every entity in range.

Damage Prevention

Weapon Damage (Server-Side)

The server intercepts all weaponDamageEvent events:

  • If the victim is in a safezone, damage is cancelled
  • If the attacker is in a safezone, damage is cancelled and the attacker receives a notification
  • This applies to all weapon types including melee

Vehicle Damage (Server-Side)

The server intercepts vehicleDamageEvent events:

  • If any occupant of the target vehicle is in a safezone, vehicle damage is cancelled
  • The attacker receives a "Vehicle damage is disabled in safe zones!" notification

Explosion Prevention (Server-Side)

The server intercepts all explosionEvent events:

  • If any safezone player is within the configured explosionRange (default 100m) of the explosion, it is cancelled entirely
  • The player who triggered the explosion receives a notification
info

Explosion cancellation protects all safezone players within range, not just the nearest one. However, cancelling the explosion also prevents it from affecting non-safezone players nearby.

Vehicle Protection (Client-Side)

While inside a safezone, the player's current vehicle receives additional protection:

ProtectionDescription
SetEntityCanBeDamaged(false)Entity cannot take damage
SetEntityInvincible(true)Entity is invincible
SetVehicleCanBeVisiblyDamaged(false)No visual damage deformation
SetVehicleEngineCanDegrade(false)Engine health preserved
SetVehicleTyresCanBurst(false)Tires cannot pop

Player Protection (Client-Side)

ProtectionDescription
SetPlayerInvincible(true)Player-level invincibility (GTA native)
SetEntityInvincible(true)Entity-level invincibility
SetEntityCanBeDamaged(false)Player takes no damage
SetPedSuffersCriticalHits(false)Disables headshot multiplier
SetEntityProofs (collision)Collision-proof from vehicles
SetPedCanRagdoll(false)Prevents being knocked down
SetPedCanBeKnockedOffVehicle(1)Cannot be pulled from vehicle
SetPedCanBeDraggedOut(false)Cannot be dragged from vehicle
SetPlayerCanBeHassledByGangs(false)Prevents NPC gang harassment
ClearPedBloodDamageRemoves blood effects
ResetPedVisibleDamageRemoves visible damage

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.

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 and proofs are removed
  5. Vehicle protection is removed
  6. Ragdoll physics are re-enabled

The cleanup runs immediately on exit with a comprehensive multi-pass sweep: ghosted players, ghosted entities, processed entities, all vehicles, all peds, and all objects in range are restored in a single operation.

See Also