TrapLord Studios™ Posted August 9, 2013 Share Posted August 9, 2013 Nite, I would like to know, how do I make a dxDrawRectangle + dxDrawText appear by command, then fade in 20 Seconds? Link to comment
Dealman Posted August 9, 2013 Share Posted August 9, 2013 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. Link to comment
xXMADEXx Posted August 10, 2013 Share Posted August 10, 2013 You should use getTickCount instead of setTimer. Too many timers can cause lag. Link to comment
Dealman Posted August 10, 2013 Share Posted August 10, 2013 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... Link to comment
xXMADEXx Posted August 10, 2013 Share Posted August 10, 2013 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
Dealman Posted August 10, 2013 Share Posted August 10, 2013 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
DiSaMe Posted August 10, 2013 Share Posted August 10, 2013 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
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