AlliedModders

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

Backstabnoob 06-10-2010 15:08

Get shooting
 
Is there any event, which is called when player shoots from his weapon or an equal code?
I do not mean CurArray, I mean when someone shoots from weapon.

fezh 06-10-2010 15:12

Re: Get shooting
 
Ham_Weapon_PrimaryAttack ?

wrecked_ 06-10-2010 15:18

Re: Get shooting
 
FM_CmdStart, IN_ATTACK

Backstabnoob 06-10-2010 15:44

Re: Get shooting
 
Quote:

Originally Posted by fezh (Post 1205203)
Ham_Weapon_PrimaryAttack ?

What should I return when I want to block the attack? Sorry, kinda noob in returns of hamsandwich.

wrecked_ 06-10-2010 15:45

Re: Get shooting
 
Quote:

Originally Posted by Backstabnoob (Post 1205239)
What should I return when I want to block the attack? Sorry, kinda noob in returns of hamsandwich.

When you hook it, make sure it's Pre (4th param of RegisterHam as default or 0) then return HAM_SUPERCEDE in the function.

Backstabnoob 06-10-2010 16:06

Re: Get shooting
 
PHP Code:

    RegisterHam(Ham_Weapon_PrimaryAttack"player""Ham_PrimaryAttackHook"

PHP Code:

public Ham_PrimaryAttackHook(id)
{
    if(
g_Holster[id])
        return 
HAM_SUPERCEDE
    
    
return HAM_IGNORED


Does not work. (g_Holster[id] is 1)

Edit: Looks like it's not even called.

PHP Code:

public Ham_PrimaryAttackHook(id)
{
client_print(idprint_console"[Debug] Ham_PrimaryAttackHook: CALLED")
    if(
g_Holster[id])
        return 
HAM_SUPERCEDE
    
    
return HAM_IGNORED


nothing shows up in the console.

Brreaker 06-10-2010 16:41

Re: Get shooting
 
use console_print(id, "message");

Emp` 06-10-2010 16:41

Re: Get shooting
 
You have to register the ham with the weapon entity ("weapon_*"), not the player.

Backstabnoob 06-10-2010 16:42

Re: Get shooting
 
And if I want all weapons?

wrecked_ 06-10-2010 16:55

Re: Get shooting
 
Code:
public plugin_init() {     new wname[32]     for( new i = CSW_P228; i <= CSW_P90; i++ )     {         if( i != 2 )         {             get_weaponname( i, wname, 31 )             // format( wname, 31, "weapon_%s", wname )             RegisterHam( Ham_Weapon_PrimaryAttack, wname, "HamPrimaryAttackPre", 0 )         }     } }

Wasn't sure as to how get_weaponname() formats the return string. Let me know if it doesn't include weapon_, in which case you'd just have to uncomment that line with formatex().


All times are GMT -4. The time now is 05:23.

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