[Gamemode]Drop ammo

Hello
I’d like to make a drop ammo function:
When a player dies, he drops somme ammo of his current weapon (instead of this weapon).
Is there anyway to get the ammo type from ply:GetActiveWeapon?
Or should I use a switch() (or something like that) to get the type of ammo?

Thanks in advance

-Snip-

----- -----
----- -----
----- -----
----- -----

--------/-
-------/–
------/—
-----/----
-----V-----

GetActiveWeapon():Clip1() – the ammo there is in use
GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) – the ammo there is left for that weapon
GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType()) --like the AR2 the energy ball thing, its Secondary Ammo Type… :slight_smile:

Thank you very much :slight_smile:

Also, I don’t know if you were planning on doing this already, but make an entity and give it a model according to the ammo type, like the pistol ammo gets the pistol ammo box, etc.

What do you mean by make an entity?
Ther’s no function to make an ammo box appear near the ragdoll?

I wrote a little something like this a few months ago: Call this in GM:DoPlayerDeath

[lua]
function dropAmmo()
if (pl:GetAmmoCount(“pistol”)>0) then
local ent = ents.Create(“prop_physics_multiplayer”)
ent:SetPos(pl:GetPos())
ent:SetAngles(pl:GetAngles())
ent:SetModel(“models/Items/BoxSRounds.mdl”)
ent:PhysWake()
ent:SetGroundEntity(NULL)
ent:Spawn()
ent.IsAmmo = true
ent.AmmoType = ammo.Type
ent.AmmoCount = pl:GetAmmoCount(ammo.Type)
ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
end
end
[/lua]

Ok, I understand now, thanks again for all.

Well I was thinking more of an entity so you can make it so when you press “e” on it you pick it up and what not.