Spectop Posted October 29, 2020 Share Posted October 29, 2020 I have wrote a function and I need server call this function every n seconds. what's the best way? I found timer.lua in scripts/components, is that available? Link to comment Share on other sites More sharing options...
Yakuzashi Posted October 29, 2020 Share Posted October 29, 2020 I always use: inst:DoPeriodicTask(time, function, nil, inst) but it's not 100% accurate and may be hard on your PC when it calls a function few times a second. Ultroman covered this matter in this auras tutorial - https://forums.kleientertainment.com/forums/topic/110362-tutorial-making-auras-using-doperiodictask-and-dotaskintime/ My simple brain understood that, so you shouldn't have any problems. Cheers! Link to comment Share on other sites More sharing options...
Ziro2k Posted October 30, 2020 Share Posted October 30, 2020 The timer component is better suited for longer duration timers that don't trigger as often and you wish to save/load the remaining time with its associated entity. Otherwise, DoPeriodicTask is more appropriate. Assign the task to a variable if you intend to cancel it at any point. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now