Raised This Month: $32 Target: $400
 8% 

What exactly is the "user id"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gromit190
Junior Member
Join Date: Jun 2019
Old 09-02-2021 , 07:52   What exactly is the "user id"
Reply With Quote #1

I am a little confused about the term "user id".


The GetClientUserId function is described like this:

"Retrieves a client's user id, which is an index incremented for every client that joins the server."

https://sm.alliedmods.net/new-api/cl...etClientUserId


If that is really the case. Then what is the "client index" that you get in the OnClientConnected forward? How is the client index different from the user id?

https://sm.alliedmods.net/new-api/cl...lientConnected


I was hoping that the "user id" is actually a unique user id per steam user... (which would mean that the GetClientUserId description is actually wrong)

Last edited by gromit190; 09-02-2021 at 07:54.
gromit190 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-02-2021 , 08:16   Re: What exactly is the "user id"
Reply With Quote #2

"UserID" is like ticket for each player who join in server.
That ticket last as long as player not disconnect or re-connect.

With "userID" you find correct person (client index) or you get 0 = person have leave from server.

"userids" start from 1 and grows by one. There are max limit, when number get reset back 1, I don't remember that limit... 65000 ?

"userids" are like temporary ID's for players. If you really want search person with right SteamID then you look players steam id.

*edit

- Client index is array index.
- You have a array start from 0 to MaxClients (max is 64, depends game and mode).
- Client index 0 = is server (or error)
- Valid client index start from 1 to MaxClients.
__________________
Do not Private Message @me

Last edited by Bacardi; 09-02-2021 at 08:23.
Bacardi is offline
gromit190
Junior Member
Join Date: Jun 2019
Old 09-02-2021 , 08:20   Re: What exactly is the "user id"
Reply With Quote #3

Okay. Whats the difference between client index and user id?

When the first client joins the server. His user id will be 1. And his client index will also be 1 (the first client)?
Then what is the point of the user id?
gromit190 is offline
gromit190
Junior Member
Join Date: Jun 2019
Old 09-02-2021 , 08:29   Re: What exactly is the "user id"
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
"UserID" is like ticket for each player who join in server.
That ticket last as long as player not disconnect or re-connect.

With "userID" you find correct person (client index) or you get 0 = person have leave from server.

"userids" start from 1 and grows by one. There are max limit, when number get reset back 1, I don't remember that limit... 65000 ?

"userids" are like temporary ID's for players. If you really want search person with right SteamID then you look players steam id.

*edit

- Client index is array index.
- You have a array start from 0 to MaxClients (max is 64, depends game and mode).
- Client index 0 = is server (or error)
- Valid client index start from 1 to MaxClients.
Okay then I think I understood it. Thanks!
gromit190 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-02-2021 , 08:34   Re: What exactly is the "user id"
Reply With Quote #5

The difference is that client indexes only go up to 64 while user IDs can go up to 65,535.

Let’s say player A joined first and became client index 1 and was assigned user ID 1. Then more players join to fill up client indexes 2-64 and were assigned with user IDs 2-64. Now let’s say player A left and player B joined to take his place. Player B will now be client index 1 but his user ID will be 65 because there were 64 other players that joined before him (including player A).

We prefer user IDs over client indexes when tracking each player currently on the server because there are more slots to fill up and thus providing more unique numbers to assign to each player that joins. Meanwhile, client indexes only go up to 64 so it becomes unreliable when you have players going in and out of the server and “replacing” each other.
__________________
Psyk0tik is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-02-2021 , 08:43   Re: What exactly is the "user id"
Reply With Quote #6

Here some code... snip

-saves players userid when plugin start, only.
- with sm_test command you can check stored userids when players leave and come back.

Spoiler
Bacardi is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-03-2021 , 05:15   Re: What exactly is the "user id"
Reply With Quote #7

userid = unique id for a player while the server is online. we use these in timers, request frames etc, because if a player disconnects and another one joins, the player who joins can have the clientid of the disconnected one.
clientid = the client entity id. with this we perform actions on the player (slap, kick etc).

its the same thing with entities ids and entities references.
__________________
Ilusion9 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-04-2021 , 00:29   Re: What exactly is the "user id"
Reply With Quote #8

I was wondering the same thing.

Great question and great answers that explain the reasons for both of them.
Thanks....
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-05-2021 , 01:28   Re: What exactly is the "user id"
Reply With Quote #9

Some follow up questions….
I saw this from a different post
“SourceMod functions (like GetClientName) take player indexes, which is the same as their entity id”

1) They use the term “player index” is this just clientid?
2) I know entities are a different concept but it looks like
For players, their clientid will = their entityid?
Austin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-05-2021 , 10:05   Re: What exactly is the "user id"
Reply With Quote #10

You use mostly player/client/entity index in SourcePawn functions.

In game events, it carry player userid, you convert that to player index.

playerid, clientid, entityid, player index, client index, entity index... there are many "names" for that.

Players are entities, both have indexs. It's a like array index.

What different between players and other entities is, game try utilize first 64 index for clients.
- It depends game engine and server max players slots. MaxClients give you right players size.

Game engine have max entity limit (edicts) https://developer.valvesoftware.com/wiki/Entity_limit
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode