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.jsonfileZone Notifications: Beautiful UI notifications when entering/exiting zones
📋 Requirements
RedM Server (Beta 1491+)
Supported Frameworks: VORP, RedEM, RSG or Standalone
🛠️ Installation
⚙️ 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
Managing Zones
View Zones:
/zone list- Lists all zones in chatDelete 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 marker23- Hollow circle25- Ring marker28- Cylinder marker (recommended)
Framework Detection
The script automatically detects your framework. Supported frameworks:
VORP:
vorp_coreRedEM:
redem_roleplayorredemRSG:
rsg-coreStandalone: 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
Zones Not Loading
Check
zones.jsonfile exists and is valid JSONCheck console for error messages
Verify zones.json is in resource folder
Markers Not Showing
Check
Config.DrawZones = trueVerify marker type is correct (try type 28)
Check
Config.DrawDistanceis large enoughEnsure you're within draw distance
Weapons Not Auto-Holstering
Check
Config.SafeZoneWeaponsDisabled = trueVerify you're actually in a safe zone
Check framework detection is working
Admin Commands Not Working
Verify admin group in
Config.AdminGroupsCheck framework admin detection
For standalone, verify ACE permissions
Discord Webhook Not Working
Verify webhook URL is correct
Check Discord permissions
Ensure
Config.LogPunishments = true
Framework Not Detected
Check framework resource is started
Verify framework name matches exactly
Check console for detection messages
UI Not Opening
Check resource is started
Verify
fxmanifest.luais correctCheck F8 console for errors
Ensure NUI files are in
nui/folder
📝 Commands
/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 adminFramework.RemoveMoney(source, amount)- Remove money from playerFramework.SendToJail(source, time)- Send player to jailFramework.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
🔄 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
DrawDistancefor larger zonesPerformance: Disable
DrawZonesif not needed for better performanceBackup Zones: Backup
zones.jsonfile regularlyAdmin UI: Use
/zoneuifor easier zone managementTesting: 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