Introduction
The RSG Weapons system (rsg-weapons) manages weapon durability, damage, repairs, and ammunition in the RSG Framework. It works seamlessly with rsg-inventory to provide a realistic weapon experience.
Version: 2.1.4
rsg-weapons is tightly integrated with rsg-inventory. Weapons are stored as inventory items with type
'weapon'.Core Features
🔧 Weapon Durability
- Weapons degrade with use (each shot reduces quality)
- Quality ranges from 0-100%
- Weapons at 0% quality become unusable
- Can be repaired using weapon repair kits
💥 Custom Weapon Damage
- Each weapon has configurable damage multipliers
- Separate from native RedM damage values
- Critical hits can be disabled server-wide
🔫 Weapon Components
- Toggle system for weapon components/attachments
- Supports custom weapon loading
🛠️ Repair System
- Useable repair kits restore weapon quality to 100%
- Repair time configurable (default: 30 seconds)
How Weapons Work
Weapon as Inventory Item
Weapons are stored in the inventory system with special properties:Every weapon gets a unique serial number automatically when added to inventory. This allows tracking and differentiating between identical weapons.
Configuration
Weapon Degradation Settings
Located inconfig.lua:
- Revolver with 6 shots = 0.06 quality lost per full cylinder
- Takes approximately 1,667 shots to degrade from 100% to 0%
Repair Time
Weapon Components
false, players can use the /loadweapon command to equip weapons.
Weapon Damage
Each weapon has a damage multiplier:1.0= Normal damage1.5= 50% more damage0.5= 50% less damage
Disable Critical Hits
Weapon Degradation System
How It Works
- Player fires weapon
- Client tracks shots in a degradation queue
- Queue sent to server periodically (every 5 seconds)
- Server updates weapon quality based on shots fired
Quality Breakpoints
- 100-75%: Excellent Condition (Green)
- 74-50%: Good Condition (Yellow)
- 49-25%: Poor Condition (Orange)
- 24-1%: Very Poor Condition (Red)
- 0%: Broken - Weapon Unusable
Weapon Repair System
Using Repair Kits
Players can repair weapons using theweapon_repair_kit item:
- Player uses repair kit from inventory
- Player selects which weapon to repair
- Progress bar shows repair in progress
- Weapon quality restored to 100%
- Repair kit consumed
Item Definition
Inrsg-core/shared/items.lua:
Server-Side Repair
Weapon Information System
Get Weapon Info by Serial
Admin Commands
Infinite Ammo
Admins can toggle infinite ammo:Integration with Inventory
Adding Weapons to Inventory
When adding weapons, a serial number is automatically generated:Serial numbers are automatically generated by rsg-inventory when adding weapon-type items!
Removing Weapons
When removing weapons, use the weapon’s serial to target specific weapons:Database Structure
player_weapons Table
This table is used for tracking weapon ownership history and can be used for law enforcement RP.
Practical Examples
Example 1: Give Player a Weapon
Example 2: Confiscate Weapons
Example 3: Weapon Damage Check
Example 4: Custom Weapon Shop
Best Practices
Make repair kits accessible: Ensure players can obtain repair kits reasonably
Performance Tips
- Degradation batching: Shots are queued and processed in batches (every 5 seconds)
- Don’t check quality every frame: Only check when weapon is actually used
- Cache weapon data: Don’t repeatedly query the same weapon information
Balancing Tips
- Degrade rate: 0.01 per shot is a good baseline (1% per 100 shots)
- Repair kit availability: Balance cost vs weapon prices
- Quality thresholds: Consider adding effects at different quality levels
- Ammo economy: Balance ammo costs with weapon upkeep costs
Common Issues
Weapon Not Degrading
Check Config.DegradeRate
Check Config.DegradeRate
Ensure
Config.DegradeRate is not set to 0Check UpdateDegrade interval
Check UpdateDegrade interval
Verify
Config.UpdateDegrade is set properly (default: 5000ms)Check for errors
Check for errors
Look in server console for any errors in weapon degradation events
Repair Kit Not Working
- Ensure item is defined as useable in shared/items.lua
- Check that weapon has a valid serial number
- Verify player actually has a weapon to repair
Weapons Disappearing
- Check if quality reached 0% (broken weapons stay in inventory but are unusable)
- Verify weapon items are defined correctly in shared/items.lua
- Check for inventory saving errors
Next Steps
- Inventory Overview - Learn about the inventory system
- Inventory Functions - Complete inventory function reference
- RSG Core Configuration - Configure your server
Need help? Join the RSG Framework Discord!