A comprehensive ranching simulation system for RedM servers, featuring realistic animal management, breeding, herding, and production mechanics.
- Multiple Animal Types: Cows (currently) : Bulls, Sheep, Pigs, and Horses (future) with unique behaviors
- Realistic Aging System: Visual scaling and stat progression over time
- Comprehensive Care: Health, hunger, and thirst management with automatic decay
- Breeding System: Full breeding mechanics with gestation periods and offspring
- Smart Spawning: Distance-based spawning/despawning for optimal performance
- 6 Pre-configured Ranches: Macfarlane, Emerald, Pronghorn, Downes, Hill Haven, Hanging Dog
- Job-based Access Control: Secure ranch access tied to RSG-Core job system
- Tiered Permissions: Trainee, Ranch Hand, and Manager roles with different capabilities
- Ranch Storage: Dedicated inventory system for feed and supplies
- Strategic Spawn Points: Optimized animal placement locations
- Multiple Herding Modes: Distance-based, type-based, and individual animal selection
- Visual Feedback: Real-time blips and indicators for herded animals
- Smart Controls: Configurable distances, speeds, and group limits
- Transport Mode: Maintains animal spawning during herding operations
- Command Integration: Easy-to-use
/herdcommand system
- Age-based Pricing: Smart pricing system (Young 50%, Prime 150%, Adult 100%, Old 70%)
- Multiple Markets: Strategic buy/sell points across the map
- Bulk Operations: Efficient handling of multiple animal transactions
- Configurable Prices: Server owners can adjust all pricing parameters
- Minimum Age Requirements: Prevents exploitation with age restrictions
- Automated Production: Animals generate resources (milk, wool, bacon, horsehair) over time
- Health Requirements: Production tied to animal welfare stats
- Breeding Mechanics: Realistic gestation periods and breeding cooldowns
- Gender System: Proper male/female ratios and breeding compatibility
- Automatic Breeding: Optional hands-off breeding for busy ranchers
- Optimized Database: Indexed queries and efficient data structures
- Debug System: Comprehensive logging and troubleshooting tools
- Automatic Cleanup: Built-in systems to prevent data corruption
- Scalable Architecture: Handles multiple ranches and hundreds of animals
- Real-time Sync: All players see consistent animal states
- RSG Framework (Required - core framework)
- ox_lib (Required - UI and utility library)
- oxmysql (Required - MySQL database connector)
- ox_target (Required - NPC and entity interactions)
- rsg-inventory (Required - inventory system integration)
- MySQL/MariaDB database
- Lua 5.4 support enabled in server
- Minimum 4GB RAM for optimal performance
# Download the rex-ranch resource
# Extract to: server/resources/rex-ranch/
# Ensure the folder name is exactly 'rex-ranch'- Import the main table:
-- Execute in your MySQL database
source path/to/rex-ranch/installation/rex-ranch.sql- Add to server.cfg:
# Resource loading (ensure dependencies load first)
ensure rex-ranchAdd ranch jobs to your rsg-core\shared\jobs.lua
Add ranch items to your rsg-core\shared\items.lua
Edit shared/config.lua to customize:
Config.Debug = false -- Enable debug mode for troubleshooting
Config.MaxRanchAnimals = 10 -- Maximum animals per ranch
Config.AnimalCronJob = '0 * * * *' -- Stat decay frequency (every hour)
Config.BuyPointSpawnDistance = 8.0 -- Distance from buy point where animals spawnModify ranch locations in Config.RanchLocations:
{
name = 'Custom Ranch',
ranchid = 'customranch',
coords = vector3(x, y, z),
npcmodel = `g_m_m_uniranchers_01`,
npccoords = vector4(x, y, z, heading),
jobaccess = 'customranch', -- Job required to access this ranch
spawnpoint = vector4(x, y, z, heading) -- Where animals spawn
}Adjust prices in Config.BaseSellPrices:
Config.BaseSellPrices = {
['a_c_cow'] = 150,
['a_c_sheep_01'] = 80,
['a_c_pig_01'] = 100,
['a_c_horse_americanpaint_greyovero'] = 300
}Configure animal production in Config.AnimalProducts:
['a_c_cow'] = {
product = 'milk',
productionTime = 3600, -- every hour in seconds
amount = 1,
requiresHealth = 60, -- minimum health to produce
requiresHunger = 40, -- minimum hunger to produce
requiresThirst = 40 -- minimum thirst to produce
}-
Obtain Ranch Job: Get assigned a ranch job from an admin
-
Find Your Ranch: Look for ranch blips on your map or visit these locations:
- Macfarlane Ranch: New Austin region
- Emerald Ranch: Heartlands region
- Pronghorn Ranch: Hennigan's Stead
- And more...
-
Animal Purchase & Management:
- Visit livestock dealers to buy animals
- Animals spawn near the dealer for pickup
- Use
/herdcommand to move animals to your ranch - Feed animals with
animal_feeditems - Water animals with
water_bucketitems - Monitor animal health, hunger, and thirst stats
-
Herding System:
/herd - Opens the herding menu Herding Options: - Distance-based: All animals within range - Type-based: Select specific animal types - Individual: Choose specific animals -
Production & Sales:
- Collect products from healthy, well-fed animals
- Products: milk (cows), wool (sheep), bacon (pigs), horsehair (horses)
- Sell mature animals at livestock markets
- Age affects pricing: Young (50%), Prime (150%), Adult (100%), Old (70%)
-
Breeding System:
- Healthy animals will automatically breed when conditions are met
- Gestation periods vary by animal type
- Monitor breeding cooldowns and pregnancy status
-
Ranch Storage:
- Access ranch storage for feed and supplies (Manager+ only)
- Organize inventory for efficient ranch operations
-- Assign ranch jobs
/setjob [player_id] [ranch_name] [grade]
-- Example: Make player ID 1 a manager at Macfarlane Ranch
/setjob 1 emeraldranch 0 -- Trainee Rancher
/setjob 1 emeraldranch 1 -- Ranch Hand
/setjob 1 emeraldranch 2 -- Ranch Manager- Performance Monitoring: Check server console for animal spawn/despawn logs
- Database Health: Monitor
rex_ranch_animalstable for corruption - Configuration Tuning: Adjust settings in
shared/config.luaas needed - Debug Mode: Enable
Config.Debug = truefor detailed logging
- Adjust animal limits per ranch:
Config.MaxRanchAnimals - Modify pricing:
Config.BaseSellPricesandConfig.AgePricing - Change production timers:
Config.AnimalProducts - Configure breeding settings:
Config.BreedingConfig
๐ด Problem: Animals don't appear after purchase/restart
โ
Solutions:
1. Verify player has correct ranch job: /job [player_id]
2. Check database connection in server console
3. Ensure Config.Debug = true and check spawn logs
4. Verify animal spawn points are not obstructed
5. Check for conflicting animal resources
6. Restart resource: refresh rex-ranch
๐ด Problem: Server lag, low FPS near ranches
โ
Solutions:
1. Reduce Config.MaxRanchAnimals (default: 10)
2. Increase Config.AnimalDistanceSpawn for better culling
3. Set Config.Debug = false in production
4. Adjust Config.AnimalCronJob frequency
5. Monitor MySQL performance and optimize queries
๐ด Problem: Pricing too high/low, exploits
โ
Solutions:
1. Adjust Config.BaseSellPrices for your server economy
2. Modify Config.AgePricing multipliers
3. Change Config.MinAgeToSell to prevent quick flipping
4. Adjust production times in Config.AnimalProducts
5. Monitor Config.MaxRanchAnimals to prevent oversupply
๐ด Problem: /herd command not working, animals won't follow
โ
Solutions:
1. Verify player has ranch job access
2. Check Config.HerdingEnabled = true
3. Ensure animals are within Config.HerdingDistance
4. Verify ox_target dependency is loaded
5. Check for conflicting resources affecting animal entities
Enable comprehensive logging:
-- In shared/config.lua
Config.Debug = true
-- Console output will show:
-- Animal spawning/despawning events
-- Database query results
-- Breeding system status
-- Production timing
-- Herding operations-- Check for corrupted animal data
SELECT * FROM rex_ranch_animals WHERE
pos_x IS NULL OR pos_y IS NULL OR pos_z IS NULL OR
health < 0 OR health > 100 OR
hunger < 0 OR hunger > 100 OR
thirst < 0 OR thirst > 100;
-- Clean up old/invalid animals
DELETE FROM rex_ranch_animals WHERE
born < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 365 DAY));-- Performance Tuning
Config.MaxRanchAnimals = 10 -- Animals per ranch
Config.AnimalDistanceSpawn = 50.0 -- Spawn distance
Config.AnimalCronJob = '0 * * * *' -- Hourly stat decay
-- Economy Balancing
Config.BaseSellPrices = {
['a_c_cow'] = 150, -- Base cow price
['a_c_bull_01'] = 400 -- Base bull price
}
Config.AgePricing = {
young = 0.5, -- 50% of base price
prime = 1.5, -- 150% of base price
adult = 1.0, -- 100% of base price
old = 0.7 -- 70% of base price
}
-- Production Settings
Config.AnimalProducts = {
['a_c_cow'] = {
product = 'milk',
productionTime = 21600, -- 6 hours
requiresHealth = 50,
requiresHunger = 30,
requiresThirst = 30
}
}-
โจ New Features:
- Advanced herding system with multiple selection modes
- Comprehensive breeding mechanics with gestation periods
- Automatic breeding system for hands-off ranch management
- Enhanced production system with health requirements
- Performance-optimized animal spawning
-
๐ง Improvements:
- Database schema optimization with proper indexing
- Real-time animal synchronization across clients
- Enhanced debug system with detailed logging
- Improved error handling and validation
- Scalable architecture supporting hundreds of animals
-
๐ Bug Fixes:
- Fixed animal duplication issues
- Resolved performance problems with large herds
- Corrected breeding cooldown calculations
- Fixed production timer synchronization
- Enable Debug Mode:
Config.Debug = truefor detailed logs - Check Dependencies: Ensure all required resources are loaded
- Review Documentation: WARP.md contains technical details
- Monitor Console: Server console shows detailed error messages
This resource welcomes community contributions:
- Report bugs and issues
- Suggest feature improvements
- Share configuration optimizations
Rex Ranch v2.0.x - A comprehensive ranching simulation for RedM
Built by RexShack for the RedM community with โค๏ธ
Transform your server into the ultimate Wild West ranching experience! ๐ค ๐๐พ