ply:Give - Dropping weapons

Run into a minor problem, I’m using siminov’s weapon base and when calling ply:Give(“weapon_name_here”) it drops the weapon instead of giving it straight to me.

Is there some ridiculously easy thing I’ve missed here?

function GM:PlayerLoadout(ply)

All the Give function does is spawn the object at your feet. I don’t think there’s a function that directly adds it to your weapons.

When I use the Give function with HL2 related weapons it spawns on me.
Unless of course what it’s really doing is just removing all the other weapons from the loadout and keeping the few I chose…


as far as i know, siminov uses a system where you have to USE the weapons to pick them up.

Indeed, make sure you are using the ‘weapon’ name and not the ‘entity’ name. Last time I used it Siminovs weapons had ‘entities’ that when USEd would give you the weapon. It may be as simple as changing sim_fas_m4a1 to weapon_fas_m4a1

It really was as simple as that wh1t3rabbit. Changed all weapon names from sim_ to weapon_, fixed it right up. Players now spawn with the weapons in hand.

Appreciate the help.

-EDIT: Excuse the question regarding ammo, I’ve extracted the GMA file and found exactly what I need to give users ammo directly. Thank you again.

Find out what ammo type (each/the) gun use and do ply:GiveAmmo( theQuantity, theAmmoType )
If you have the addon extracted you can just check the code for the ammo entities and copy it from there.

EDIT - Ninja’d by your edit :stuck_out_tongue:

You can also try to use that on the weapons, so that you don’t need to use them yourself.
(Although you might need to use ents.Create instead of doing player:Give(), as ents.Create actually returns an entity)

I believe something like this would work:

[LUA]local playerMeta = FindMetaTable(“Player”);
function playerMeta:Give(weapon)
local spawnedWeapon = ents.Create(weapon);
if spawnedWeapon:IsWeapon() then
ErrorNoHalt(“Weapon argument isn’t a valid weapon class.”);
spawnedWeapon:Remove(); – I’m not really sure if not calling this will leave a ghost entity behind