Viewmodel not drawing when player has no ammo

I’m making a medkit SWEP that takes ammo. It works fine with the exception that when it’s out of ammo the viewmodel doesn’t draw and, if I get ammo for it while it’s deployed, it cannot be reloaded and must be redeployed to work properly. Assuming this is intended behavior, how can I get around this and have the SWEP draw the viewmodel and allow reloading regardless of ammo count?

Edit: I’ve just done some testing and it looks like if I switch from a working SWEP, like the default fists, the medkit SWEP takes the viewmodel from that swep so I’m left with fists displaying that they have no ammo. It also shows the same viewmodel behavior and movement as the SWEP its stealing from. I’ll include a video of what I mean below as soon as it uploads.

Just a note that this code here is a simplified version of the final code, but it still shows the same symptoms.


SWEP.PrintName				= "New First Aid Kit"
SWEP.Author					= "Vincent Luciano"
SWEP.Purpose			= ""

SWEP.Slot					= 2
SWEP.SlotPos				= 3

SWEP.Spawnable				= true

SWEP.ViewModel				= Model( "models/weapons/v_rif_ak47.mdl" )
SWEP.WorldModel				= Model( "models/weapons/w_c4.mdl" )
SWEP.ViewModelFOV			= 54
SWEP.UseHands				= true

SWEP.Primary.ClipSize		= 1
SWEP.Primary.DefaultClip	= 0
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "Pistol"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.HealAmount				= 20

local HealSound = Sound( "HealthKit.Touch" )
local DenySound = Sound( "WallHealth.Deny" )

function SWEP:PrimaryAttack()

function SWEP:SecondaryAttack()


You do realize that the code you show sets the view model to the CS AK47, right? (I know you said it was example code, but make sure you didn’t overlook this.)

GMod’s default weapon switcher disregards weapons with no ammo, so the easy way would be to set the secondary clipsize to 1 even it it doesn’t use or have secondary ammo.

Also, make your primary defaultclip more than 0. This is used to check if you can reload and will deny you reloading if your current clip size is equal default clip. Meaning, once you use your charge and clipsize hits 0, even if you pick up additional ammo, you won’t be able to reload (unless you write your own Reload function).

return true in SWEP.Deploy

This is extremely helpful, thank you very much.

Luckily none of this information is on the wiki.

That was fixed within the last 2 days by Robotboy. I had this problem for ages. It turns out it’s not intended to work that way after all.

Here’s my bug report regarding that issue, which includes the a workaround that I used for CityScript:

Well doesn’t that just wrap this thread up nicely.

I know this thread is closed but I wanted to dispel some bullshit:

GMod’s default weapon switcher will still allow you to see and switch to weapons with absolutely no ammo.

DefaultClip is not related to reloading AT ALL. It is only used to give additional ammo on weapon spawn ( or override the amount of ammo in the clip the weapon starts with ) You can test this yourself.

It isn’t on the wiki because it is false.