I’m trying to create a SWEP with a various modes & each mode would have a custom draw element. All the values in are placeholders. While I have the mode system working with reload & primary fire the HUD defaults to 1 for some reason instead of using the updated values when its changed in-game via reload. Manually editing the “SWEP.Mode = 1” to 2-9 changes the draw element however. I’m confused as to what I’m doing wrong considering the reload function & primaryfire functions are using the same code essentially.
// values
SWEP.Mode = 1
SWEP.ReloadDelay = 0
//PRIMARY FIRE
function SWEP:PrimaryAttack()
if self.Mode == 1 then
print("Mode One")
end
//Mode Two
if self.Mode == 2 then
print("Mode Two")
end
//Mode Three
if self.Mode == 3 then
print("Mode Three")
end
//Mode Four
if self.Mode == 4 then
print("Mode Four")
end
//Mode Five
if self.Mode == 5 then
print("Mode Five")
end
//Mode Six
if self.Mode == 6 then
print("Mode Six")
end
//Mode Seven
if self.Mode == 7 then
print("Mode Seven")
end
//Mode Eight
if self.Mode == 8 then
print("Mode Eight")
end
//Mode Nine
if self.Mode == 9 then
print("Mode Nine")
end
end
//HUD
function SWEP:DrawHUD()
if self.Mode == 1 then
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 25, 25, 100, 100 )
end
//Mode Two
if self.Mode == 2 then
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 50, 50, 300, 300 )
end
//Mode Three
if self.Mode == 3 then
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 25, 25, 100, 100 )
end
//Mode Four
if self.Mode == 4 then
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 50, 50, 300, 300 )
end
//Mode Five
if self.Mode == 5 then
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 25, 25, 100, 100 )
end
//Mode Six
if self.Mode == 6 then
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 50, 50, 300, 300 )
end
//Mode Seven
if self.Mode == 7 then
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 25, 25, 100, 100 )
end
//Mode Eight
if self.Mode == 8 then
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 50, 50, 300, 300 )
end
//Mode Nine
if self.Mode == 9 then
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 25, 25, 100, 100 )
end
end
//RELOAD - Switching Modes
function SWEP:Reload()
if self.ReloadDelay == 0 then
self.ReloadDelay = 1
timer.Simple(0.52, function() if self && self:IsValid() then self.ReloadDelay = 0 end end)
self.Owner:ViewPunch( Angle((-0.12),0,0) )
self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
if (SERVER) then self.Owner:EmitSound( "weapons/slam/mine_mode.wav", 52, 100 )
if self.Mode == 1 then
self.Mode = 2
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Two")
return end
if self.Mode == 2 then
self.Mode = 3
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Three")
return end
if self.Mode == 3 then
self.Mode = 4
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Four")
return end
if self.Mode == 4 then
self.Mode = 5
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Five")
return end
if self.Mode == 5 then
self.Mode = 6
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Six")
return end
if self.Mode == 6 then
self.Mode = 7
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Seven")
return end
if self.Mode == 7 then
self.Mode = 8
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Eight")
return end
if self.Mode == 8 then
self.Mode = 9
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode Nine")
return end
if self.Mode == 9 then
self.Mode = 1
self.Owner:PrintMessage(HUD_PRINTCENTER, "Mode One")
return end
end
end
end
Mode one:
Mode two:
Mode two: (Manually edited in value to 2, this is how it should look without me having to edit the code w/ the value)