Function to give a weapon directly to a player rather than dropping it in front of him?

So I have been doing a lot of custom work for my server and have been stumped by this. Using the regular DarkRP entities menu, how would you give a weapon directly to the player who buys it rather than dropping it in front of them? So certain classes can spawn themselves class restricted items that cant be obtained by other people. Any help would be very appreciated.

Current entities:

AddEntity(“Timed C4”, {
ent = “m9k_suicide_bomb”,
model = “models/weapons/w_sb_planted.mdl”,
price = 20000,
max = 2,
cmd = “/buyC4”,
allowed = {TEAM_TERRORIST}

AddEntity(“Improvised Explosive”, {
ent = “m9k_ied_detonator”,
model = “models/props_junk/cardboard_box004a.mdl”,
price = 15000,
max = 3,
cmd = “/buyIED”,
allowed = {TEAM_TERRORIST}


[LUA]function givewep(ply)
concommand.Add(“weapon_give”, givewep)[/LUA]

bump, need a solution here, above doesn’t work when added on to the entities in the shared.lua

Thats just stupid function.That gives you pistol when you running console command “weapon_give”

[editline]21st July 2013[/editline]

Okay. Thats one function from commands.lua

function GM:AddEntityCommands(tblEnt)
	if CLIENT then return end

	local function buythis(ply, args)
		if ply:isArrested() then return "" end
		if type(tblEnt.allowed) == "table" and not table.HasValue(tblEnt.allowed, ply:Team()) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.incorrect_job, tblEnt.cmd))
			return ""
		local cmdname = string.gsub(tblEnt.ent, " ", "_")

		if tblEnt.customCheck and not tblEnt.customCheck(ply) then
			GAMEMODE:Notify(ply, 1, 4, tblEnt.CustomCheckFailMsg or "You're not allowed to purchase this item")
			return ""

		local max = tonumber(tblEnt.max or 3)

		if ply["max"..cmdname] and tonumber(ply["max"..cmdname]) >= tonumber(max) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.limit, tblEnt.cmd))
			return ""

		if not ply:CanAfford(tblEnt.price) then
			GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, tblEnt.cmd))
			return ""

		local trace = {}
		trace.start = ply:EyePos()
		trace.endpos = trace.start + ply:GetAimVector() * 85
		trace.filter = ply

		local tr = util.TraceLine(trace)

		if tblEnt.weapon then
		local item = ents.Create(tblEnt.ent)
		item.dt = item.dt or {}
		item.dt.owning_ent = ply
		if item.Setowning_ent then item:Setowning_ent(ply) end
		item.SID = ply.SID
		item.onlyremover = true
		local phys = item:GetPhysicsObject()
		if phys:IsValid() then phys:Wake() end
		GAMEMODE:Notify(ply, 0, 4, string.format(LANGUAGE.you_bought_x,, GAMEMODE.Config.currency..tblEnt.price))
		if not ply["max"..cmdname] then
			ply["max"..cmdname] = 0
		ply["max"..cmdname] = ply["max"..cmdname] + 1
		return ""
	AddChatCommand(tblEnt.cmd, buythis)

And that function from MakeThings.lua

function AddEntity(name, entity, model, price, max, command, classes, CustomCheck, weapon)
	local tableSyntaxUsed = type(entity) == "table"

	local tblEnt = tableSyntaxUsed and entity or
		{ent = entity, model = model, price = price, max = max,
		cmd = command, allowed = classes, customCheck = CustomCheck, weapon = weapon} = name

	if type(tblEnt.allowed) == "number" then
		tblEnt.allowed = {tblEnt.allowed}

	local corrupt = checkValid(tblEnt, validEntity)
	if corrupt then ErrorNoHalt("Corrupt Entity \"" .. (name or "") .. "\": element " .. corrupt .. " is corrupt.
") end

	if SERVER and FPP then
		FPP.AddDefaultBlocked(blockTypes, tblEnt.ent)

	table.insert(DarkRPEntities, tblEnt)
	timer.Simple(0, function() GAMEMODE:AddEntityCommands(tblEnt) end)

And thats example for weapon what gives to you

AddEntity("Deagle1", {
	ent = "weapon_deagle2",
	model = "models/weapons/w_pist_deagle.mdl",
	price = 215,
	max = 10,
	cmd = "/buydeagle1",
	allowed = {TEAM_GUN},
	weapon = true

I think you know what to do.If you dont know,add me on steam airblack_djpeng4me