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:

[lua]
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]

[LUA]function givewep(ply)
ply:Give(“weapon_pistol”)
end
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 ""
		end
		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 ""
		end

		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 ""
		end

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

		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
		ply:Give(tblEnt.ent)
		else
		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:SetPos(tr.HitPos)
		item.SID = ply.SID
		item.onlyremover = true
		item:Spawn()
		local phys = item:GetPhysicsObject()
		if phys:IsValid() then phys:Wake() end
		end
		GAMEMODE:Notify(ply, 0, 4, string.format(LANGUAGE.you_bought_x, tblEnt.name, GAMEMODE.Config.currency..tblEnt.price))
		if not ply["max"..cmdname] then
			ply["max"..cmdname] = 0
		end
		ply["max"..cmdname] = ply["max"..cmdname] + 1
		return ""
	end
	AddChatCommand(tblEnt.cmd, buythis)
end

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}
	tblEnt.name = name

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

	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)
	end

	table.insert(DarkRPEntities, tblEnt)
	timer.Simple(0, function() GAMEMODE:AddEntityCommands(tblEnt) end)
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