How to run multiple functions with one console command

Hi, I’m new to Lua, and was wondering if I could get some help with a SWEP.

Basicly what I want to do is

SWEP:PrimaryAttack()
SWEP:SecondaryAttack()

I want to do both at once, in one console command, and I don’t know how about to go with this. So I ask you all.
:slight_smile:

In your weapon:


SWEP.DoBoth = true

Your command:



local function DoBoth( pl )
  local wep

  if not ( pl:IsValid( ) and pl:Alive( ) ) then
    return
  end

  wep = pl:GetActiveWeapon( )

  if not ( wep:IsValid( ) and wep.DoBoth ) then
    return
  end

  wep:PrimaryAttack( )
  wep:SecondaryAttack( )
end

concommand.Add( "whatever", DoBoth )

Fairly simple.

Thanks, It worked :smiley: