Raised This Month: $ Target: $400
 0% 

Ham_Weapon_PrimaryAttack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lycode
Junior Member
Join Date: Aug 2014
Old 08-08-2014 , 09:35   Re: Ham_Weapon_PrimaryAttack
Reply With Quote #1

Quote:
Originally Posted by hornet View Post
Rather than explaining what you think you need to do ( aka. the XY Problem ) to solve your problem, explain what you are actually trying to achieve in the end.
I'm setting a bool to true when the player is holding down their attack button while holding a grenade. I would like to set it to false when they release the button, not when the grenade is thrown. Is that possible through Ham_Weapon_PrimaryAttack?

Quote:
Originally Posted by PreDominance View Post
Isn't it possible to just hook the -attack clcmd?
Nope.
__________________
-This too shall pass
Lycode is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-08-2014 , 09:42   Re: Ham_Weapon_PrimaryAttack
Reply With Quote #2

Quote:
Originally Posted by Lycode View Post
I'm setting a bool to true when the player is holding down their attack button while holding a grenade. I would like to set it to false when they release the button, not when the grenade is thrown
Read my post again. For what purpose is this going to be used?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Lycode
Junior Member
Join Date: Aug 2014
Old 08-08-2014 , 09:48   Re: Ham_Weapon_PrimaryAttack
Reply With Quote #3

Quote:
Originally Posted by hornet View Post
Read my post again. For what purpose is this going to be used?
For various things. Like drawing a line to where the player is aiming using a TE_BEAMENTPOINT message.

Quote:
Originally Posted by Flick3rR View Post
Better hook the CmdStart forward and check for pev_buttons & IN_ATTACK. That's when your player holds the attack button.
That's what I'm trying to avoid.
__________________
-This too shall pass
Lycode is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-08-2014 , 10:10   Re: Ham_Weapon_PrimaryAttack
Reply With Quote #4

Quote:
Originally Posted by Lycode View Post
That's what I'm trying to avoid.
The engine usually only cares about whether IN_ATTACK is pressed so it can do stuff. There is no special event for letting go of the button. The engine only cares about IN_ATTACK not being set for initiating a reload on empty weapon (Ham_Weapon_Reload), automatically switching from an empty weapon to something else (Ham_Weapon_Deployed/Ham_Weapon_Holstered) and initiating the idle animation (Ham_Weapon_WeaponIdle). You could try experimenting with all of these and try to set up the right configuration to detect what you want. Obviously all of these events are not unique to letting go of the IN_ATTACK button.

Otherwise hooking FM_CmdStart is probably the right solution. It can be hooked on-demand if you would like, by hooking FM_CmdStart in Ham_Weapon_PrimaryAttack and immediately unhooking in FM_CmdStart once the button has been let go by all players.
__________________
In Flames we trust!
Nextra is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-08-2014 , 10:33   Re: Ham_Weapon_PrimaryAttack
Reply With Quote #5

Quote:
Originally Posted by Lycode View Post
For various things. Like drawing a line to where the player is aiming using a TE_BEAMENTPOINT message.
All information regarding your goal is relevant, in particular cases like this where very specific details are the key to making it work.
Relating back to your post using flashbangs, you could do something like this to detect such events:

Code:
#include <amxmodx> #include <hamsandwich> #define FLASHBANG_PULLPIN   1 #define FLASHBANG_THROW     2 public plugin_init() {     RegisterHam( Ham_CS_Weapon_SendWeaponAnim, "weapon_flashbang", "CFlashbang_SendWeaponAnim" ); } public CFlashbang_SendWeaponAnim( iEnt, iAnim ) {     switch( iAnim )     {         case FLASHBANG_PULLPIN:         {             //Attack button pressed by weapon owner         }                 case FLASHBANG_THROW:         {             //Attack button released by weapon owner         }     } }

Of course you would need to also account for weapon holster aswell.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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:07.


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