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

Solved [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game


Post New Thread Reply   
 
Thread Tools Display Modes
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 01-17-2018 , 00:53   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #11

Quote:
Originally Posted by eyal282 View Post
not related to MaxClients at all.
And I said it doesn't matter. Think about the size of the array you're declaring. Think about what your loop indices are at the last iterations.
Fyren is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 01-17-2018 , 02:36   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #12

MaxClients-1 isn't recommended. Imagine having only 1 player on the server. That would be 1 - 1 = 0. That would result to client 0 (console/world).

As for MAXPLAYERS + 1, that accounts for the max players allowed on the server plus the console/world-spawn. The client count usually starts from Client 0 so that's what the + 1 is for.

Example: 32 player server

32 + 1 = Client 0, 1, 2, 3, ... 30, 31, 32
__________________
Psyk0tik is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-17-2018 , 02:56   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #13

Quote:
Originally Posted by Crasher_3637 View Post
MaxClients-1 isn't recommended. Imagine having only 1 player on the server. That would be 1 - 1 = 0. That would result to client 0 (console/world).

As for MAXPLAYERS + 1, that accounts for the max players allowed on the server plus the console/world-spawn. The client count usually starts from Client 0 so that's what the + 1 is for.

Example: 32 player server

32 + 1 = Client 0, 1, 2, 3, ... 30, 31, 32
Client indexes are entity indexes, and as you already pointed out, entity 0 is the console/world entity.

For a 32-player server, clients would be 1 through 32... but if you declare an array of size 32, it has indexes 0 through 31... hence the +1.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 01-17-2018 , 03:21   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #14

Quote:
Originally Posted by Powerlord View Post
Client indexes are entity indexes, and as you already pointed out, entity 0 is the console/world entity.

For a 32-player server, clients would be 1 through 32... but if you declare an array of size 32, it has indexes 0 through 31... hence the +1.
Basically:

PHP Code:
int iPlayerIndex[MAXPLAYERS 1]; //Clients 1-32
int iPlayerIndex[32 1]; //Clients 1-32
int iPlayerIndex[32]; //Clients 0-31 
__________________
Psyk0tik is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-17-2018 , 03:26   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #15

Quote:
Originally Posted by Crasher_3637 View Post
Basically:

PHP Code:
int iPlayerIndex[MAXPLAYERS 1]; //Clients 1-32
int iPlayerIndex[32 1]; //Clients 1-32
int iPlayerIndex[32]; //Clients 0-31 
No.

PHP Code:
int iPlayerIndex[MAXPLAYERS 1]; //66 indexes, clients 0 - 65
int iPlayerIndex[MAXPLAYERS]; //65 indexes, clients 0 - 64
int iPlayerIndex[32 1]; //33 indexes, clients 0-32
int iPlayerIndex[32]; //32 indexes, clients 0-31 
MAXPLAYERS is always 65. MaxClients is, basically, the number of player slots on the server. So you generally want to declare global arrays with size MAXPLAYERS+1, and non-global arrays with size MaxClients+1
__________________

Last edited by ddhoward; 01-17-2018 at 03:28.
ddhoward is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-17-2018 , 03:29   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #16

Quote:
Originally Posted by ddhoward View Post
No.

PHP Code:
int iPlayerIndex[MAXPLAYERS 1]; //66 indexes, clients 0 - 65
int iPlayerIndex[MAXPLAYERS]; //65 indexes, clients 0 - 64
int iPlayerIndex[32 1]; //33 indexes, clients 0-32
int iPlayerIndex[32]; //32 indexes, clients 0-31 
MAXPLAYERS is always 65. MaxClients is, basically, the number of player slots on the server.
I'm confused. When declaring an array that is designed to represent players, use MAXPLAYERS or MAXPLAYERS + 1?
eyal282 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-17-2018 , 03:32   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #17

Quote:
Originally Posted by eyal282 View Post
I'm confused. When declaring an array that is designed to represent players, use MAXPLAYERS or MAXPLAYERS + 1?
It depends. Are the indexes in the array supposed to represent the actual player indexes? If so, use the solution that causes the indexes to match the client indexes. In global arrays, this would be MAXPLAYERS+1. In non-global arrays, this would usually be MaxClients+1.

If the indexes in the array don't necessarily have to match the client indexes (for example, if the client indexes are the data being stored in the array...) then that extra index is unnecessary. You'd want to use MAXPLAYERS for global arrays and usually MaxClients for non-global.
__________________

Last edited by ddhoward; 01-17-2018 at 03:39.
ddhoward is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-17-2018 , 07:13   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #18

Quote:
Originally Posted by eyal282 View Post
I'm confused. When declaring an array that is designed to represent players, use MAXPLAYERS or MAXPLAYERS + 1?
MAXPLAYERS + 1

The reason being that CS:S (and CS:GO?) can have 64 players plus SourceTV. Meaning that client indexes are 1-65 and you need an array of size 66.

Edit: Take into consideration what ddhoward said about MaxClients + 1 first, though.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 01-17-2018 at 07:14.
Powerlord is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-17-2018 , 07:58   Re: [ANY] Native "ChangeClientTeam" reported: Client 32 is not in game
Reply With Quote #19

Quote:
Originally Posted by Powerlord View Post
MAXPLAYERS + 1

The reason being that CS:S (and CS:GO?) can have 64 players plus SourceTV. Meaning that client indexes are 1-65 and you need an array of size 66.

Edit: Take into consideration what ddhoward said about MaxClients + 1 first, though.
And when I make a plugin exclusive to L4D2?
eyal282 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 01:16.


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