DarkRP: Mad Cows Ammo

Hey everyone. In DarkRP, we all know that we can go into chat (or the F4 menu) and buy some ammo. That’s simple enough. But, if you’ve heard of Mad Cows SWEP’s, I’m sure you’ll know about the types of ammo for the right guns. That’s not my concern. My question is:

How do I make it so everyone can spawn the ammo they want (this’ll be Mad Cows ammo) from the F4 menu?

It’s really confusing me and I don’t have the confidence yet to try it out mainly because I don’t know what to do!

However, I do know that at lines 491 (ish) is where everyone can buy the ammo. Although I don’t know what to put in there. Can anyone help?

Sorry if I couldn’t discribe this well enough, it’s hard to discribe.



AddIcon("models/Items/357ammo.mdl", "Buy some .357 ammo: " .. CUR .. tostring(GetGlobalInt("ammopistolcost")), "/buyammo 357")


Anything else I should add here or anywhere in the DarkRP script?

Why dont you just change the ammo, the guns uses?

Adding an icon isn’t adding the buy ammo function correctly, you need to create a whole new function that would purchase and give the correct ammo; not just an icon that gives the wrong ammo.

I know, my question was how do I do that.

Sorry I couldn’t explain it that well. :stuck_out_tongue:

I haven’t edited DarkRP in a while, but I’m thinking the main.lua, search for this “/buyammo” then look at the function. If you post it here I may check back and see what I can do.

look line 615 in showteamtabs.lua

He is right, it’s a whole lot simpler to change the ammo to the ones that darkrp uses than making darkrp use new ones. Just open the shared.lua of the weapons and change the ammo type to either smg1, pistol or buckshot.

What about it?
Ok then I’ve done a few things (sorry I was away I was doing work). But yeah here are the things I’ve done (and it’s still not working):

Added the ammo types to the entites/spawned_shipment.lua:



ShipmentWeaponClasses["9MM-AMMO"] = {}
ShipmentWeaponClasses["9MM-AMMO"]["ent_mad_ammo_9mm"] = "models/Items/BoxSRounds.mdl"
ShipmentWeaponClasses["4.5MM-AMMO"] = {}
ShipmentWeaponClasses["4.5MM-AMMO"]["ent_mad_ammo_45"] = "models/Items/BoxSRounds.mdl"
ShipmentWeaponClasses["4.6MM-AMMO"] = {}
ShipmentWeaponClasses["4.6MM-AMMO"]["ent_mad_ammo_46mm"] = "models/Items/BoxSRounds.mdl"
ShipmentWeaponClasses["5MM-AMMO"] = {}
ShipmentWeaponClasses["5MM-AMMO"]["ent_mad_ammo_50"] = "models/Items/BoxSRounds.mdl"
ShipmentWeaponClasses["5.7MM-AMMO"] = {}
ShipmentWeaponClasses["5.7MM-AMMO"]["ent_mad_ammo_57mm"] = "models/Items/BoxSRounds.mdl"
ShipmentWeaponClasses["3.57MM-AMMO"] = {}
ShipmentWeaponClasses["3.57MM-AMMO"]["ent_mad_ammo_357"] = "models/Items/357ammo.mdl"
ShipmentWeaponClasses["5.56MM-AMMO"] = {}
ShipmentWeaponClasses["5.56MM-AMMO"]["ent_mad_ammo_556mm"] = "models/Items/BoxMRounds.mdl"
ShipmentWeaponClasses["7.62MM-AMMO"] = {}
ShipmentWeaponClasses["7.62MM-AMMO"]["ent_mad_ammo_762mm"] = "models/Items/BoxMRounds.mdl"


Added them to the addshipments.lua:



AddCustomShipment("9MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_9mm", 40, 5, true, 40, true)
AddCustomShipment("4.5MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_45", 40, 5, true, 40, true)
AddCustomShipment("4.6MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_46mm", 40, 5, true, 40, true)
AddCustomShipment("5MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_50", 40, 5, true, 40, true)
AddCustomShipment("5.7MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_57mm", 40, 5, true, 40, true)
AddCustomShipment("3.57MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_357", 40, 5, true, 40, true)
AddCustomShipment("5.56MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_556mm", 40, 5, true, 40, true)
AddCustomShipment("7.62MM-AMMO", "models/Items/BoxSRounds.mdl", "ent_mad_ammo_762mm", 40, 5, true, 40, true)


