esx_core icon indicating copy to clipboard operation
esx_core copied to clipboard

[Feature Request] - es_extended - Better handling of getting entity type

Open mikigoalie opened this issue 1 year ago • 5 comments

There is small overseen issue with getvehicletype RPC https://github.com/esx-framework/esx_core/blob/7c59848a08a4bf6e17a36a4c44f20197aa698a79/%5Bcore%5D/es_extended/server/onesync.lua#L91

Currently, if there are no players near given coords, the function will fail without proper handling. I suggest to pass the rpc to any other random player or cache it until someone appears nearby.

Use case should be self explainatory, but: Creating a vehicle in onesync zone with no player will result in an error.

mikigoalie avatar Feb 05 '24 15:02 mikigoalie

this is set to 300 to allow wiggle room. if the player is 423m out, and it gets called, they just have to walk for a second, and suddenly they out are out of oncesync range, which could result in much more issues. caching is also just not possible here.

Mycroft-Studios avatar Feb 12 '24 19:02 Mycroft-Studios

I understand why it's locked within 300 units, but I still believe A.) We should handle this case to prevent errors (or passing events to invalid sources atleast) B.) We could still retrieve vehicle type from any other player that's not within the range.

If you consider second option to bring more issues ( i assume statebags would be the problem here and entity ownership ), then you may close this issue

mikigoalie avatar Feb 13 '24 10:02 mikigoalie

what is your usecase for spawning vehicles outside of onesync range anyway?

Mycroft-Studios avatar Feb 13 '24 17:02 Mycroft-Studios

what is your usecase for spawning vehicles outside of onesync range anyway?

Generally, in most cases it's fine if the source is within 400 units, but there was a case where I needed to create entity far from the entity, which was then tracked on the map etc. Very speecific, however I thought it'd be good idea to mention it as it's not really handled at all atm

mikigoalie avatar Feb 14 '24 17:02 mikigoalie

what is your usecase for spawning vehicles outside of onesync range anyway?

Generally, in most cases it's fine if the source is within 400 units, but there was a case where I needed to create entity far from the entity, which was then tracked on the map etc. Very speecific, however I thought it'd be good idea to mention it as it's not really handled at all atm

For that, id recommend putting a blip where it would spawn, and then spawning the vehicle when the player gets close. :)

Mycroft-Studios avatar Feb 14 '24 18:02 Mycroft-Studios

@mikigoalie Hi! As @Mycroft-Studios said you can do this, you manage the whole process server-side and update the coordinate from the server and send it back to the client.

Gellipapa avatar Feb 29 '24 21:02 Gellipapa