CodeRanch - Zone System

Advanced Safe Zone & Law Zone System for RedM

This script provides a comprehensive zone management system for RedM servers. Create safe zones where weapons are prohibited, law zones with enforcement rules, and custom zones with special rules. Features an intuitive admin UI with old western design theme.

🚀 Features

  • Multi-Zone Types: Safe zones, Law zones, and Custom zones

  • Automatic Weapon Detection: Forces players to holster weapons in safe zones

  • PvP Protection: Disables PvP and damage in safe zones

  • Visual Markers: Draw markers on map showing zone boundaries

  • Admin Management UI: Beautiful old western themed admin interface

  • Multi-Framework Support: VORP, RedEM, RSG and Standalone

  • Discord Integration: Log zone violations and admin actions

  • Punishment System: Fine, jail, or auto-holster for law zone violations

  • 3D Text Display: Shows zone names and types above zones

  • Sound Effects: Audio feedback on zone enter/exit

  • JSON Storage: Zones saved to zones.json file

  • Zone Notifications: Beautiful UI notifications when entering/exiting zones

📋 Requirements

  • RedM Server (Beta 1491+)

  • Supported Frameworks: VORP, RedEM, RSG or Standalone

🛠️ Installation

1

Download Files

Copy the resource to your server's resources folder:

2

Server.cfg Settings

Add framework dependencies (only add the ones you use) and ensure the safe zones resource:

3

Configuration

Edit config.lua file according to your server's needs.

⚙️ Configuration

Zone Check Settings

Safe Zone Settings

Law Zone Settings

Admin Permissions

Zone Drawing Settings

Sound Settings

Discord Integration

Zone Messages

Default Zones

🎮 Usage

For Admins

Creating a Zone

1

Create via Command

Command: /zone create [safe/law/custom] Example: /zone create safe — Opens UI at your current position

2

Create via UI

Command: /zoneui — Opens the admin management UI

In the UI:

  • Click "Claim New Territory"

  • Fill in zone details:

    • Territory Name: Name of the zone

    • Territory Classification: Safe, Law, or Custom

    • Territory Range: Radius in meters

    • Map Coordinates: X, Y, Z coordinates

  • Click "Claim Territory"

Managing Zones

  • View Zones: /zone list - Lists all zones in chat

  • Delete Zone: Use UI or /zone delete [name]

  • Teleport to Zone: Click "Teleport" button in UI

  • Update Zone: Modify zone in UI (future feature)

Zone Types

Safe Zone

  • Weapons automatically holstered

  • PvP disabled

  • Players are invincible

  • No weapon violations logged

Law Zone

  • Warning given when weapon drawn

  • Punishment applied after warning time

  • Fine, jail, or auto-holster punishment

  • Violations logged to Discord

Custom Zone

  • Custom rules can be applied

  • Base zone functionality

  • Can be extended with custom rules

For Players

  • Automatic Detection: Zones are automatically detected when entering

  • Notifications: Receive notifications when entering/exiting zones

  • Weapon Auto-Holster: Weapons automatically holstered in safe zones

  • Visual Markers: See zone boundaries with colored markers

  • 3D Text: Zone names displayed above zones when nearby

🔧 Advanced Settings

Adding Custom Zone Rules

Changing Marker Types

Common marker types for RedM:

  • 1 - Circle marker

  • 23 - Hollow circle

  • 25 - Ring marker

  • 28 - Cylinder marker (recommended)

Framework Detection

The script automatically detects your framework. Supported frameworks:

  • VORP: vorp_core

  • RedEM: redem_roleplay or redem

  • RSG: rsg-core

  • Standalone: Uses ACE permissions

Admin Permissions (Standalone)

🎨 UI Features

Admin Interface

  • Western Theme: Beautiful old western design

  • Zone List: View all active zones

  • Zone Creation: Easy zone creation form

  • Zone Management: Delete, teleport, and manage zones

  • Real-time Coordinates: Get your current coordinates

  • Visual Indicators: Color-coded zone types

