Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCL improvements #99

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

thecraftianman
Copy link

@thecraftianman thecraftianman commented Aug 5, 2024

NOTE: This change also requires the matching ULX pull request to avoid breakage: TeamUlysses/ulx#226

This PR has two main changes that impact UCL:

  • UCL networking updates no longer resend all player and group data at once; instead, only the data for the applicable player/group will be networked to users upon an update
    • To facilitate this, two new clientside functions have been added: ucl.updateClientUCLPlayer( id, data ) and ucl.updateClientUCLGroup( name, data )
  • ucl.authed now uses SteamID64 internally instead of UniqueID
    • All functions that have been impacted by this change now support SteamID64 as a parameter as well, but all of this can be reverted if just using SteamID would be preferred

Tested both in a local server and on a public server for a couple weeks now with no regressions found.

A couple uses of UniqueID in functions have been kept for backwards compatibility, but honestly I'm not sure if those need to remain either
@Reycko
Copy link

Reycko commented Oct 23, 2024

Won't this break ULX extensions that access ucl.authed?
ULib.ucl.authed[player:UniqueID()] wouldn't work anymore on those.

@thecraftianman
Copy link
Author

That's true, I assumed that there was no need for other addons to access that table directly when I wrote this. Maybe it could just be able to use multiple player identifiers as a key like ULib.ucl.users instead?

Copy link

@JarosLucky JarosLucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, without call PLAYER:UniqueID() somehere in PlayerInitialSpawn before PLAYER.query. Hook call PlayerInitialSpawn sendAutocompletes, gives instant error.

@Reycko
Copy link

Reycko commented Nov 23, 2024

Won't this break ULX extensions that access ucl.authed? ULib.ucl.authed[player:UniqueID()] wouldn't work anymore on those.

Thought about it for a bit, got an idea for a (sorta) compatibility fix:

Using a metatable, we can make __newindex give/set SteamIDs internally even when UniqueIDs are passed.
Not sure about __index (getter), though.

@thecraftianman
Copy link
Author

thecraftianman commented Jan 14, 2025

Won't this break ULX extensions that access ucl.authed?
ULib.ucl.authed[player:UniqueID()] wouldn't work anymore on those.

Alright, I think I might've finally come up with a potential way to deal with this problem. It's a bit weird, but stick with me here. No matter what ID I tried in testing the length of a SteamID64 (ex. print(#util.SteamIDTo64("STEAM_0:0:0"))), it seems to always come out to be 17 characters long, and UniqueID (ex. print(#util.CRC("gm_".."STEAM_0:0:0".."_gm"))) seems to pretty much always come out to be 10 characters long. I added a metatable that is only used by ULib.ucl.authed to convert UniqueID usage to SteamID64 in its __index and __newindex methods using this length check to determine which one is being used, which should be more efficient than using player.GetByUniqueID or something else that would have to iterate over players in order to find the one with the matching UniqueID. This still isn't a great solution for when a UniqueID actually does get used because player.GetByUniqueID is still needed anyways to get the correct player, but it should at least prevent other addons from breaking. Let me know what you all think about this idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants