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

Problem with getting all clients.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WaterRatj
Junior Member
Join Date: Dec 2009
Old 07-28-2015 , 04:12   Problem with getting all clients.
Reply With Quote #1

I'm trying to execute something for each player but for some reason it always gives the error

[SM] Native "GetClientAuthId" reported: Client index 0 is invalid

using this code

Code:
for ( new x = 1; x < MAXPLAYERS+1; x++)
{
    if ( Client_IsIngame(x) )
    {
        new clientPlayer = GetClientOfUserId(x);
        
        new String:steamidPlayer[32];
        GetClientAuthId(clientPlayer, AuthId_Steam3, steamidPlayer, sizeof(steamidPlayer));
    }
}
this is only a part of the code. the part that fires the error.

I put 1 - maxplayers i don't understand why it comes a cross 0 then?

Last edited by WaterRatj; 07-28-2015 at 04:13.
WaterRatj is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 07-28-2015 , 04:16   Re: Problem with getting all clients.
Reply With Quote #2

Code:
for ( new x = 1; x <= MaxClients; x++ ) {

    if ( !IsValidClient ( x ) || !IsClientInGame ( x ) )
        continue;

    //new clientPlayer = GetClientOfUserId(x);
        
    new String:steamidPlayer[32];
    GetClientAuthId(x, AuthId_Steam3, steamidPlayer, sizeof(steamidPlayer));

    // now you can use steamidPlayer for x player

}

stock IsValidClient ( client ) {

	if ( !( 1 <= client <= MaxClients ) || !IsClientInGame ( client ) )
		return false;

	return true;
}

Last edited by hadesownage; 07-28-2015 at 04:18.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 07-28-2015 , 04:17   Re: Problem with getting all clients.
Reply With Quote #3

PHP Code:
for(new 1<= MaxClients;i++)
{
if (
IsClientInGame(i))
{
// Do something
}

__________________
SourcePawn, C# and C++ Programmer.

My plugin list

Last edited by TheUnderTaker; 07-28-2015 at 04:17.
TheUnderTaker is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-28-2015 , 04:18   Re: Problem with getting all clients.
Reply With Quote #4

PHP Code:
for (new 1MAXPLAYERSi++)
{
    if (
IsClientInGame(i))
    {
        new 
clientPlayer GetClientOfUserId(x);
           
        new 
String:steamidPlayer[32];
        
GetClientAuthId(clientPlayerAuthId_Steam3steamidPlayersizeof(steamidPlayer));
    }


Last edited by headline; 07-28-2015 at 04:21.
headline is offline
WaterRatj
Junior Member
Join Date: Dec 2009
Old 07-28-2015 , 04:29   Re: Problem with getting all clients.
Reply With Quote #5

Using that code still fires the error
WaterRatj is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 07-28-2015 , 04:32   Re: Problem with getting all clients.
Reply With Quote #6

Quote:
Originally Posted by WaterRatj View Post
Using that code still fires the error
Send me full code here or in P.M.
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline
WaterRatj
Junior Member
Join Date: Dec 2009
Old 07-28-2015 , 04:37   Re: Problem with getting all clients.
Reply With Quote #7

Are you getting my messages ? cause they don't show up in my sent messages
WaterRatj is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 07-28-2015 , 04:39   Re: Problem with getting all clients.
Reply With Quote #8

You cannot pass a client index to GetClientOfUserId. Remove the GetClientOfUserId function and use your x variable directly, it's already a client index. You should also use MaxClients (without the +1) instead of MAXPLAYERS.
__________________

Last edited by Impact123; 07-28-2015 at 04:42.
Impact123 is offline
WaterRatj
Junior Member
Join Date: Dec 2009
Old 07-28-2015 , 04:44   Re: Problem with getting all clients.
Reply With Quote #9

Thanks! Those two confuse me sometimes
WaterRatj is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 07-28-2015 , 07:37   Re: Problem with getting all clients.
Reply With Quote #10

GetClientAuthId still working in 1.7?
__________________
Benoist3012 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 17:22.


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