How long does the server take for running each Tick and Think? Is it possible to change the rate by lua it self? I’m going to use ents.FindInBox 10 - 20 times on each Tick/Think. There’s no problem with delay up to 1 seconds. Which one do you suggest me to use?
It runs every tick, if I’m not mistaken. You could make a timer that runs every x seconds.
It depends; if you have 33 ticks per second then Tick is every 0.03030303030303030303030303030303 seconds. 60 per second: 0.01666666666666666666666666666667
Any ents.FindIn* functions can be expensive and I’d recommend against using them. I used to use FindInCone once per frame and it cut performance of my lighting system drastically. It essentially halved my FPS…
Depending what you want it to do, there may be better alternatives. What is it that you’re trying to accomplish?
I’m trying to detect whether if player is on some specified areas of map or not, And send it to client if they are. Also one other question, If I set LocalPlayer().Variable = CustomObject on client, Will it be shared on server too? or vice versa.
What Humble suggested would work.
You can expand on it, or leave it basic. Considering how fast / slow users travel, if you detect once every second ( for alive players ), it’ll be quick enough; no need to run it every tick, let alone 10-20 times…
If you want the box to be square, I’d recommend looping through alive players and doing a Distance check to the origin that you want boxed off ( this will be a sphere ); if they are within range, then do an AABB search to see if they are within range. Distance is cheaper to call than FindIn*
Can you please give a small example for this? Cause I haven’t worked much with distances before.
Here, just turned it into html file. Remove .html to see the .lua.