Raised This Month: $51 Target: $400
 12% 

Questions about Client Index


Post New Thread Reply   
 
Thread Tools Display Modes
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 06-17-2013 , 11:23   Re: Questions about Client Index
Reply With Quote #21

I do not think he wants to use it for permanent storage; all he said was that he needed to store temporary information through a map change. Which means there is only going to be data saved for the players on the server at the time. Depending on what he needs it for, I would wipe the file before every map change, and then add the stuff you want to add to it.

If you wanted more specific help you need to give more details about what you are saving and how you want to save it.
Marcus_Brown001 is offline
ElooKoN
        ^_^
Join Date: Apr 2011
Old 06-18-2013 , 15:22   Re: Questions about Client Index
Reply With Quote #22

I am sure both userid and index do not change on mapchange.
ElooKoN is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 06-18-2013 , 15:28   Re: Questions about Client Index
Reply With Quote #23

You would be wrong ElooKoN. Here's a copy/paste from the wiki!

Quote:
Originally Posted by DAT WIKI
Client and Entity Indexes

One major point of confusion with Half-Life 2 is the difference between the following things:
Client index
Entity index
Userid
The first answer is that clients are entities. Thus, a client index and an entity index are the same thing. When a SourceMod function asks for an entity index, a client index can be specified. When a SourceMod function asks for a client index, usually it means only a client index can be specified.
A fast way to check if an entity index is a client is checking whether it's between 1 and GetMaxClients() (inclusive). If a server has N client slots maximum, then entities 1 through N are always reserved for clients. Note that 0 is a valid entity index; it is the world entity (worldspawn).
A userid, on the other hand, is completely different. The server maintains a global "connection count" number, and it starts at 1. Each time a client connects, the connection count is incremented, and the client receives that new number as their userid.
For example, the first client to connect has a userid of 2. If he exits and rejoins, his userid will be 3 (unless another client joins in-between). Since clients are disconnected on mapchange, their userids change as well. Userids are a handy way to check if a client's connection status has changed.
SourceMod provides two functions for userids: GetClientOfUserId() and GetClientUserId().
Edit: It seems Powerlord is correct, userids no longer chance on disconnect. Perhaps OrangeBox changed the functionality?
PHP Code:
map     mg_gravitycastle at0 x0 y0 z
players 
11 (48 max)

# userid name                uniqueid            connected ping loss state
#    762 "hitmanki11er7"     STEAM_0:0:48276855   2:08:05    84    0 active
#    814 "Hudalla"           STEAM_0:1:19650782  13:11       48    0 active
#    777 "LindseyBabyღ"    STEAM_0:1:34209071   1:23:19    70    0 active
#    816 "Morgan Freeman"    STEAM_0:0:51472988  07:35       70    0 active
#    788 "¨˜”°º•♛ℬℒϴϴĞ*********" STEAM_0:0:64207343  1:07:18   65    0 active
#    809 "[bG-T] Panduh"     STEAM_0:0:12812584  29:31      145    0 active
#    817 "Krackerjak"        STEAM_0:1:13762883  05:46       94    0 active
#    818 "Hyphin"            STEAM_0:0:48936535  05:06       60    0 active
#    819 "¤Brandon_J¤"     STEAM_0:0:11558870  03:05       76    0 active
#    821 "=7Cav=SPC.Velox.J" STEAM_0:1:19495538  01:56       85    0 active
#    822 "тнε cнσƨεп" STEAM_0:0:26072150 01:22      100    0 active


map     fun_matrix_trilogie at0 x0 y0 z
players 
10 (48 max)

# userid name                uniqueid            connected ping loss state
#    762 "hitmanki11er7"     STEAM_0:0:48276855   2:08:46   174    0 spawning
#    814 "Hudalla"           STEAM_0:1:19650782  13:53       48    0 active
#    777 "LindseyBabyღ"    STEAM_0:1:34209071   1:24:01    75    0 active
#    816 "Morgan Freeman"    STEAM_0:0:51472988  08:16      161    0 spawning
#    788 "¨˜”°º•♛ℬℒϴϴĞ*********" STEAM_0:0:64207343  1:08:00   59    0 active
#    809 "[bG-T] Panduh"     STEAM_0:0:12812584  30:12      141    0 active
#    818 "Hyphin"            STEAM_0:0:48936535  05:47      145    0 spawning
#    819 "¤Brandon_J¤"     STEAM_0:0:11558870  03:46      187    0 spawning
#    821 "=7Cav=SPC.Velox.J" STEAM_0:1:19495538  02:38      180    0 spawning
#    822 "тнε cнσƨεп" STEAM_0:0:26072150 02:04      198    0 spawning 
__________________

