I'm in the progress of coding a ultimate swep, and wondered how I could
make a command run when holding down the Reload button?
Whenever you reload, you activate the function, but when you release the reload button, the function
stops. I've been looking through google and wiki but couldn't really figure out how.
Best Regards,
Author
[code]
local HoldingReload = false
function SWEP:Think()
if( !IsValid( self.Owner ) ) then return end
HoldingReload = self.Owner:KeyDown( IN_RELOAD )
if( HoldingReload ) then
-- do your stuff here
end
end
[/code]
?
Thanks alot, I'll go test this out right now!
[editline]11th February 2014[/editline]
It works, but this is what I really need:
Whenever you Hold the Reload button, it actives a function.
and when you release the reload button, it starts a new function.
For example:
When holding reload,
game.SetTimeScale(0.1)
When releasing reload,
game.SetTimeScale(1)
Hope you can figure out a way ;)
Thanks
[QUOTE=Lolm4te;43869752]Thanks alot, I'll go test this out right now!
[editline]11th February 2014[/editline]
It works, but this is what I really need:
Whenever you Hold the Reload button, it actives a function.
and when you release the reload button, it starts a new function.
For example:
When holding reload,
game.SetTimeScale(0.1)
When releasing reload,
game.SetTimeScale(1)
Hope you can figure out a way ;)
Thanks[/QUOTE]
[lua]
function SWEP:Think()
if ( !IsValid( self.Owner ) ) then return end
if ( self.Owner:KeyPressed( IN_RELOAD ) ) then -- If reload is pressed
-- Do something
end
if ( self.Owner:KeyReleased( IN_RELOAD ) ) then -- If reload is released
-- Do something
end
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.