Skip to main content
A powerful, modular and fully configurable RedM script designed to give server owners complete control over AI relationship behavior, ambient spawn density, location-based ped restrictions, and visual model overrides. Whether you want immersive faction conflicts, living town behaviors, or optimized performance zones — this script is your all-in-one solution.
This script provides comprehensive control over AI relationships, spawn frequencies, location restrictions, and visual model replacements to create immersive and optimized server environments.

Features

Relationship Control

Define default AI-to-AI relationships globally, configure group behaviors toward players, and set conditional rules based on time, job, weather, and more.

Spawn Frequency Management

Globally control ped, animal, and traffic spawn density with area-specific overrides for different zones and events.

Volume-Based Restrictions

Define boxes or spheres to control AI spawn types in key locations, blocking specific ped types like dangerous animals, town NPCs, lawmen, and birds.

Model Replacements

Replace the visual appearance of specific peds in defined areas while maintaining original model logic for animations and behavior.

Debugging Tools

Toggle debug mode for verbose logs and define custom conditions as Lua functions directly in the configuration.

Framework Integration

Compatible with VORP Core and RSG Core frameworks with modular framework bridge support.

Installation

1

Download

Get the latest release from our Tebex Store and download it from your Keymaster
2

Extract

Extract the spooni_ambientPedManager folder to your server’s resources directory
3

Configure

Add ensure spooni_ambientPedManager to your server.cfg
4

Customize

Edit config.lua to match your server logic and requirements

Configuration

The script is highly configurable through the config.lua file. Here are the main configuration sections:

Relationship Types

Define the numeric values for each relationship type:
-- Relationship type definitions
RelationshipTypes = {
    HATE = 6,
    DISLIKE = 4,
    IGNORE = 3,
    LIKE = 2,
    RESPECT = 1,
    NONE = 0
}

Group Relationships

Set static relationships between two AI groups:
-- Define how AI groups interact with each other
GroupRelationships = {
    rel_civmale = {
        rel_civfemale = "LIKE",
        rel_vanhorn_citizen = "HATE"
    },
    rel_cop = {
        rel_civmale = "RESPECT",
        rel_civfemale = "RESPECT"
    }
    -- Add more group relationships as needed
}

Player Relations

Configure how groups behave around the player:
-- Player relationship configuration
PlayerRelations = {
    Enabled = true,
    BehaviorAroundPlayer = {
        rel_cop = "RESPECT",
        rel_civmale = "LIKE",
        rel_civfemale = "LIKE"
    }
}

Conditional Rules

Dynamic rules based on game context (time, job, weather, etc.):
-- Conditional relationship rules
ConditionalRules = {
    {
        condition = function()
            return GetClockHours() >= 20 or GetClockHours() <= 5
        end,
        between = { "player", "rel_civmale" },
        relation = "HATE"
    },
    {
        condition = function()
            return IsPedInAnyVehicle(PlayerPedId(), false)
        end,
        between = { "rel_cop", "rel_civmale" },
        relation = "RESPECT"
    }
    -- Add more conditional rules as needed
}
Use "player" in conditional rules to dynamically resolve the player’s group. The rel_cop group maintains persistent relationships via background loop.

Spawn Frequency

Set global ambient spawn values (0.0–1.0):
-- Global spawn frequency settings
spawnFrequency = {
    pedFrequency = 1.0,      -- General ped spawn rate
    humanFrequency = 0.5,    -- Human ped spawn rate
    animalFrequency = 1.0,   -- Animal spawn rate
    trafficFrequency = 0.0   -- Vehicle traffic spawn rate
}

Location-Specific Spawn Frequency

Area-specific spawn density overrides:
-- Location-based spawn frequency overrides
spawnFrequencyLocations = {
    huntingEvent = {
        coords = { x = -1500.0, y = 500.0, z = 100.0 },
        radius = 1500.0,
        humanFrequency = 0.0,    -- No humans in hunting area
        animalFrequency = 1.0    -- Maximum animals for hunting
    },
    townCenter = {
        coords = { x = -300.0, y = 800.0, z = 120.0 },
        radius = 200.0,
        humanFrequency = 1.0,    -- High human activity
        animalFrequency = 0.0    -- No animals in town center
    }
    -- Add more location-specific settings
}

Location Restrictions