Last edited by thetwistedpanda; 06-18-2013 at 17:50.
thetwistedpanda is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-18-2013 , 16:43   Re: Questions about Client Index
Reply With Quote #24

Fine, I set up a plugin to log data on this and will report back later on my findings of whether client indexes change on map changes. I don't need to check if userids change, because I already know that they don't.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-18-2013 , 17:15   Re: Questions about Client Index
Reply With Quote #25

Here's my test data, taken from the attached plugin.

Powerlord is my fast desktop
rbemrose is my slow laptop

rbemrose was intentionally connected first to test if client indexes would be reordered during the first map change. And so I could kick it before the second map change.

rbemrose was kicked during ctf_doublecross.

Code:
L 06/18/2013 - 15:53:44: [testclientid_index.smx] Plugin Loaded
L 06/18/2013 - 15:53:48: [testclientid_index.smx] Map change to pl_upward
L 06/18/2013 - 15:53:48: [testclientid_index.smx] Client connected: Replay<2><STEAM_ID_PENDING><>, client: 1
L 06/18/2013 - 16:05:07: [testclientid_index.smx] Client connected: rbemrose<3><STEAM_ID_PENDING><>, client: 2
L 06/18/2013 - 16:06:41: [testclientid_index.smx] Client connected: Powerlord<4><STEAM_ID_PENDING><>, client: 3
L 06/18/2013 - 16:08:48: [testclientid_index.smx] Client disconnected: Replay<2><STEAM_ID_PENDING><>, client: 1
L 06/18/2013 - 16:08:48: [testclientid_index.smx] Client disconnected: rbemrose<3><STEAM_0:1:42523234><>, client: 2
L 06/18/2013 - 16:08:48: [testclientid_index.smx] Client disconnected: Powerlord<4><STEAM_0:0:1081621><>, client: 3
L 06/18/2013 - 16:08:52: [testclientid_index.smx] Map change to ctf_doublecross
L 06/18/2013 - 16:08:52: [testclientid_index.smx] Client connected: Replay<2><STEAM_ID_PENDING><>, client: 1
L 06/18/2013 - 16:08:53: [testclientid_index.smx] Client connected: Powerlord<4><STEAM_ID_PENDING><>, client: 3
L 06/18/2013 - 16:08:53: [testclientid_index.smx] Client connected: rbemrose<3><STEAM_ID_PENDING><>, client: 2
L 06/18/2013 - 16:10:11: [testclientid_index.smx] Client disconnected: rbemrose<3><STEAM_0:1:42523234><>, client: 2
L 06/18/2013 - 16:10:20: [testclientid_index.smx] Client disconnected: Replay<2><STEAM_ID_PENDING><>, client: 1
L 06/18/2013 - 16:10:20: [testclientid_index.smx] Client disconnected: Powerlord<4><STEAM_0:0:1081621><>, client: 3
L 06/18/2013 - 16:10:24: [testclientid_index.smx] Map change to ctf_2fort
L 06/18/2013 - 16:10:24: [testclientid_index.smx] Client connected: Replay<2><STEAM_ID_PENDING><>, client: 1
L 06/18/2013 - 16:10:24: [testclientid_index.smx] Client connected: Powerlord<4><STEAM_ID_PENDING><>, client: 3
L 06/18/2013 - 16:11:53: [testclientid_index.smx] Client disconnected: Powerlord<4><STEAM_0:0:1081621><>, client: 3
As you can see, after the last map (ctf_2fort) started, the only connected client indexes were Replay at index 1 and Powerlord at 3.

So, to reiterate, client indexes are kept across map changes, as are userids... and "DAT WIKI" really needs to be updated because it's blatantly wrong. In retrospect, I probably should have logged the kick in here as a kick instead of just a disconnect (whoops).
Attached Files
File Type: sp Get Plugin or Get Source (testclientid_index.sp - 182 views - 786 Bytes)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-18-2013 at 17:33.
Powerlord is offline
pilger
Senior Member
Join Date: Sep 2010
Old 06-18-2013 , 17:52   Re: Questions about Client Index
Reply With Quote #26

I guess this close the case.

Thanks Powerlord, I'd do that myself but I'm swamped with work for the next couple of weeks.

pilger is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 06-22-2013 , 06:17   Re: Questions about Client Index
Reply With Quote #27

Quote:
Originally Posted by Powerlord View Post
[...]So, to reiterate, client indexes are kept across map changes, as are userids...[...]
Of course they are. Tons of plugins rely on that.
Dr. Greg House is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-22-2013 , 23:18   Re: Questions about Client Index
Reply With Quote #28

Quote:
Originally Posted by Dr. Greg House View Post
Of course they are. Tons of plugins rely on that.
Yes, they do, but up until I went and edited the wiki page, it claimed they changed between maps.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 19:14.


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