Raised This Month: $ Target: $400
 0% 

Receiver client index 0 is invalid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
climbw34468
Member
Join Date: Aug 2010
Old 12-02-2010 , 09:50   Receiver client index 0 is invalid
Reply With Quote #1

L 12/02/2010 - 22:44:09: [SM] Native "SetListenOverride" reported: Receiver client index 0 is invalid
L 12/02/2010 - 22:44:09: [SM] Displaying call stack trace for plugin "hear_new.smx":
L 12/02/2010 - 22:44:09: [SM] [0] Line 27, H:\sourcemod\sp\scripting(2)\hear_new.sp::Eve nt_PlayerTeamSwitch()


PHP Code:
public Event_PlayerTeamSwitch(Handle:event, const String:name[], bool:dontBroadcast)
{
new 
victim GetClientOfUserId(GetEventInt(event"userid"));
for(new 
i=1;i<GetMaxClients();i++)
{
if(
IsClientInGame(i) && IsClientConnected(i))
{
if(!
IsFakeClient(i))
{
SetListenOverride(victim,i,Listen_Default);
}
}
}
SetClientListeningFlags(victim,VOICE_NORMAL);

why???
climbw34468 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-02-2010 , 09:57   Re: Receiver client index 0 is invalid
Reply With Quote #2

PHP Code:
public Event_PlayerTeamSwitch(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    if (!
victim || !IsClientInGame(victim ) || !IsClientConnected(victim))
        return;

    for(new 
i=1;i<GetMaxClients();i++)
    {
        if(
IsClientInGame(i) && IsClientConnected(i))
        {
            if(!
IsFakeClient(i))
            {
                
SetListenOverride(victim,i,Listen_Default);
            }
        }
    }
    
SetClientListeningFlags(victim,VOICE_NORMAL);

You should check if victim is valid
Edit: Check IsClientConnected before IsClientInGame
__________________

Last edited by Silvers; 12-02-2010 at 10:51.
Silvers is offline
climbw34468
Member
Join Date: Aug 2010
Old 12-02-2010 , 10:08   Re: Receiver client index 0 is invalid
Reply With Quote #3

what does it mean
if (!victim)
climbw34468 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-02-2010 , 10:51   Re: Receiver client index 0 is invalid
Reply With Quote #4

Player indexes start from 1 and not 0 so you must check for this.

if (!victim) is the same as if (victim == 0) and
if (victim) is the same as if (victim != 0).
They will all evaluate to true. Any other number would evaluate the statement to false.

I forgot the ! before IsClientInGame and IsClientConnected... sorry I always do that by mistake
__________________
Silvers 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 22:58.


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