Looping a Sequence?

self:SetPlaybackRate(1) [/lua]
For a nexbot, how do I loop a sequence?
My sequence plays once then freezes.
I’ve used this but I can’t find any info.
Probably obvious, but not for me.
If there is a better way please let me know, the below isn’t perfect and leads to “okay” results.
My solution was to reset the sequence with a timer, right when it ends.
[lua]timer.Create( “my_timer”, 11, 0, function()
end )[/lua]


If you turn off automatic frame advance, you can do it yourself clientside.

function ENT:Draw( )
  self:DrawModel( )

  if self:GetCycle( ) == 1 then
    self:SetCycle( 0 )
    self:FrameAdvance( FrameTime( ) )

As long as nextbots call :Draw clientside, that should work.

Originally, my timer wouldn’t always work. It would play the animation, stop playing it and wait for the timer to come around again, then it played once more. But with the code you gave me, it seems to work better, thanks. I added one other line (can’t remember what it was) but I’ll bet that wasn’t the fix.

This worked, but any idea why spawning the multiple nexbots makes the older ones stop looping the animation?
For instance, if I had 3 citizens walking, the first 2 spawned would stop the animation loop but the latest spawned one would loop.:suicide:

Didn’t know this, thanks


The easiest way I can think of is extracting your model and adding the word loop to the animation.


$sequence "idle" "anims\idle.smd" {

He’s using default citizen models

Not really, I was just using that as an example. Basically the animations won’t continue to loop if another of that NPC is created.

So any other ideas guys? :open_mouth:


I just waited a week so I am going to bump again,

I dont think anyone knows, considering there have been no other answers in 3 weeks

What Kogitsune posted should work.
I used a similar method for my cat npcs.

Make your own animation system like I did. But I will tell you this: It takes a long time to make one, and also I suggest using modules

I pasted his code into my cl_init.lua, no changes in anything :blush: