Raised This Month: $ Target: $400
 0% 

Hook when a player USE a weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pfsm999
Senior Member
Join Date: Sep 2009
Old 02-06-2010 , 20:23   Hook when a player USE a weapons
Reply With Quote #1

Hi everyone,

I just want to know it's possible to hook the event : when a player just use a specific weapons. When player click the left button on the mouse to use the weapons selected ...

Thanks
__________________
Pfsm999 is offline
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 02-07-2010 , 10:52   Re: Hook when a player USE a weapons
Reply With Quote #2

SDKhooks... "SDKHook_FireBulletsPost"
miniman is offline
KawMAN
SourceMod Donor
Join Date: Sep 2007
Location: Cracov
Old 02-07-2010 , 10:58   Re: Hook when a player USE a weapons
Reply With Quote #3

maybe public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)

or SDKHooks SDKHook_WeaponSwitch
__________________
KawMAN is offline
Send a message via ICQ to KawMAN Send a message via Skype™ to KawMAN
psychonic

BAFFLED
Join Date: May 2008
Old 02-07-2010 , 11:14   Re: Hook when a player USE a weapons
Reply With Quote #4

I'm going to guess this is for TF2 since the OP has a TF2 server in his sig...

forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result);
http://docs.sourcemod.net/api/index....d=show&id=883&

^ that will fire for any weapon shot/melee swing/etc. as long as crits aren't disabled.
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-07-2010 , 11:17   Re: Hook when a player USE a weapons
Reply With Quote #5

Quote:
Originally Posted by miniman View Post
SDKhooks... "SDKHook_FireBulletsPost"
This would likely only work with hitscan weapons, like pistols, shotguns, and minigun.

Quote:
Originally Posted by KawMAN
maybe public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)

or SDKHooks SDKHook_WeaponSwitch
This would still be quite tedious because you would have to check that they have ammo and aren't already firing.
psychonic is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 02-07-2010 , 11:35   Re: Hook when a player USE a weapons
Reply With Quote #6

I think "use" differs from "fire".
FaTony is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-07-2010 , 12:29   Re: Hook when a player USE a weapons
Reply With Quote #7

Quote:
Originally Posted by FaTony View Post
I think "use" differs from "fire".
True, but reading is tough ^^

if that's the case then he indeed wants

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon);
{
    if ((
buttons IN_ATTACK) == IN_ATTACK)
    { 
psychonic is offline
Pfsm999
Senior Member
Join Date: Sep 2009
Old 02-07-2010 , 14:39   Re: Hook when a player USE a weapons
Reply With Quote #8

Thanks a lot !
Just one question :

I want to detect when a player use a specific weapon.
Can i use OnPlayerRunCommand to know that like that :

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon); 

    if ((
buttons IN_ATTACK) == IN_ATTACK
    {  
      new 
String:classname[64];
      
GetClientWeapon(clientclassname64);
      if(
StrEqual(classname"tf_weapon_lunchbox_drink"))
          ...............
   }

__________________

Last edited by Pfsm999; 02-07-2010 at 15:08.
Pfsm999 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 17:19.


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