Raised This Month: $ Target: $400
 0% 

Questions about Client Index


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 06-14-2013 , 11:15   Questions about Client Index
Reply With Quote #1

So the client index is from 1 to <Maximum Number of Players In the Server>, 0 being the world.
I was in an impression that these indexes don't until a round ends, but that's just seems wrong.

I was storing information in an array as follows:

Code:
player_grenadeKills[MAXPLAYERS+1]
and use the array as follows:

Code:
onPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attackerClientID = GetEventInt(event, "attacker");
    if ( attackerClientID > 0 && attackerClientID <= MaxClients  )
    {
          player_grenadeKills[attackerClientID]++;
    }
}
which should contain its information until a new round starts, but it seems I was doing horribly wrong since "sometimes" it isn't working properly.

So when do these indexes change?
Do they change when someone connects or disconnects?

What are more efficient methods of doing this?
dilalmon is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 06-14-2013 , 11:52   Re: Questions about Client Index
Reply With Quote #2

Quote:
Do they change when someone connects or disconnects?
Yes.

Quote:
What are more efficient methods of doing this?
Set player_grenadeKills[client] = 0; in OnClientPutInServer or OnClientDisconnect.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 06-14-2013 , 12:00   Re: Questions about Client Index
Reply With Quote #3

When do the client indexes change?
What happens if a client with an index of 9 disconnects? Do players with an index of 10 or bigger get shifted by 1 in their index or does that index become vacant until a new client connects and fills it out?
dilalmon is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 06-14-2013 , 12:08   Re: Questions about Client Index
Reply With Quote #4

Client indexes are only recycled when it becomes available, such as when a client disconnects. So if 9 disconnects, and three people connect, someone is going to take the 9th index and then the next two available indexes. No other indexes will be affected. Each player also possess a userid, which can be considered unique for most purposes (they're reused after ~65,000 entries). For every successful connection the userid will be incremented by one.

In your OnPlayerDeath, you're using the player's userid. To obtain their client index, you'd have to GetClientOfUserId(GetEventInt(event, "attacker")).
__________________

Last edited by thetwistedpanda; 06-14-2013 at 12:08.
thetwistedpanda is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 06-14-2013 , 13:36   Re: Questions about Client Index
Reply With Quote #5

Great. Thanks Panda!
dilalmon is offline
pilger
Senior Member
Join Date: Sep 2010
Old 06-14-2013 , 23:46   Re: Questions about Client Index
Reply With Quote #6

I don't know if this might be considered thread hijacking but I have a question that fits on this subject.

Are the client indexes refreshed on map change? I mean, if a player get 9th index and the map change, will the player still use the 9th index or all the indexes will be reasigned to players on the order they connect after the map change?

Thanks in advance!
pilger is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-14-2013 , 23:53   Re: Questions about Client Index
Reply With Quote #7

Quote:
Originally Posted by pilger View Post
I don't know if this might be considered thread hijacking but I have a question that fits on this subject.

Are the client indexes refreshed on map change? I mean, if a player get 9th index and the map change, will the player still use the 9th index or all the indexes will be reasigned to players on the order they connect after the map change?

Thanks in advance!
All clients are fully disconnected and reconnected on mapchange. So yes, client indexes are refreshed on mapchange.
__________________
Dr. McKay is offline
pilger
Senior Member
Join Date: Sep 2010
Old 06-15-2013 , 00:09   Re: Questions about Client Index
Reply With Quote #8

Quote:
Originally Posted by Dr. McKay View Post
All clients are fully disconnected and reconnected on mapchange. So yes, client indexes are refreshed on mapchange.
Wouldn't this get in the way of using the method suggested here: https://forums.alliedmods.net/showpo...97&postcount=6 ?
Since all the clients are disconnected and reconnected and recieve new indexes, relying on them between map changes doesn't look like a good idea anymore.
pilger is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-15-2013 , 01:37   Re: Questions about Client Index
Reply With Quote #9

Quote:
Originally Posted by Dr. McKay View Post
All clients are fully disconnected and reconnected on mapchange. So yes, client indexes are refreshed on mapchange.
I'd double check that if I were you, since the server clearly knows the client hasn't completed disconnected since it doesn't fire the player_disconnected event for them.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-15-2013 , 01:55   Re: Questions about Client Index
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
I'd double check that if I were you, since the server clearly knows the client hasn't completed disconnected since it doesn't fire the player_disconnected event for them.
I'm just going off this.
__________________
Dr. McKay is offline
Reply


Thread Tools
Display Modes

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 17:18.


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