GetClosestObjectOfType native takes between 2 and 4 ms

Like honestly… do you really need to check 20 times per second to see if a player is close to a door…

There is a lot weird things that are happening in esx_celldoors:

  • It checks at default 100x per second if someone is close to a door. Multiply that by the number of door you have configured (default 23).
  • Why is it even asking for the closest object when the player could be no where near the door. Easy fix is to do the distance check first before asking the closest object.
  • Why is all of this in a loop in the first place, you only want this to happen when the players is pressing the E key…

As I said earlier, the GetClosestObjectOfType native probably is a heavy function in itself, when you combine it with a loop and unnecessary calls, then yes your resource will become slow. I suggest reading up on my topic I made a while back:


Also, I can review the allavacciavostramodder script/resource for you to see why it’s slow. Just post it here if you are willing to.