Raised This Month: $ Target: $400
 0% 

Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 11-17-2015 , 17:11   Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #1

Hi all,
i got extensive log errors on this plugin
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.30"

/*ChangeLog
1.00    Release
1.10    Totals for Admin
1.20    Reset Options
1.30    Punish option
*/

#define SURVIVOR    2
#define ZOMBIE        3
#define READY        4

public Plugin:myinfo =
{
    
name "ZPS Barricade Killer",
    
author "Will2Tango, Edited by JonnyBoy0719",
    
description "Notification when a Survivor Kills a Barricade.",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net"
}

//Cvars
new Handle:hEnabled INVALID_HANDLE;
new 
Handle:hPunish INVALID_HANDLE;
new 
Handle:hPunishscale INVALID_HANDLE;
new 
Handle:hReset INVALID_HANDLE;

new 
bool:gEnabled true;
new 
gReset 1;
new 
gPunish 0;
new 
gPunishscale 1;

//Player Vars
new cadeKillCount[MAXPLAYERS+1] = {0, ...};

public 
OnPluginStart()
{
    
//Cvars
    
CreateConVar("zps_barricadekiller_version"PLUGIN_VERSION"ZPS Barricade Killer Version."FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
hEnabled CreateConVar("sm_barricadekiller_enabled""1""Turns Barricade Killer Off/On. (1/0)"FCVAR_PLUGINtrue0.0true1.0);
    
hPunish CreateConVar("sm_barricadekiller_punish""0""Punish the person who broke it, 0=disabled, 1=slap."FCVAR_PLUGINtrue0.0true1.0);
    
hPunishscale CreateConVar("sm_barricadekiller_punishscale""1""Set the slap damage, 1=min, 99=max."FCVAR_PLUGINtrue0.0true99.0);
    
hReset CreateConVar("sm_barricadekiller_reset""2""When to reset Running Totals, 0=never, 1=map, 2=round."FCVAR_PLUGINtrue0.0true2.0);
    
    
HookConVarChange(hEnabledConVarChange);
    
HookConVarChange(hPunishConVarChange);
    
HookConVarChange(hPunishscaleConVarChange);
    
HookConVarChange(hResetConVarChange);
    
    
//Hooks
    
HookEvent("break_prop"SomethingBroke);
    
HookEvent("player_spawn"PlayerSpawn);
    
    
//Translations
    
LoadTranslations("barricadekiller.phrases");
}

public 
ConVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) 
{
    
gEnabled GetConVarBool(hEnabled);
    
gPunish GetConVarBool(hPunish);
    
gPunishscale GetConVarBool(hPunishscale);
    
gReset GetConVarInt(hReset);
}

public 
OnMapEnd()
{
    if (
gEnabled && gReset == 1)
    {
        for (new 
1MaxClientsi++)
        {
            if(
IsClientInGame(i) && !IsFakeClient(i))
            {
                
cadeKillCount[i] = 0;
            }
        }
    }
}

public 
Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
gEnabled && gReset == 2)
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        new 
team GetClientTeam(client);
        
        if (
team == READY)
        {
            
cadeKillCount[client] = 0;
        }
    }
}

public 
Action:SomethingBroke(Handle:event, const String:name[], bool:dontBroadcast)
{    
    if (!
gEnabled)
    {
        return;
    }

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
team GetClientTeam(client);
    
    if (
team == SURVIVOR)
    {
        new 
ent GetEventInt(event"entindex");
        
        
decl String:model[128];
        
GetEntPropString(entProp_Data"m_ModelName"modelsizeof(model));
        
        if (
StrContains(model"/barricades/"false) != -1)
        {
            
cadeKillCount[client]++;
            
            new 
String:killerName[MAX_NAME_LENGTH];
            
GetClientName(clientkillerNamesizeof(killerName));
            
            new 
total cadeKillCount[client];
            new 
flags;
            
            for (new 
1MaxClientsi++)
            {
                if(
IsClientInGame(i) && !IsFakeClient(i))
                {
                
                    if (
gPunish == 1)
                    {
                        
SlapPlayer(clientgPunishscale);
                    }
                
                    if (
== client)
                    {
                        if (
gPunish == 1)
                        {
                            
PrintToChat(i"[SM] %t""You_Punish");
                        }
                        else
                        {
                            
PrintToChat(i"[SM] %t""You");
                        }
                    }
                    else
                    {
                        
flags GetUserFlagBits(i);
                        
                        if (
flags ADMFLAG_ROOT || flags ADMFLAG_GENERIC)
                        {
                            if (
gPunish == 1)
                            {
                                
PrintToChat(i"[SM] %t""Admin_Punish"killerNametotal);
                            }
                            else
                            {
                                
PrintToChat(i"[SM] %t""Admin"killerNametotal);
                            }
                        }
                        else if (
GetClientTeam(i) == SURVIVOR)
                        {
                            if (
gPunish == 1)
                            {
                                
PrintToChat(i"[SM] %t""All_Punish"killerName);
                            }
                            else
                            {
                                
PrintToChat(i"[SM] %t""All"killerName);
                            }
                        }
                    }
                }
            }
            
            
LogMessage("%L Broke a Baricade! (%i)"clienttotal);
        }
    }

error log
[SM] Native "GetClientTeam" reported: Client index 0 is invalid
[SM] Displaying call stack trace for plugin "barricadekiller.smx":
[SM] [0] Line 106, .attach::SomethingBroke()
unscarred is offline
Hartmann
Senior Member
Join Date: Nov 2014
Old 11-17-2015 , 18:18   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #2

You posted in Amx Mod X.

Maybe:

Code:
 if (IsClientInGame(client)
		new team = GetClientTeam(client);
__________________

RETAKES v1.0
github.com/alghtryer/retakes

Contact : [email protected]

BTC Donate: 1QAh1NLmeHy81LF9r8PaeGjYqHL2BBcJTx

Hartmann is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-17-2015 , 18:45   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #3

Moved to SM
__________________
Bugsy is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-17-2015 , 19:43   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #4

Replace

PHP Code:
    new client GetClientOfUserId(GetEventInt(event"userid")); 
    new 
team GetClientTeam(client); 
with

PHP Code:
    new client GetClientOfUserId(GetEventInt(event"userid")); 
    if (
client == 0)
        return;
    new 
team GetClientTeam(client); 
Potato Uno is offline
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 11-18-2015 , 17:50   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #5

Quote:
Originally Posted by Potato Uno View Post
Replace

PHP Code:
    new client GetClientOfUserId(GetEventInt(event"userid")); 
    new 
team GetClientTeam(client); 
with

PHP Code:
    new client GetClientOfUserId(GetEventInt(event"userid")); 
    if (
client == 0)
        return;
    new 
team GetClientTeam(client); 

Thanks bro !! no more error logs !
do you have paypal account ? i want donate for you.
unscarred is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-18-2015 , 18:08   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #6

I don't have a paypal but if you want to donate you can donate to AlliedModders here: http://sourcemod.net/donate.php
Potato Uno is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-18-2015 , 18:13   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #7

If everyone would donate everytime someone would help them with a fix for an error like that alliedmodders would have a lot of donations ;D
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
unscarred
Member
Join Date: Dec 2009
Location: cs 1.6
Old 11-18-2015 , 18:24   Re: Help to fix errors Native "GetClientTeam" reported: Client index 0 is invalid
Reply With Quote #8

Quote:
Originally Posted by Potato Uno View Post
I don't have a paypal but if you want to donate you can donate to AlliedModders here: http://sourcemod.net/donate.php
ok done !
thanks
unscarred 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 03:15.


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