Trying to find some help with SWEP's - searching isn't any help.
4 replies, posted
I'm trying to figure out how to do a couple things. How would I check to see if the player's weapon is reloading, and how would I change deploy speed? "self:SetDeploySpeed( )" doesn't seem to be working when I throw any number in it. (I'm also shoving it into my initialize code)
My best guess would be sticking a self.Reloading or whatever into the reload function and have a timer to reset it, then you can check for self.Reloading.
If I'm wrong well then feel free to rate me dumb and correct me.
Hey guys! I figured out a solution.
Create a SWEP.Reloading variable, and then in SWEP:Reload( ), throw in:
[code]self.Reloading = ( CurTime( ) + self.Owner:GetViewModel():SequenceDuration() )[/code]
If you want to prevent something from running if the player is reloading, use this.
[code]self.Reloading < CurTime( )[/code]
That'll give you the core functionality, but if you would like a function for it, create the SWEP.Reloading variable, then do this:
[code]function SWEP:IsReloading( )
if self.Reloading > CurTime( ) then
return true
else
return false
end
end[/code]
SWEP:IsReloading( ) will return true if the reload animation is playing. I'm using this to prevent the player from running or aiming down sights if the player is reloading.
I would still like a way to stretch the deploy animation, if possible.
[QUOTE=wauterboi;42536600]Hey guys! I figured out a solution.
Create a SWEP.Reloading variable, and then in SWEP:Reload( ), throw in:
[code]self.Reloading = ( CurTime( ) + self.Owner:GetViewModel():SequenceDuration() )[/code]
If you want to prevent something from running if the player is reloading, use this.
[code]self.Reloading < CurTime( )[/code]
That'll give you the core functionality, but if you would like a function for it, create the SWEP.Reloading variable, then do this:
[code]function SWEP:IsReloading( )
if self.Reloading > CurTime( ) then
return true
else
return false
end
end[/code]
SWEP:IsReloading( ) will return true if the reload animation is playing. I'm using this to prevent the player from running or aiming down sights if the player is reloading.
I would still like a way to stretch the deploy animation, if possible.[/QUOTE]
You can just do:
[lua]
return self.Reloading >= CurTime()
[/lua]
For the deploy speed you would use:
[lua]
--Use this inside SWEP:Initialize()
self:SetDeploySpeed(self.DeploySpeed)
[/lua]
Thanks dude. I found out that the stuff mentioned in this thread works for reload speed as well:
[url]http://facepunch.com/showthread.php?t=1087321[/url]
Marking this as solved!
Sorry, you need to Log In to post a reply to this thread.