Skip to main content

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 in config.lua:
Example Degradation:
  • Revolver with 6 shots = 0.06 quality lost per full cylinder
  • Takes approximately 1,667 shots to degrade from 100% to 0%
Lower degrade rates = longer weapon lifespan. Balance this with your server’s economy!

Repair Time

Time it takes to repair a weapon using a repair kit.

Weapon Components

When false, players can use the /loadweapon command to equip weapons.

Weapon Damage

Each weapon has a damage multiplier:
  • 1.0 = Normal damage
  • 1.5 = 50% more damage
  • 0.5 = 50% less damage

Disable Critical Hits


Weapon Degradation System

How It Works

  1. Player fires weapon
  2. Client tracks shots in a degradation queue
  3. Queue sent to server periodically (every 5 seconds)
  4. 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
When a weapon reaches 0% quality, it becomes unusable but remains in inventory. Players must repair it to use it again.

Weapon Repair System

Using Repair Kits

Players can repair weapons using the weapon_repair_kit item:
  1. Player uses repair kit from inventory
  2. Player selects which weapon to repair
  3. Progress bar shows repair in progress
  4. Weapon quality restored to 100%
  5. Repair kit consumed

Item Definition

In rsg-core/shared/items.lua:

Server-Side Repair


Weapon Information System

Get Weapon Info by Serial

Usage:

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

Balance degradation rates: Too fast = annoying, too slow = meaningless. Test with your community!
Track weapon serials for law enforcement RP: Use the serial numbers for crime investigations
Make repair kits accessible: Ensure players can obtain repair kits reasonably

Performance Tips

  1. Degradation batching: Shots are queued and processed in batches (every 5 seconds)
  2. Don’t check quality every frame: Only check when weapon is actually used
  3. Cache weapon data: Don’t repeatedly query the same weapon information

Balancing Tips

  1. Degrade rate: 0.01 per shot is a good baseline (1% per 100 shots)
  2. Repair kit availability: Balance cost vs weapon prices
  3. Quality thresholds: Consider adding effects at different quality levels
  4. Ammo economy: Balance ammo costs with weapon upkeep costs

Common Issues

Weapon Not Degrading

Ensure Config.DegradeRate is not set to 0
Verify Config.UpdateDegrade is set properly (default: 5000ms)
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


Need help? Join the RSG Framework Discord!