Raised This Month: $89 Target: $400
 22% 

Client index 0 is invalid?


Post New Thread Reply   
 
Thread Tools Display Modes
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-07-2014 , 21:07   Re: Client index 0 is invalid?
Reply With Quote #11

After some recheck I resolve the problem..sorry.. another question here: anyway find the fire damage?(from molotov or gas can)

Last edited by gilmon; 01-07-2014 at 21:07.
gilmon is offline
Send a message via MSN to gilmon
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-07-2014 , 22:14   Re: Client index 0 is invalid?
Reply With Quote #12

Quote:
Originally Posted by ReFlexPoison View Post
Cuz valve

Cuz whynot

Cuz does it really matter?

You can just recompile the plugin to your liking if you are going to use it.
I'm just saying it pointless in case someone was wondering, sure you can do as your liking but if you do it because your not sure, I can assure you that the event won't be called without a valid victim.
Mathias. is offline
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 00:09   Re: Client index 0 is invalid?
Reply With Quote #13

Oh my....
Quote:
Originally Posted by gilmon View Post
PHP Code:
    new attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victim GetEventInt(event"userid"); 
Nothing strange here?
P.S.: Second line.
__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-08-2014 , 06:13   Re: Client index 0 is invalid?
Reply With Quote #14

Quote:
Originally Posted by V952 View Post
Oh my....

Nothing strange here?
P.S.: Second line.
That one already change to
PHP Code:
new victim GetClientOfUserId(GetEventInt(event"userid")); 
gilmon is offline
Send a message via MSN to gilmon
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-08-2014 , 06:21   Re: Client index 0 is invalid?
Reply With Quote #15

The new error here after running a few hours:

PHP Code:
L 01/08/2014 18:46:10: [SMPlugin encountered error 8Not enough space on the stack
L 01
/08/2014 18:46:10: [SMDisplaying call stack trace for plugin "l4d2_antiTK.smx":
L 01/08/2014 18:46:10: [SM]   [0]  Line 502D:\L4D2\left4dead2\addons\sourcemod\scripting\include\entity_prop_stocks.inc::SetEntityHealth()
L 01/08/2014 18:46:10: [SM]   [1]  Line 61l4d2_antiTK.sp::Player_Hurt()
L 01/08/2014 18:46:46: [SMPlugin encountered error 8Not enough space on the stack
L 01
/08/2014 18:46:46: [SMDisplaying call stack trace for plugin "l4d2_antiTK.smx":
L 01/08/2014 18:46:46: [SM]   [0]  Line 502D:\L4D2\left4dead2\addons\sourcemod\scripting\include\entity_prop_stocks.inc::SetEntityHealth()
L 01/08/2014 18:46:46: [SM]   [1]  Line 61l4d2_antiTK.sp::Player_Hurt()
L 01/08/2014 18:48:02: [SMPlugin encountered error 8Not enough space on the stack
L 01
/08/2014 18:48:02: [SMDisplaying call stack trace for plugin "l4d2_antiTK.smx":
L 01/08/2014 18:48:02: [SM]   [0]  Line 502D:\L4D2\left4dead2\addons\sourcemod\scripting\include\entity_prop_stocks.inc::SetEntityHealth()
L 01/08/2014 18:48:02: [SM]   [1]  Line 61l4d2_antiTK.sp::Player_Hurt()
L 01/08/2014 18:50:59: [SMPlugin encountered error 8Not enough space on the stack
L 01
/08/2014 18:50:59: [SMDisplaying call stack trace for plugin "l4d2_antiTK.smx":
L 01/08/2014 18:50:59: [SM]   [0]  Line 502D:\L4D2\left4dead2\addons\sourcemod\scripting\include\entity_prop_stocks.inc::SetEntityHealth()
L 01/08/2014 18:50:59: [SM]   [1]  Line 61l4d2_antiTK.sp::Player_Hurt()
L 01/08/2014 18:52:05: [SMPlugin encountered error 8Not enough space on the stack
L 01
/08/2014 18:52:05: [SMDisplaying call stack trace for plugin "l4d2_antiTK.smx":
L 01/08/2014 18:52:05: [SM]   [0]  Line 502D:\L4D2\left4dead2\addons\sourcemod\scripting\include\entity_prop_stocks.inc::SetEntityHealth()
L 01/08/2014 18:52:05: [SM]   [1]  Line 61l4d2_antiTK.sp::Player_Hurt() 
PHP Code:
#include <sdktools>
#include <sourcemod>
#include <sdkhooks>
#pragma semicolon 1
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY

#define IsValidClient(%1)        (1 <= %1 <= MaxClients && IsClientInGame(%1))

#define PLUGIN_VERSION "1.0"

public Plugin:myinfo 
{
    
name "Anti TK",
    
author "xxx",
    
description "Anti survivor FF TK",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net/"
}

public 
OnPluginStart()
{
    
HookEvent("player_hurt"Player_Hurt);
}

public 
Action:Player_Hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
health;
    
    if(
IsValidClient(attacker) && IsValidClient(victim))
    {
        if(
GetClientTeam(attacker) == && GetClientTeam(victim) == 2)
        {
            new 
dmg_health GetEventInt(event"dmg_health");     // get the amount of damage done
            
            
health GetEntProp(attackerProp_Data"m_iHealth") - dmg_health;
            
SetEntProp(attackerProp_Data"m_iHealth"health);
            if(
GetEntProp(attackerProp_Data"m_iHealth") <= 1)
            {
                new 
iDmgEntity CreateEntityByName("point_hurt");
                
SetEntityHealth(attacker1);
                
DispatchKeyValue(attacker"targetname""bm_target");
                
DispatchKeyValue(iDmgEntity"DamageTarget""bm_target");
                
DispatchKeyValue(iDmgEntity"Damage""100");
                
DispatchKeyValue(iDmgEntity"DamageType""0");
                
DispatchSpawn(iDmgEntity);
                
AcceptEntityInput(iDmgEntity"Hurt"attacker);
                
DispatchKeyValue(attacker"targetname""bm_targetoff");
                
RemoveEdict(iDmgEntity);
                
PrintToChat(attacker"\x03DO NOT FF others anymore!\x01");
            }
        }
    }

What's wrong now? also plugin seem nothing working anymore.
gilmon is offline
Send a message via MSN to gilmon
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 08:58   Re: Client index 0 is invalid?
Reply With Quote #16

You are performing recursive damaging of yourself and getting your callback fired again and again and again.... this is not the correct way of doing it.
__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-08-2014 , 09:08   Re: Client index 0 is invalid?
Reply With Quote #17

Well.. this one just trying deal damage feedback to "attacker",so TK'er will be punish..
gilmon is offline
Send a message via MSN to gilmon
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 09:10   Re: Client index 0 is invalid?
Reply With Quote #18

And your event will be fired again, where attacker == victim && attacker's team == victim's team...
__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 09:12   Re: Client index 0 is invalid?
Reply With Quote #19

Try using OnTakeDamage virtual function hook. While in callback - use SDKHooks's TakeDamage function to damage entities; it'll not cause recursive event re-firing.
__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-08-2014 , 09:39   Re: Client index 0 is invalid?
Reply With Quote #20

Thanks for the help,sorry don't know how to call/hook this event,do you have any example?
gilmon is offline
Send a message via MSN to gilmon
Reply


Thread Tools
Display Modes

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 11:54.


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