GetClosestObjectOfType native takes between 2 and 4 ms


#1

GTA V version? Latest
Up to date? yes
Legit or Pirate copy? Legit
Steam/CD/Social Club? Social Club
Windows version? 10
Did you try to delete caches.xml and try again? yeah
Error screenshot (if any) – at the end
System specifications amd fx 8320e, 12gb ram, 128ssd + 5 (1tb) HDD, Nvidia GTX980
What did you do to get this issue? used function native “GetClosestObjectOfType”
What server did you get this issue on? every server
CitizenFX.log file not needed i think
.dmp files/report IDs not crash errors

Did you try to disable/uninstall your Anti-virus? always

SCREENSHOTS:
WHILE USING “GetClosestObjectOfType”

WITHOUT USING “GetClosestObjectOfType”


#2

Yes, GetClosestObjectofType isn’t fastest function, I’d suspect it might be iterating over a large list of objects.

And if you call this function 2300x per second like esx_celldoors is doing… then yes you will end up with a slow resource…


#3

actually i’m using a wait of 50ms and i got it from 3.8 to 2.8 but can’t do nothing more…

it should work like GetClosestVehicle by giving the name of the object you want him to find… but GetClosestVehicle is not actually acting this weird


#4

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.


#5

i fixed it ^^ is my anticheat since the native to check for all vehicles GetClosestVehicle works for cars and doesn’t recognize planes and copters and boats i added the CastRayPointToPoint to despawn forbidden vehicles… now i get 0.29ms.

i’ll check better the esx_celldoors and try to fix it myself :slight_smile: thanks for the help :smiley:


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.