AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Weapon_PrimaryAttack (https://forums.alliedmods.net/showthread.php?t=245767)

Lycode 08-06-2014 15:40

Ham_Weapon_PrimaryAttack
 
Is it possible to detect -attack in Ham_Weapon_PrimaryAttack?

get_pdata_int(id, m_afButtonReleased, XO_CBASEPLAYER) & IN_ATTACK is not working for me.

If not then what would be the next best option to detect -attack after doing a couple of checks in Ham_Weapon_PrimaryAttack.

alan_el_more 08-06-2014 16:27

Re: Ham_Weapon_PrimaryAttack
 
Show your code

Lycode 08-07-2014 13:48

Re: Ham_Weapon_PrimaryAttack
 
My first post had sufficient information to answer the question, but:

PHP Code:

RegisterHam(Ham_Weapon_PrimaryAttack"weapon_flashbang""fwd_flashbang"); 

PHP Code:

public fwd_flashbang(ent)
{
    new 
id get_pdata_cbase(entm_pPlayerXO_CBASEPLAYERITEM);
    if(
get_pdata_int(idm_afButtonReleasedXO_CBASEPLAYER) & IN_ATTACK)
    {
       
client_print(idprint_chat"-attack");
    }



meTaLiCroSS 08-08-2014 02:30

Re: Ham_Weapon_PrimaryAttack
 
What do you want to check exactly?

Lycode 08-08-2014 05:05

Re: Ham_Weapon_PrimaryAttack
 
Within the Ham_Weapon_PrimaryAttack forward, I'm checking if the player released their attack key. Is that even possible as the forward is called when you're holding down attack?

If that is not possible, what would be my best option? Efficiency wise.

hornet 08-08-2014 07:39

Re: Ham_Weapon_PrimaryAttack
 
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.

PreDominance 08-08-2014 08:13

Re: Ham_Weapon_PrimaryAttack
 
Isn't it possible to just hook the -attack clcmd?

Lycode 08-08-2014 09:35

Re: Ham_Weapon_PrimaryAttack
 
Quote:

Originally Posted by hornet (Post 2180916)
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 (Post 2180930)
Isn't it possible to just hook the -attack clcmd?

Nope.

hornet 08-08-2014 09:42

Re: Ham_Weapon_PrimaryAttack
 
Quote:

Originally Posted by Lycode (Post 2180973)
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?

Flick3rR 08-08-2014 09:42

Re: Ham_Weapon_PrimaryAttack
 
Better hook the CmdStart forward and check for pev_buttons & IN_ATTACK. That's when your player holds the attack button.


All times are GMT -4. The time now is 13:07.

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