Can't get Secondary Ammo for wep.

Hi !

I try to get the Secondary ammo info for the Ar2 but it’s not working

[lua]for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == “weapon_ar2” then
draw.SimpleText("Clip: " … v:GetActiveWeapon(v:GetSecondaryAmmoType()), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Secondary: " … v:GetAmmoCount(v:GetActiveWeapon():GetSecondaryAmmoType()), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)



No one know ?

I need really help because I tryied alot of things but without good result :frowning:

Okay, for one, GetActiveWeapon is a function you run on a player to get what weapon he has out right now. But your loop suggests you’re trying to run this function on a weapon, which makes no sense. GetActiveWeapon doesn’t take any arguments either, but you’re trying to pass the weapon’s ammo type as an argument.

What exactly do you want to be drawn in the non-commented line?

This is what I use to get slot1 and slot2 ammo.
local Slot1 = ( LocalPlayer():GetAmmoCount( LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType() ) + LocalPlayer():GetActiveWeapon():Clip1() )
local Slot2 = ( LocalPlayer():GetAmmoCount( LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType() ) + LocalPlayer():GetActiveWeapon():Clip2() )

I’m trying to get the Alt Fire ammo of the Ar2 without to having to select the Ar2 weapon but I want to see the amount of this at any time.


Damn thanks it’s working :slight_smile:

but why I can use v instead of LocalPlayer() in my loop ?

How do you mean?

I mean why I can’t use v: instead of LocalPlayer() in my loop like this ?


That code wouldn’t work (assuming it was inside your loop) because as I said before, GetActiveWeapon is a function exclusive to players, it doesn’t exist on weapons.

ok thanks for this information :slight_smile:

Is there a way to make an Slider and he can set my secondary ammo with the value of the slider ?

Thanks in advance.