Zone Notifications

  • Enter Notification: Shows when entering a zone

  • Exit Notification: Shows when leaving a zone

  • Zone Type Badges: Visual indicators for zone types

  • Western Design: Matches admin UI theme

📊 Zone Storage

Zones are stored in zones.json file in the resource folder. Structure:

🐛 Troubleshooting

Common Issues

chevron-rightZones Not Loadinghashtag
  • Check zones.json file exists and is valid JSON

  • Check console for error messages

  • Verify zones.json is in resource folder

chevron-rightMarkers Not Showinghashtag
  • Check Config.DrawZones = true

  • Verify marker type is correct (try type 28)

  • Check Config.DrawDistance is large enough

  • Ensure you're within draw distance

chevron-rightWeapons Not Auto-Holsteringhashtag
  • Check Config.SafeZoneWeaponsDisabled = true

  • Verify you're actually in a safe zone

  • Check framework detection is working

chevron-rightAdmin Commands Not Workinghashtag
  • Verify admin group in Config.AdminGroups

  • Check framework admin detection

  • For standalone, verify ACE permissions

chevron-rightDiscord Webhook Not Workinghashtag
  • Verify webhook URL is correct

  • Check Discord permissions

  • Ensure Config.LogPunishments = true

chevron-rightFramework Not Detectedhashtag
  • Check framework resource is started

  • Verify framework name matches exactly

  • Check console for detection messages

chevron-rightUI Not Openinghashtag
  • Check resource is started

  • Verify fxmanifest.lua is correct

  • Check F8 console for errors

  • Ensure NUI files are in nui/ folder

📝 Commands

Command
Permission
Description

/zone create [type]

Admin

Create zone at current position

/zone delete [name]

Admin

Delete a zone

/zone list

Admin

List all zones

/zoneui

Admin

Open admin management UI

🔄 Framework Functions

Server Functions

  • Framework.IsAdmin(source) - Check if player is admin

  • Framework.RemoveMoney(source, amount) - Remove money from player

  • Framework.SendToJail(source, time) - Send player to jail

  • Framework.Notify(source, message, type) - Send notification

Client Functions

  • Automatic weapon holster detection

  • Zone entry/exit detection

  • 3D marker rendering

  • UI management

🎯 Performance Optimization

The script includes performance optimizations:

  • Debounced Zone Rendering: Prevents excessive re-renders

  • Zone Caching: Only updates when zones change

  • Efficient DOM Manipulation: Uses DocumentFragment for better performance

  • Event Delegation: Single event listener for zone actions

  • CSS Optimizations: Hardware-accelerated animations

  • Render Optimization: Only renders zones within draw distance

🔐 Security

  • Server-side permission checks

  • Admin-only zone creation/deletion

  • Framework-based admin detection

  • ACE permission support for standalone

  • Input validation on zone data

📄 File Structure

🎨 UI Customization

1

Colors

Edit CSS variables in nui/style.css to change colors.

2

Fonts

Change Google Fonts imports in nui/index.html to update fonts.

3

Layout

Modify HTML structure in nui/index.html to change layout.

4

Icons

The UI uses Lucide icons (change in nui/script.js).

🔄 Updates

v1.0.0

  • Initial release

  • Safe zone and law zone support

  • Admin management UI

  • Multi-framework support

  • Discord integration

  • Visual markers and 3D text

  • Performance optimizations

💡 Tips

  • Zone Placement: Place zone centers at ground level for best marker visibility

  • Radius Size: Recommended radius: 100-300 meters

  • Zone Overlap: Zones can overlap, player enters the first zone detected

  • Marker Distance: Increase DrawDistance for larger zones

  • Performance: Disable DrawZones if not needed for better performance

  • Backup Zones: Backup zones.json file regularly

  • Admin UI: Use /zoneui for easier zone management

  • Testing: Test zones in safe areas before deploying


Note: This script is developed for RedM Beta version. Incompatibilities may occur in RedM's official release.

Support: For issues or questions, contact CodeRanch support.

Last updated