Trying to make a police ammo box!

Hey, I am trying to make a Police Ammo Box that will sit inside a PD and when a player comes up to it and presses ‘E’ that player is given SMG1 ammo however when I use Player/GiveAmmo it wont give the player the ammo. The code I am using is;

Init.Lua


--Police Ammo Box
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()

	self:SetModel("models/Items/ammocrate_smg1.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)

	local phys = self:GetPhysicsObject()

	if phys:IsValid() then

		phys:Wake()

	end	

end

function ENT:Use(a , c)

	Player:GiveAmmo( 125, SMG1, true)

end

Can someone please tell me why the ammo is never given. I do not get any errors and just am really confused… Help is greatly appreciated!

the ammo type should be a string, either in “” or ‘’


function ENT.Use(a , c)

      Player:GiveAmmo( 125, "SMG1", true)     

end

Would this be correct then ?

Instead of




Player:GiveAmmo()

Do

c:GiveAmmo( 125, "SMG1", true )




function ENT:Use(a , c)

	c:GiveAmmo( 125, "SMG1", true)

end

I tested this and it works however if you hold ‘E’ it gives you 9999 ammo to stop this would I just do:


self:SetUseType( SIMPLE_USE )

Another problem has come up with the code in the police ammo box:

I am trying to create it so when the government official walks up to it and interacts with it, money is taken off him and he is greeted with a notification that reads; “You have spent $”…ammoprice…" on ammo!"

The code I am trying to use is:


function ENT:Use(a , caller)

	local ammoprice = 250
	caller:GiveAmmo( 25, "ar2", true)
	Player:AddMoney(-ammoprice)
	DarkRP.notify(caller, 1, 5, "You have spent $"..ammoprice.." on ammo!")

end

I have triple checked the code and can’t find anything wrong but still no notification or money taken. The only thing I could think it is, is that on DarkRP.notify I have put caller and it should be something else!

Video to show what is happening:

Thank you for your help!