• Player.GetAmmoCount() returns 0 for some weapons, but works for others?
    0 replies, posted
Hi. I'm working on a HUD and I've run into a small issue I can't seem to find a solution to. On some weapons, GetAmmoCount returns the number of bullets remaining total. It does it's job. On other weapons (even some weapons that use the [i]same ammo type as a weapon that works[/i]) it refuses to return anything other than 0. My current workaround is to just display the weapon:Clip1() and simply say "fuck off" to the glitchy ammo count, but I would much prefer to display that. Here's my current code: [lua] local AmmoText = "Unlimited" local ActiveWep = LocalPlayer():GetActiveWeapon() if ValidEntity( ActiveWep ) then local AmmoMax = LocalPlayer():GetAmmoCount( tostring( ActiveWep:GetPrimaryAmmoType() ) ) local AmmoCurrent = ActiveWep:Clip1() AmmoText = tostring( AmmoCurrent ) .. " / " .. tostring( AmmoMax ) if AmmoMax == -1 then AmmoText = "Unlimited" elseif AmmoCurrent == -1 then AmmoText = "Unlimited" end else AmmoText = "Unlimited" end if tostring( AmmoText ) != "Unlimited" then draw.WordBox( 12, 15, ScrH() - 195, AmmoText, "HUDNumber3", Color( 20, 20, 20, 180 ), Color( 20, 180, 20, 255 ) ) end[/lua] Any suggestions would be appreciated.
Sorry, you need to Log In to post a reply to this thread.