[DarkRP] Is there a way for a certain job to buy ammo?

I have a DarkRP server with FA:S 2.0, and I really want to know if it’s possible for a specific job to buy ammunition, e.g. an ammo dealer. Is this possible? If so, how??

I haven’t done this myself, but I think you just have to go to the jobs file in the DarkRP folder, and then you set what can be bought by what jobs, and things like that.
At least that’s how you enable gun dealers to buy guns, and black market dealers to buy knives, c4s, etc

As far as I’m aware you can’t put an ammo code in shipments.lua so I put them in entities.lua. Because in the shipments file you can job specify. This is the code I use for an ammo example in entities.lua:

DarkRP.createAmmoType(“7.62x39mm”, {
name = “7.62x39mm”,
model = “models/Items/BoxMRounds.mdl”,
price = 5000,
amountGiven = 24
})

If there’s a way to allow ammo for a certain job then can somebody please tell me how…



DarkRP.createAmmoType("7.62x39mm", {
name = "7.62x39mm",
model = "models/Items/BoxMRounds.mdl",
price = 5000,
amountGiven = 24,
customCheck = function(ply) return ply:Team() == TEAM_WHATEVER end end
})


also ammo should go in ammo.lua not entities.lua

I tried your code, but it gave me this error in the server console:

Local file is overriding addon’s file! gamemodes/darkrp/gamemode/libraries/simplerr.lua (DarkRP)

[ERROR] Lua is unable to understand file “darkrp_customthings/ammo.lua” because its author made a mistake around line number 73.
The best help I can give you is this:

There is an opening ‘{’ bracket at line 68, but this bracket is never closed or not closed in time. It was expected to be closed before the ‘end’ at line 73.

Hints:
- Did you forget a comma?
- All open brackets ({, (, [) must have a matching closing bracket. Are you sure it’s there?
- Brackets must be opened and closed in the right order. This will work: ({}), but this won’t: ({)}.

------- End of Simplerr error -------

  1. error - [C]:-1
  2. unknown - gamemodes/darkrp/gamemode/libraries/simplerr.lua:467
    3. doInclude - gamemodes/darkrp/gamemode/libraries/fn.lua:80
    4. loadCustomDarkRPItems - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:131
    5. Call - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:142
    6. unknown - gamemodes/darkrp/gamemode/init.lua:81

Couldn’t Load Init Script: ‘darkrp/gamemode/init.lua’

There should only be one ‘end’ after the customCheck. So just remove the other one.


DarkRP.createAmmoType("7.62x39mm", {
name = "7.62x39mm",
model = "models/Items/BoxMRounds.mdl",
price = 5000,
amountGiven = 24,
customCheck = function(ply) return ply:Team() == TEAM_WHATEVER end
})

my bad.

Thank you it works! :smiley: