How to run multiple functions with one console command
2 replies, posted
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.
:)
In your weapon:
[code]SWEP.DoBoth = true[/code]
Your command:
[code]
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 )[/code]
Fairly simple.
Thanks, It worked :D
Sorry, you need to Log In to post a reply to this thread.