Restrict or allow ped types in volumes (box or sphere):
-- Volume-based ped restrictions
locationRestrictions = {
    BlackWaterSaloon = {
        volumeName = "volumeBlackWaterSaloonAmbientRestriction",
        coords = { x = -800.0, y = -1300.0, z = 45.0 },
        disallowHumanPeds = { disallowAll = true },
        disallowAnimalPeds = { disallowAll = true }
    },
    HuntingZone = {
        volumeName = "volumeHuntingZoneRestriction",
        coords = { x = -1500.0, y = 500.0, z = 100.0 },
        disallowHumanPeds = { disallowAll = true },
        allowAnimalPeds = { allowAll = true }
    }
    -- Add more location restrictions
}

Model Replacements

Replace ped appearances visually in a zone:
-- Visual model replacement settings
modelReplacements = {
    armadilloTownfolk = {
        coords = { x = -3500.0, y = -2000.0, z = 150.0 },
        radius = 90.0,
        targetModels = { 'A_M_M_ARMTOWNFOLK_01' },
        replacementModels = { 's_m_m_ambientsdpolice_01' }
    },
    valentineLawmen = {
        coords = { x = -300.0, y = 800.0, z = 120.0 },
        radius = 150.0,
        targetModels = { 'A_M_M_VALPROSPECTOR_01' },
        replacementModels = { 'S_M_M_VALGUNSMITH_01' }
    }
    -- Add more model replacements
}
Model types must match (e.g., human with human, horse with horse). Model replacements only affect visual appearance, not base behavior.

Advanced Configuration

Custom Conditions

Define custom conditions as Lua functions directly in the config:
-- Example custom conditions
CustomConditions = {
    isNightTime = function()
        local hour = GetClockHours()
        return hour >= 22 or hour <= 6
    end,
    
    isRaining = function()
        return GetPrevWeatherTypeHashName() == GetHashKey("RAIN")
    end,
    
    playerInVehicle = function()
        return IsPedInAnyVehicle(PlayerPedId(), false)
    end
}

Debug Mode

Enable verbose logging for development:
-- Debug configuration
Config.debug = true
Config.ConditionCheckTimer = 1000  -- Check interval in milliseconds

Usage Examples

Creating Faction Conflicts

-- Example: Van Horn vs Saint Denis citizens
GroupRelationships = {
    rel_vanhorn_citizen = {
        rel_saintdenis_citizen = "HATE"
    },
    rel_saintdenis_citizen = {
        rel_vanhorn_citizen = "HATE"
    }
}

Time-Based Behavior

-- Example: Lawmen more aggressive at night
ConditionalRules = {
    {
        condition = function()
            return GetClockHours() >= 22 or GetClockHours() <= 6
        end,
        between = { "rel_cop", "player" },
        relation = "DISLIKE"
    }
}

Event Zones

-- Example: Hunting event area
spawnFrequencyLocations = {
    huntingEvent = {
        coords = { x = -1500.0, y = 500.0, z = 100.0 },
        radius = 1500.0,
        humanFrequency = 0.0,
        animalFrequency = 1.0,
        pedFrequency = 0.0
    }
}

Performance Considerations

The script is optimized for performance with several key features:
  • Conditional Checking: Configurable tick rate via ConditionCheckTimer
  • Volume-Based Restrictions: Efficient area-based ped control
  • Selective Spawning: Location-specific spawn density management
  • Background Processing: Persistent relationship maintenance for critical groups

Performance Tips

  • Check Timer: Increase ConditionCheckTimer for less frequent condition checks
  • Volume Optimization: Use appropriate volume sizes for restrictions
  • Spawn Limits: Set reasonable spawn frequencies to prevent performance issues
  • Debug Mode: Disable debug mode in production for optimal performance

Troubleshooting

Verify group names are correct, check that conditional functions return proper boolean values, and ensure the script is properly started in your server.cfg.
Confirm volume names exist in the game map or are manually created, check coordinate accuracy, and verify spawn frequency values are between 0.0 and 1.0.
Ensure model types match (human with human, animal with animal), verify coordinates and radius are correct, and check that target models exist in your server.
Reduce condition check frequency, limit the number of conditional rules, optimize volume sizes, and disable debug mode in production.
Verify volume names are valid, check coordinate positioning, and ensure the volume is properly defined in the game world or created manually.

Framework Integration

The script includes built-in support for multiple frameworks:
-- Automatically detected when vorp_core is running
-- No additional configuration required

Limitations

Be aware of the following limitations when configuring the script:
  • Volume Names: Volume names must exist in the game map or be manually created
  • Model Replacements: Only affect visual appearance, not base behavior
  • Relationship Persistence: Only rel_cop and player relationships are enforced continuously
  • Condition Functions: Must return boolean values and be properly formatted

Support

If you encounter issues or need assistance:
I