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

TF2: Get attacker weapon error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 03-22-2009 , 14:08   TF2: Get attacker weapon error
Reply With Quote #1

Having some error which I think is even crashing the server.

Can someone tell me whats wrong with this? It says the error. Im not seeing whats wrong with it. Its pointing to this line. GetClientWeapon(attacker, sWeapon, sizeof(sWeapon));

This is a player_hurt hook if that matters.


"zf_sounds.smx":
L 03/22/2009 - 10:41:01: [SM] [0] Line 219, zf_sounds.sp::Event_ZFplayerhurt()
L 03/22/2009 - 10:425: [SM] Native "GetClientWeapon" reported: Client index 0 is invalid
L 03/22/2009 - 10:425: [SM] Displaying call stack trace for plugin



Code:
public Action:Event_ZFplayerhurt(Handle:event, const String:name[],bool:dontBroadcast)
{
  if (g_enabled)
  {
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
      //Get attackers weapon
    decl String:sWeapon[32];
    GetClientWeapon(attacker, sWeapon, sizeof(sWeapon));
    //Check weapon
    //PrintToChatAll("\x01Current Weapon is: \x04%s", sWeapon);
    
    if (StrEqual("tf_weapon_bat",sWeapon))
    {
        new Float:vecPos[3];
      GetClientAbsOrigin(attacker, vecPos);
      EmitSoundToAll(g_aSound, attacker, SNDCHAN_AUTO, SNDLEVEL_NORMAL, _, 1.0, _, _, vecPos, _, true, 0.0);
    }
    if (StrEqual("tf_weapon_bat_wood",sWeapon))
    {
       new Float:vecPos[3];
     GetClientAbsOrigin(attacker, vecPos);
     EmitSoundToAll(g_aSound, attacker, SNDCHAN_AUTO, SNDLEVEL_NORMAL, _, 1.0, _, _, vecPos, _, true, 0.0);
    }
    if (StrEqual("tf_weapon_knife",sWeapon))
    {
       new Float:vecPos[3];
     GetClientAbsOrigin(attacker, vecPos);
     EmitSoundToAll(g_aSound, attacker, SNDCHAN_AUTO, SNDLEVEL_NORMAL, _, 1.0, _, _, vecPos, _, true, 0.0);
    }
    if (StrEqual("tf_weapon_fists",sWeapon))
    {
       new Float:vecPos[3];
     GetClientAbsOrigin(attacker, vecPos);
     EmitSoundToAll(g_bSound, attacker, SNDCHAN_AUTO, SNDLEVEL_NORMAL, _, 1.0, _, _, vecPos, _, true, 0.0);
    }
  }
  return Plugin_Continue;    
}
retsam is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 03-22-2009 , 14:29   Re: TF2: Get attacker weapon error
Reply With Quote #2

The attacker's index is 0 (server) so they're taking something like fall damage.
__________________
MikeJS is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 03-22-2009 , 17:18   Re: TF2: Get attacker weapon error
Reply With Quote #3

Humm...
retsam 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 13:12.


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