The entites ARE in the DarkRP/entites/entites folder.

What I’m confused about however is that in the addshipment.lua file, it allows you to make them “buy only”. I understand that part. But on the line where it says:



AddIcon("models/Items/357ammo.mdl", "DISABLED" .. CUR .. tostring(GetGlobalInt("ammopistolcost")), "/buyammo 357")


It says about in the string “ammopistolcost”. HOW can I make that possible for Mad cows SENTs? Like, how would I add the ammo as a GetGlobalInt?

Just freaking change the ammo the gun uses.

Because I don’t WANT to. I’d rather make it so that the guns use proper more precise ammo. Ok?

Please don’t quote that again.

That may of been slightly harsh to say, but if wanted to do that, then I wouldn’t be asking Facepunch.

Okay, I just dont get why you want to do alot of work, and have to ask others for help and bug the server, just because you want another type of “proper more precise ammo”. Why is the ammo more “proper” and “precise”?

I just dont get it.

Have you ever seen Mad Cows SWEPS? You seem confused on what they are.
And it’s for the experience. How are you supposed to learn by just taking shortcuts and not understanding how to do it?

But back to my problem. Can anyone help me out?

No, I havent seem them - though, I know they use different ammo.

Yeah. The guns automatically assign the right ammo for the right guns, it’s now just a matter of coding them into DarkRP.

Replace function BuyAmmo at about line 1247 in main.lua , Also add all of your icons to the F4 menu, this is just the code that makes it work :wink:

[lua]
function BuyAmmo(ply, args)
if args == “” then return “” end

if RPArrestedPlayers[ply:SteamID()] then return "" end

if CfgVars["noguns"] == 1 then
	Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "ammo", ""))
	return ""
end

if args ~= "rifle" and args ~= "shotgun" and args ~= "pistol" and args ~= "9MM-AMMO" 
					and args ~= "4.5MM-AMMO" and args ~= "4.6MM-AMMO" and args ~= "5MM-AMMO" and args ~= "5.7MM-AMMO" 
					and args ~= "3.57MM-AMMO" and args ~= "5.56MM-AMMO" and args ~= "7.62MM-AMMO" then
	Notify(ply, 1, 4, string.format(LANGUAGE.unavailable, "ammo"))
	return ""
end

if not ply:CanAfford(GetGlobalInt("ammo" .. args .. "cost")) then
	Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "ammo"))
	return ""
end

if args == "rifle" then
	ply:GiveAmmo(80, "smg1")
elseif args == "shotgun" then
	ply:GiveAmmo(50, "buckshot")
elseif args == "pistol" then
	ply:GiveAmmo(50, "pistol")
elseif args == "9MM-AMMO" then
ply:GiveAmmo(50, "ent_mad_ammo_9mm")
elseif args == "4.5MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_45")
elseif args == "4.6MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_46mm")
elseif args == "5MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_50")
elseif args == "5.7MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_57mm")
elseif args == "3.57MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_357")
elseif args == "5.56MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_556mm")
elseif args == "7.62MM-AMMO" then
	ply:GiveAmmo(50, "ent_mad_ammo_762mm")
end

local cost = GetGlobalInt("ammo" .. args .. "cost")

Notify(ply, 1, 4, string.format(LANGUAGE.you_bought_x, args, CUR..tostring(cost)))
ply:AddMoney(-cost)

return ""

end
AddChatCommand("/buyammo", BuyAmmo)[/lua]

At line 1247 I got this…:


	if not ply:Alive() then

Well then, search for the BuyAmmo function?

I have. I searched for ages. Still can’t find it. I may just be a bad searcher, but I still can’t find it. :frowning:

No, litterally, search for it.

CTRL+F, in notepad++ opens a search box.