AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Native "IsFakeClient" reported: Client index 0 is invalid (https://forums.alliedmods.net/showthread.php?t=74946)

exvel 07-27-2008 17:38

Native "IsFakeClient" reported: Client index 0 is invalid
 
What is wrong with this?
Code:

public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
        new client = GetClientOfUserId(GetEventInt(event, "userid"));       
        if (IsFakeClient(client))
        {
                return;
        }
        // some code
}

Error:
Code:

[SM] Native "IsFakeClient" reported: Client index 0 is invalid
[SM] Displaying call stack trace for plugin "test-plugin.smx":
[SM]  [0]  Line 64, /home/groups/sourcemod/upload_tmp/phpRz9Q5o.sp::Event_PlayerTeam()

Tried to add function that prints to chat current client value for diagnostic but it tells me 21 (not 0). :(

bl4nk 07-27-2008 17:57

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
Are you trying this on a listen server?

teame06 07-27-2008 18:10

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
Code:
new client = GetClientOfUserId(GetEventInt(event, "userid"));   // Means the client not connected. if(!client) {      return; }

exvel 07-27-2008 18:11

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
bl4nk, no, I am running SRCDS. But it runs on the same computer from which I start the game for testing.

exvel 07-27-2008 18:13

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
Quote:

Originally Posted by teame06 (Post 660039)
Code:
new client = GetClientOfUserId(GetEventInt(event, "userid"));   // Means the client not connected. if(!client) {      return; }

I think here is something else. Because if I use PrintToChat(client, message) it works fine, so client (me) is connected.

exvel 07-27-2008 18:19

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
Sorry. It really works.
Thanks, teame06 for helping but I dont understand wich client fires this event with clinet=0... world? :)

teame06 07-27-2008 19:23

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
Quote:

Originally Posted by exvel (Post 660047)
Sorry. It really works.
Thanks, teame06 for helping but I dont understand wich client fires this event with clinet=0... world? :)

When GetClientOfUserId return 0 it means the client is from the server. player_team event fire off when the client disconnect too.

Check the structure of the event next time. It has a parameter which says disconnect

Kigen 07-27-2008 22:10

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
0 refers to the console generally. 0 is not a valid client index of course. Only 1-GetMaxClients() are valid client indexes.

mitchdb 07-29-2008 15:34

Re: Native "IsFakeClient" reported: Client index 0 is invalid
 
You need to check to make sure the client is connected ( IsClientConnected ) before you try to check if it is fake


All times are GMT -4. The time now is 21:53.

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