I want to replace the timer here
[CODE]
self.Owner:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
timer.Simple(0.5, function()
self.Owner:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
end )
[/CODE]
With something that will repeat ACT_ZOMBIE_LEAPING until the player is on the ground.
81 Views and no one knows how
Just use Think hook to verify that, it's not about no one knows, it's about no one wants to take the time to help you
[QUOTE=Bear1ySane;52522613][IMG]https://facepunch.com/image.php?u=744003&dateline=1501438719[/IMG][/QUOTE]
Worst avatar I ever saw pls change
[CODE]
local ply = self.Owner --Or whatever you want to determine Player/NPC, using what you had as base
while not ply:OnGround() do
timer.Simple( 0.5, function()
ply:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
end)
end
[/CODE]
[url]http://wiki.garrysmod.com/page/Entity/OnGround[/url]
That should work, untested (with a touchpad so any obvious typos are being blamed on that), also if you do use a while loop, try and make sure you add error catching.
[QUOTE=Gl1tch3t;52524645][CODE]
local ply = self.Owner --Or whatever you want to determine Player/NPC, using what you had as base
while not ply:OnGround() do
timer.Simple( 0.5, function()
ply:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
end)
end
[/CODE]
[url]http://wiki.garrysmod.com/page/Entity/OnGround[/url]
That should work, untested (with a touchpad so any obvious typos are being blamed on that), also if you do use a while loop, try and make sure you add error catching.[/QUOTE]
That while loop will just run forever; it should be done in a think hook as gonzalalog said
[QUOTE=wh1t3rabbit;52524782]That while loop will just run forever; it should be done in a think hook as gonzalalog said[/QUOTE]
Is that in the assumption that the code is the only code in file or something to do with on ground? Asking as I'm confused why that while loop would run if the player is on the ground??
[QUOTE=Gl1tch3t;52524885]why that while loop would run if the player is on the ground??[/QUOTE]
Because due to how all this shit works, when that loop is running it will block [I]everything else[/I] from running, including all the stuff that processes user input and updates game state. Which means if the player wasn't on the ground and that code gets triggered, the player will never get back on ground again. Actually it will hang whatever it's running on (either the client or the server).
[QUOTE=Bear1ySane;52519285]I want to replace the timer here
[CODE]
self.Owner:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
timer.Simple(0.5, function()
self.Owner:DoAnimationEvent(ACT_ZOMBIE_LEAPING)
end )
[/CODE]
With something that will repeat ACT_ZOMBIE_LEAPING until the player is on the ground.[/QUOTE]
This code is for a weapon right?
[editline]31st July 2017[/editline]
[Lua]self.owner.nextjumpanim = self.owner.nextjumpanim or 0
if !self.owner:OnGround() and (self.owner.nextjumpanim - CurTime()) < 0 then
self.owner:DoAnimationEvent(TheJumpAnimationGoesHere)
self.owner.nextjumpanim = CurTime() + .5
end
[/Lua]
If you put that code in your weapons think hook and correct any mistakes I made with my phone it should work
I only want it to do the animation when i right click
[code]
function SWEP:SecondaryAttack()
if ( SERVER ) then
if ( not self:CanSecondaryAttack() ) or self.Owner:IsOnGround() == false then return end
local JumpSounds = { "npc/fast_zombie/leap1.wav", "npc/zombie/zo_attack2.wav", "npc/fast_zombie/fz_alert_close1.wav", "npc/zombie/zombie_alert1.wav" }
self.SecondaryDelay = CurTime()+10
self.Owner:SetVelocity( self.Owner:GetForward() * 200 + Vector(0,0,400) )
self.Owner:EmitSound( JumpSounds[math.random(4)], 100, 100 )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
end
end
[/code]
You didn't use the code from highvoltage anywhere in there? Try putting it in SWEP:Think()
Also, your check could be simplified to this:
[CODE]
if CLIENT or not self:CanSecondaryAttack() or not self.Owner:IsOnGround() then return end
[/CODE]
[editline]6th August 2017[/editline]
Also, I have to change my avatar now :(
Just put the DoAnimation part of the code after the if statement
No because it will only do the animation once
Please explain what you want to happen exactly
I want to do the Act when i right click until Im on the ground
Sorry, you need to Log In to post a reply to this thread.