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

Miscellaneous E2 player additions #2718

Merged
merged 4 commits into from
Aug 12, 2023
Merged

Miscellaneous E2 player additions #2718

merged 4 commits into from
Aug 12, 2023

Conversation

Denneisk
Copy link
Member

@Denneisk Denneisk commented Aug 9, 2023

Additions:

  • number entity:accountID() - returns the player's account ID.
  • number entity:userID() - returns the player's user ID. This is different from entity index.
  • entity player(index) - returns a player entity from the user ID.
  • array teamMembers(index) - returns an array with the members of a team.
  • number teamMemberCount(index) - returns the number of players on a team.

Changes:

  • Deprecated number teamPlayers(index) (misleading, should be replaced by teamMembers)
  • Simplified some function returns
  • Added exceptions to certain functions where they seemed appropriate
  • Small E2 Description change for consistency

Removals:

  • Removed check for Player.LocalEyeAngles() existing
  • Removed unused local variables

Test code

Fixes #2660

Add e:userID()
Add player(n)
Add teamMembers(n) and teamMemberCount(n) (deprecate teamPlayers)
Minor cleanup
Clean entity:inVehicle()
@thegrb93
Copy link
Contributor

thegrb93 commented Aug 9, 2023

Don't leave commented code; just delete it

@Denneisk
Copy link
Member Author

Denneisk commented Aug 9, 2023

Think of all the keystrokes that guy in 15 years will save.

@@ -85,7 +75,25 @@ e2function string entity:steamID64()
if not IsValid(this) then return self:throw("Invalid entity!", "") end
if not this:IsPlayer() then return self:throw("Expected a Player but got an Entity!", "") end

return this:SteamID64() or ""
return this:SteamID64()
Copy link
Contributor

Choose a reason for hiding this comment

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

I vaguely remember this returning nil if the the player is a bot. Might need the or "". Could be wrong though

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the changes look fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Latest update said it now always returns something valid.

Made Player:SteamID64 and Player:AccountID never return no value

Copy link
Contributor

Choose a reason for hiding this comment

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

no value is not the same as nil, although it looks like they did also change the nil case. I think the only case where this happened was when a player signed in on a -multirun client.

@Vurv78 Vurv78 merged commit 214d473 into wiremod:master Aug 12, 2023
1 check failed
Vurv78 added a commit that referenced this pull request Aug 14, 2023
Fix regression in #2718
@Denneisk Denneisk deleted the player branch April 14, 2024 05:32
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