From Official DarkRP Wiki
Jump to: navigation, search

A file called ammo.lua in your lua/darkrp_customthings folder (see here) is available for you to customize everything about DarkRP ammo buying.

There are three ammo boxes in there by default: the pistol, shotgun and rifle ammo.

Here's how you create your own:

GAMEMODE:AddAmmoType(ammoType, name, model, price, amountGiven, customCheck)

ammoType: The name of the ammo that Garry's mod recognizes If you open your SWEP's shared.lua, you can find the ammo name next to SWEP.Primary.Ammo = "AMMO NAME HERE" or SWEP.Secondary.Ammo = "AMMO NAME HERE"

name: The name you want to give to the ammo. This can be anything.

model: The model you want the ammo to have in the F4 menu

price: the price of your ammo in dollars

amountGiven: How much bullets of this ammo is given every time the player buys it

customCheck: (Optional! Advanced!) a Lua function that describes who can buy the ammo. Similar to the custom check function for jobs and shipments Parameters: ply: the player who is trying to buy the ammo

Removing ammo

Any/all the ammo can be removed without breaking the gamemode. Just disable them in lua/darkrp_config/disabled_defaults.lua


Example 1: Adding rifle ammo (in by default)

GAMEMODE:AddAmmoType("smg1", "Rifle ammo", "models/Items/BoxMRounds.mdl", 80, 30)

Example 2: Adding rifle ammo for donator/admin only using FAdmin (replace the original rifle ammo with this)

GAMEMODE:AddAmmoType("smg1", "Rifle ammo", "models/Items/BoxMRounds.mdl", 80, 30, function(ply)
        return ply:IsAdmin() or ply:GetNWString("usergroup") == "donator"

Example 3: Limit the pistol ammo to gun dealers only.

GAMEMODE:AddAmmoType("pistol", "Pistol ammo", "models/Items/BoxSRounds.mdl", 30, 24, function( ply ) return ply:Team() == TEAM_GUN end)

Personal tools