red40_gangambush
Spice up your city with random NPC assaults on players. Spawn peds or vehicles to ambush your players for hanging out on other gangs turf.
Preview Video
Coming soon
Features
- Customizable zones for random gang ambushes
- Adjust ped models, weapons, and vehicles per zone
- Fully customizable loot system with metadata support
- XP support (open for integration)
- Exports and command support for triggering via other resources
- Locales for translations
Requirements
- ox_lib
- ox_target (other target require bridge code)
- QBX/QB/ESX
- Bridge files are open for other frameworks
Installation
- Unzip resource to your server resources
- Adjust configuration to your needs
Create or Modify zones
Open our zone tool
Draw a new polygon or square zone
Select that zone to open the details and copy the points section
Replace the points section in the zone
Copy the thickness section
Replace the thickness section in the zone
Config
---@class zoneConfig
---@field points vector3[] -- The points of the zone. Use https://zones.red40.dev/ to quickly build these.
---@field thickness number -- The thickness of the zone. Don't set this too high so underground ipls/houses are not included.
---@field rewards rewardConfig -- The rewards configuration for the zone
---@field vehicleRewards rewardConfig -- The vehicle rewards configuration for the zone
---@field xpPerLoot number -- The amount of XP gained per successful loot
---@field peds string[] -- The ped models that can spawn in this zone.
---@field maxPeds number -- The maximum number of peds that can spawn in this zone per attack, Setting this over the number of seats in the vehicle is not recommended.
---@field minPedsForVehicle number -- The minimum number of peds required to spawn a vehicle in this zone
---@field pedConfig pedConfig -- The configuration for the peds that can spawn in this zone
---@field vehicles? string[] -- The vehicle models that can spawn in this zone
---@field weapons string[] -- The weapon models that can spawn in this zone
---@field vehicleProps vehicleProps -- The properties of the vehicle that can spawn in this
---@field startHour number -- The hour at which the zone becomes active (0-23)
---@field endHour number -- The hour at which the zone becomes inactive (0-23)
---@field attackChance number -- The chance of an attack happening in this zone (0 to 100)
---@field announceWhenLive boolean -- Whether to announce when attacks are possible
---@field activeWhenPoliceOnDuty boolean -- Whether the zone is active when police are on duty
---@field spawnDelay number -- The delay in seconds before another attack can occur in this zone
---@field dispatchPolice boolean -- Whether to send a dispatch notice to police when an attack occurs
---@class vehicleProps
---@field color table<number, number, number> -- The color of the vehicle, an array of RGB values
---@class rewardConfig
---@field rewardMin number -- The minimum amount of items to be rewarded
---@field rewardMax number -- The maximum amount of items to be rewarded
---@field rewardItems table<rewardItem> -- The items to be rewarded
---@class rewardItem
---@field name string -- The name of the item
---@field metadata? table -- Metadata to be added to item (optional)
---@field chance number -- The chance of the item being rewarded (0.0 to 1.0)
---@field level number -- The level required to get this item
---@field min number -- The minimum amount of this item to be rewarded
---@field max number -- The maximum amount of this item to be rewarded
---@class pedConfig
---@field noReload boolean -- Whether the ped should not reload their weapon
---@field aggressiveness number -- The aggressiveness of the ped (1 to 3) higher is more aggressive
---@field health number -- The health of the ped
---@field armor number -- The armor of the ped (0 to 100)
---@field accuracy number -- The accuracy of the ped (0 to 100)
---@field alertness number -- The alertness of the ped (0 to 3)
---@field suffersHeadshots boolean -- Whether the ped suffers from headshots
---@type table<string, zoneConfig>
zones = {
vagos = {
points = {
vector3(279.15, -1860.64, 30),
vector3(131.88, -2038.58, 30),
vector3(364.87, -2172.58, 30),
vector3(492.35, -2049.56, 30)
},
thickness = 50,
rewards = {
rewardMin = 1,
rewardMax = 3,
rewardItems = {
{ name = 'ammo-9', chance = 0.9, min = 1, max = 4, level = 3 },
{ name = 'money', chance = 0.75, min = 50, max = 200, level = 1 },
{ name = 'WEAPON_PISTOL', chance = 0.25, min = 1, max = 1, level = 1 },
},
},
vehicleRewards = {
rewardMin = 1,
rewardMax = 1,
rewardItems = {
{ name = 'ammo-9', chance = 0.9, min = 1, max = 4, level = 3 },
{ name = 'money', chance = 0.75, min = 50, max = 200, level = 1 },
{ name = 'WEAPON_PISTOL', chance = 0.25, min = 1, max = 1, level = 1 },
}
},
peds = {
`G_M_Y_MexGoon_01`,
`G_M_Y_MexGoon_02`,
`G_M_Y_MexGoon_03`,
`G_M_Y_PoloGoon_01`,
`G_M_Y_PoloGoon_02`,
`G_F_Y_Vagos_01`
},
maxPeds = 4,
minPedsForVehicle = 3,
pedConfig = {
noReload = true,
aggressiveness = 3,
health = 200,
armor = 100,
accuracy = 90,
alertness = 3,
suffersHeadshots = false
},
vehicles = {
`primo2`
},
weapons = {
`WEAPON_PISTOL_MK2`,
`WEAPON_PISTOL`,
`WEAPON_MICROSMG`,
`WEAPON_MACHINEPISTOL`,
},
vehicleProps = {
color = { 255, 243, 63 },
},
xpPerLoot = 1,
announceWhenLive = false,
startHour = 20,
endHour = 6,
attackChance = 50,
activeWhenPoliceOnDuty = true,
spawnDelay = 300,
dispatchPolice = true,
},
}
Usage
/gangambush <zone> <pedCount> <target>
— Start an ambush either on yourself or another target/disableambush <cleanup>
— Disable ambushes server wide/disableambushzone <zone>
— Disable one ambush zone/cleanupgangambush
— Cleanup peds/vehicles from ambush (these are cleaned up automatically but this is provided if earlier cleanup is needed)
After downing the peds you can loot the vehicles and peds via target.
Exports
All exports are server side unless otherwise stated
startVehicleAttack
This export is used to start a vehicle attack on a given source with the zone configuration, spawn location, and ped count of your choice
Parameters
- source (number): The identifier to target the attack towards
- zone (string): The key from the configuration for the zone configuration you want to use
- coords (vec3): Coordinates to spawn the peds/vehicles at
- pedCount (number): Number of peds to spawn
Usage
exports.red40_gangambush:startVehicleAttack(1, 'vagos', vec3(100, 50, 20), 3)
startPedAttack
This export is used to start a ped attack on a given source with the zone configuration, spawn location, and ped count of your choice
Parameters
- source (number): The identifier to target the attack towards
- zone (string): The key from the configuration for the zone configuration you want to use
- coords (vec3): Coordinates to spawn the peds/vehicles at
- pedCount (number): Number of peds to spawn
Usage
exports.red40_gangambush:startPedAttack(1, 'vagos', vec3(100, 50, 20), 3)
disableAmbush
This export toggles the randomly generated ambushes. Returns true if disabled and false if enabled
Usage
exports.red40_gangambush:disableAmbush()
disableAmbushZone
This export toggles randomly generated ambushes per zone. Returns false if disabled and true if enabled.
Parameters
- zone (string): The key from the configuration for the zone configuration you want to disable/enable
Usage
exports.red40_gangambush:disableAmbushZone('vagos')
### cleanupAmbushes
This export cleans up the peds and vehicles spawned from the resource. This isn't needed as they will be cleaned up automatically.
#### Usaged
```lua copy
exports.red40_gangambush:cleanupAmbushes()
server.cfg
ensure red40_gangambush
or
ensure [red40]
Requirements
Last updated on