gear-codeExports

Client Side Exports

1. spawnZombies

  • spawnZombies(zombieType, coords, count)

    • Spawns zombies at the given location.

    • Arguments:

      • zombieType (string): Zombie type name from Config.types (e.g., "default", "screamer", "exploder").

      • coords (vector3): Where to spawn the zombies.

      • count (number, optional): How many zombies to spawn. Default is 1.

    • Returns: Nothing.

    • Usage: Use this from other scripts to spawn zombies for events, missions, etc.

    • Example:

      -- Spawn one default zombie
      exports['5s_zombies']:spawnZombies('default', vector3(100.0, 200.0, 30.0))
      
      -- Spawn 5 exploders
      exports['5s_zombies']:spawnZombies('exploder', vector3(150.0, 250.0, 35.0), 5)
      
      -- Spawn a screamer near the player
      exports['5s_zombies']:spawnZombies('screamer', GetEntityCoords(PlayerPedId()) + vector3(10.0, 0.0, 0.0), 1)
    • Notes:

      • zombieType must exist in Config.types or you will see a warning.

      • coords must be a valid vector3.

      • Zombies spawn with a small offset between them so they don't overlap.

      • Spawn animations play automatically (except for animal types).


2. getZombieCount

  • getZombieCount()

    • Returns the number of zombies near the player (in render/tracking distance).

    • Arguments: None.

    • Returns: number - count of nearby zombies.

    • Usage: Use this to display zombie count on a HUD, scale difficulty, or trigger events based on nearby threat level.

    • Example:


3. isInGreenZone

  • isInGreenZone()

    • Checks if the player is inside a safe zone.

    • Arguments: None.

    • Returns: boolean - true if in a safe zone, false if not.

    • Usage: Use this to enable or disable features depending on whether the player is safe.

    • Example:

    • Notes:

      • Safe zones are set in Config.zones.safeZones.

      • Checks the player's current position.


4. isInDangerZone

  • isInDangerZone()

    • Checks if the player is inside a danger zone.

    • Arguments: None.

    • Returns: boolean - true if in a danger zone, false if not.

    • Usage: Use this to trigger special effects or UI when the player enters a danger zone.

    • Example:

    • Notes:

      • Danger zones are set in Config.zones.dangerZones.

      • These zones have more zombies and special enemy types.


5. isIgnoredByZombies

  • isIgnoredByZombies()

    • Checks if the local player is currently ignored by all zombies.

    • Arguments: None.

    • Returns: boolean - true if ignored, false if not.

    • Usage: Use this to check if the player is in a "safe" state set by the server (e.g., during a cutscene, in admin mode, etc.).

    • Example:

    • Notes:

      • This state is set server-side via setIgnoredByZombies. See server exports.


6. addNoSpawnZone

  • addNoSpawnZone(id, coords, radius)

    • Registers a no-spawn zone. Zombies will not spawn at coordinates inside this zone.

    • Arguments:

      • id (string): Unique identifier for this zone (e.g., "myresource:zone_1").

      • coords (vector3): Center of the no-spawn zone.

      • radius (number): Radius in meters.

    • Returns: Nothing.

    • Usage: Use this to prevent zombie spawns around player bases, event areas, or other protected locations. Unlike safe zones (which affect player state), no-spawn zones only prevent zombies from spawning at those coordinates.

    • Example:

    • Notes:

      • The id must be unique. If you call this again with the same id, it overwrites the previous zone.

      • This is used internally by 5s_building to protect Tool Cupboard areas.


7. removeNoSpawnZone

  • removeNoSpawnZone(id)

    • Removes a previously registered no-spawn zone.

    • Arguments:

      • id (string): The same identifier used when adding the zone.

    • Returns: Nothing.

    • Example:


Server Side Exports

1. setIgnoredByZombies

  • setIgnoredByZombies(source, ignored)

    • Makes a player invisible to all zombies, or restores normal detection.

    • Arguments:

      • source (number): Player server ID.

      • ignored (boolean): true to ignore, false to restore.

    • Returns: Nothing.

    • Usage: Use this for admin godmode, cutscenes, safe trader NPCs, spawn protection, or any scenario where a player should not be targeted.

    • Example:


2. isIgnoredByZombies

  • isIgnoredByZombies(source)

    • Checks if a player is currently ignored by zombies.

    • Arguments:

      • source (number): Player server ID.

    • Returns: boolean - true if ignored, false if not.

    • Example:


3. setSpawnsPaused

  • setSpawnsPaused(source, paused)

    • Pauses or resumes zombie spawning around a specific player. When paused, no new zombies will be spawned for this player's sector.

    • Arguments:

      • source (number): Player server ID.

      • paused (boolean): true to pause, false to resume.

    • Returns: Nothing.

    • Usage: Use this during loading screens, character selection, instanced interiors, or any time you want to temporarily stop zombie spawns for a player.

    • Example:


4. getPlayersInDangerZone

  • getPlayersInDangerZone(zoneId)

    • Returns a list of players currently inside a danger zone.

    • Arguments:

      • zoneId (number): The index of the danger zone in Config.zones.dangerZones (1-based).

    • Returns: table - array of player server IDs, or empty table if none.

    • Usage: Use this for zone-based events, leaderboards, or scaling difficulty based on player count.

    • Example:


5. overrideSquareMultiplier

  • overrideSquareMultiplier(squareId, multiplier)

    • Overrides the spawn multiplier for a specific map sector. This stacks with zone archetype and night multipliers.

    • Arguments:

      • squareId (number): The sector ID (from the grid system).

      • multiplier (number): Spawn count multiplier (e.g., 2.0 for double spawns, 0.0 to disable spawns).

    • Returns: Nothing.

    • Usage: Use this for dynamic events - increase spawns during a horde event, or reduce spawns in a cleared area.

    • Example:


6. getSquareMultiplier

  • getSquareMultiplier(squareId)

    • Gets the current spawn multiplier override for a map sector.

    • Arguments:

      • squareId (number): The sector ID.

    • Returns: number - current multiplier (default 1.0 if not overridden).

    • Example:


7. getZombieCountInSquare

  • getZombieCountInSquare(squareId)

    • Returns the number of zombies currently alive in a map sector.

    • Arguments:

      • squareId (number): The sector ID.

    • Returns: number - zombie count in that sector.

    • Usage: Use this for monitoring server load, balancing events, or displaying zone population.

    • Example:


8. getPlayerSquare

  • getPlayerSquare(source)

    • Returns the map sector ID a player is currently in.

    • Arguments:

      • source (number): Player server ID.

    • Returns: number | nil - sector ID, or nil if the player hasn't entered a sector yet.

    • Usage: Use this with other sector-based exports like getZombieCountInSquare or overrideSquareMultiplier.

    • Example:


Last updated