Jump to content

How do I?


Recommended Posts

Posted
addCommandHandler 
setTimer 
addEventHandler --onClientRender 
removeEventHandler --onClientRender 
dxDrawRectangle 
dxDrawText 

As for fading, you could make us of either onClientRender or setTimer. Just have it decrease the alpha. Using onClientRender will make it fade much smoother than a timer would.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
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...

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
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.

Posted

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.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
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.

-

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...