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

Displaying call stack trace for plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kikal767
Member
Join Date: Aug 2012
Old 10-23-2012 , 00:59   Displaying call stack trace for plugin
Reply With Quote #1

I have write a new plugins..and I got this error logs

PHP Code:
L 10/23/2012 12:43:05: [SMNative "GetEntPropEnt" reportedProperty "m_jockeyVictim" not found (entity 0/worldspawn)
L 10/23/2012 12:43:05: [SMDisplaying call stack trace for plugin "L4d2_Jockey acid swipe.smx":
L 10/23/2012 12:43:05: [SM]   [0]  Line 79D:\steamapps\common\left 4 dead 2\left4dead2\addons\sourcemod\scripting\L4d2_Jockey Acid Swipe.sp::Event_PlayerHurt() 
PHP Code:
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
Jockey GetClientOfUserId(GetEventInt(event"attacker"));
    new 
target GetClientOfUserId(GetEventInt(event"userid"));
    new 
duration GetConVarInt(FindConVar("sm_Jockey_acidswipe_duration"));
    new 
stack GetConVarInt(FindConVar("sm_Jockey_acidswipe_stack"));
    new 
Jockey_Victim GetEntPropEnt(JockeyProp_Send"m_jockeyVictim");
    
    
decl String:weapon[64];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
    if((
GetClientTeam(target) == 2) && (StrEqual(weapon"jockey_claw")))
    {
        if (
IsValidEntity(Jockey_Victim) && Jockey_Victim != 0)
        {
            return 
Plugin_Continue;
        } else
        {
            
attacker[target] = Jockey;
            if(
hurtsLeft[target] <= 0)
            {
                
hurtsLeft[target] = duration;
                
CreateTimer(1.0Acid_Damagetarget);
            } else
            {
                if(
stack == -1)
                {
                    
hurtsLeft[target] = duration;
                } else
                {
                    if(
stack >= 0)
                    {
                        
hurtsLeft[target] += stack;
                    } else
                    {
                        
//sm_Jockey_acidswipe_stack has invalid value so log error
                        
LogError("sm_Jockey_acidswipe_stack has an invalid value. Accepted values are -1 and higher.");
                    }
                }
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:Acid_Damage(Handle:timerany:client)
{
    if(
hurtsLeft[client] <= 0)
    {
        
attacker[client] = 0;
        return;
    } else
    {
        
hurtsLeft[client] -= 1;
    }
    if(
client == 0)
    {
        
attacker[client] = 0;
        
hurtsLeft[client] = 0;
        return;
    }
    if(!
IsClientInGame(client))
    {
        
attacker[client] = 0;
        
hurtsLeft[client] = 0;
        return;
    }
    if(!
IsPlayerAlive(client))
    {
        
attacker[client] = 0;
        
hurtsLeft[client] = 0;
        return;
    }
    if(
GetClientTeam(client) != 2)
    {
        
attacker[client] = 0;
        
hurtsLeft[client] = 0;
        return;
    }
    
#if defined DEBUG
    
    
EmitSoundToClient(ClientAcid_Sound);

    
#endif
    
    
DamageEffect(client);
    
    if(
hurtsLeft[client] > 0)
    {
        
CreateTimer(1.0Acid_Damageclient);
    }
    return;

PHP Code:
public OnMapStart()
{
    
PrecacheSound(Acid_Soundtrue);
}

public 
Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{

    if(
timer_handle != INVALID_HANDLE )
                {
                    
KillTimer(timer_handle);
                    
timer_handle=INVALID_HANDLE;
                }
    if(
timer_handle == INVALID_HANDLE)
                {
                    
timer_handle=CreateTimer(GetConVarFloat(sm_Jockey_Msg_time), Msg0TIMER_REPEAT);
                }
}

public 
Action:Event_RoundEnd(Handle:eventString:event_name[], bool:dontBroadcast)
{
    if(
timer_handle != INVALID_HANDLE)
    {
        
KillTimer(timer_handle);
        
timer_handle=INVALID_HANDLE;
    }


Last edited by kikal767; 10-23-2012 at 01:02.
kikal767 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-23-2012 , 01:12   Re: Displaying call stack trace for plugin
Reply With Quote #2

Attacker can be anything, not necessarily player, much less jockey. Add checks.
__________________
FaTony is offline
kikal767
Member
Join Date: Aug 2012
Old 10-23-2012 , 01:19   Re: Displaying call stack trace for plugin
Reply With Quote #3

Add checks like this?

PHP Code:
    if((GetClientTeam(target) == 2) && (StrEqual(weapon"jockey_claw")) && GetClientTeam(Jockey) == 3

Last edited by kikal767; 10-23-2012 at 01:31.
kikal767 is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 10-23-2012 , 02:11   Re: Displaying call stack trace for plugin
Reply With Quote #4

Much more like this
Code:
if(client > 0 && client <= MaxClients && IsClientInGame(client ))
Also you will get an error too if you check the team for an invalid index.

Yours sincerely
Impact
__________________

Last edited by Impact123; 10-23-2012 at 02:11.
Impact123 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-23-2012 , 03:45   Re: Displaying call stack trace for plugin
Reply With Quote #5

if this is valid net_prop you should move it inside the filter suggested by Impact123

PHP Code:
new Jockey_Victim GetEntPropEnt(JockeyProp_Send"m_jockeyVictim"); 
GsiX is offline
kikal767
Member
Join Date: Aug 2012
Old 10-23-2012 , 05:41   Re: Displaying call stack trace for plugin
Reply With Quote #6

Thanks all....

like this ?
PHP Code:
if((GetClientTeam(target) == 2) && (StrEqual(weapon"jockey_claw")) && (GetClientTeam(Jockey) == 3) && Jockey && Jockey <= MaxClients && IsClientInGame(Jockey)) 
OR like this
PHP Code:
if((GetClientTeam(target) == 2) && (StrEqual(weapon,  "jockey_claw")) && (GetClientTeam(Jockey) == 3)  &&  IsClientInGame(Jockey)) 
And thanks GsiX

Is the core like this?

PHP Code:
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
Jockey GetClientOfUserId(GetEventInt(event"attacker"));
    new 
target GetClientOfUserId(GetEventInt(event"userid"));

    
decl String:weapon[64];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
    if((
GetClientTeam(target) == 2) && (StrEqual(weapon"jockey_claw")) && (GetClientTeam(Jockey) == 3) && IsClientInGame(Jockey))
    {
        new 
Jockey_Victim GetEntPropEnt(JockeyProp_Send"m_jockeyVictim");
        if (
IsValidEntity(Jockey_Victim) && Jockey_Victim != 0)
        {
            return 
Plugin_Continue;
        } else
        {
            new 
duration GetConVarInt(FindConVar("sm_Jockey_acidswipe_duration"));
            new 
stack GetConVarInt(FindConVar("sm_Jockey_acidswipe_stack"));
            
            
attacker[target] = Jockey;
            if(
hurtsLeft[target] <= 0)
            {
                
hurtsLeft[target] = duration;
                
CreateTimer(1.0Acid_Damagetarget);
            } else
            {
                if(
stack == -1)
                {
                    
hurtsLeft[target] = duration;
                } else
                {
                    if(
stack >= 0)
                    {
                        
hurtsLeft[target] += stack;
                    } else
                    {
                        
//sm_Jockey_acidswipe_stack has invalid value so log error
                        
LogError("sm_Jockey_acidswipe_stack has an invalid value. Accepted values are -1 and higher.");
                    }
                }
            }
        }
    }
    return 
Plugin_Continue;


Last edited by kikal767; 10-23-2012 at 06:10.
kikal767 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-23-2012 , 10:21   Re: Displaying call stack trace for plugin
Reply With Quote #7

When use "player_hurt" event, "attacker" can return with invalid userid == 0,
happens when player hurt by fire, fall damage or get hurt something else than other player(s).

When try get client index by given userid,
GetClientOfUserId(userid) will return 0 if not found. 0 is invalid client index.

Valid client index is between 1 and your server maxplayers.

It is important to look first client index before continue check rest player things.

PHP Code:
public OnPluginStart()
{
    
HookEventEx("player_hurt"player_hurt);
}

public 
player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));

    if(
attacker == || attacker == victim// attacker else than player || attacker is victim
    
{
        return; 
// Don't continue callback
    
}

    new 
String:weapon[30];
    
GetEventString(event"weapon"weaponsizeof(weapon));

    if( !
StrEqual(weapon"jockey_claw") ) // weapon not "jockey_claw"
    
{
        return;
    }

    
// Add here your your rest code
    // attacker is jockey if weapon "jockey_claw", not need check team. If jockey not have more weapons.
    // victim should be survivor, I assume now those Special Infected can't hurt each other, I could be wrong.



sry bad english.

Last edited by Bacardi; 10-23-2012 at 10:22.
Bacardi is offline
kikal767
Member
Join Date: Aug 2012
Old 10-23-2012 , 13:59   Re: Displaying call stack trace for plugin
Reply With Quote #8

Thanks all....
I had knew a lot about player_hur !!!
kikal767 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-24-2012 , 03:04   Re: Displaying call stack trace for plugin
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
When use "player_hurt" event, "attacker" can return with invalid userid == 0,
happens when player hurt by fire, fall damage or get hurt something else than other player(s).

When try get client index by given userid,
GetClientOfUserId(userid) will return 0 if not found. 0 is invalid client index.
It can also be anything that does damage, not just 0.
__________________
FaTony 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:35.


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