Jump to content

How do I?


Recommended Posts

You should use getTickCount instead of setTimer. Too many timers can cause lag.

I have never ever had an issue where a lot of timers caused lag, especially when client side. Only if you have a massive amount of timers looping rapidly will it cause lag...

Acutely they do cause lag... especially on the client side, however, you might not notice it if its just you and a couple of friends play on the server.

Link to comment

Acutely they do cause lag... especially on the client side, however, you might not notice it if its just you and a couple of friends play on the server.

A friend of mine had made a map where timers were being created through onClientRender by accident, we didn't notice any lag whatsoever - because it was client-side and it didn't use any for loops. It was when cleaning the code up he noticed it.

A timer will really only cause lag if it does a for loop like every 10th of a second, server-side. Other than that, they will rarely ever cause lag.

Link to comment
Acutely they do cause lag... especially on the client side, however, you might not notice it if its just you and a couple of friends play on the server.

That doesn't make any sense at all. Number of players does not influence the execution of timers. What's more, I just started 20000 timers on the server and they increased the CPU usage like by 10%. Even if I give them 50 ms interval, they reduce the server FPS from 145 to 120, with CPU usage being about 60-70%. In addition, implementing timers in Lua using onClientRender/onClientPreRender and getTickCount would probably cause bigger slowdowns. Even if that weren't true, code readability is more important than performance because reliability comes from readability and slowly working code is better than not working code.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...