AlliedModders

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

ironskillz1 06-04-2013 10:52

Detect Shoot
 
Why doesnt it print in the chat when i shoot with a USP?
it doesnt print anything

Code:

RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_usp", "Ham_Attack" )
Code:

public Ham_Attack( entity )
{
 new id = get_pdata_cbase( entity, 41, 4 )
 
 ColorChat(0, GREY, "Start 1")
 
 if( is_user_alive( id ) )
 {
  ColorChat(0, GREY, "Start 2")
  if( !cs_get_weapon_ammo( entity) )
 
  ColorChat(0, GREY, "Start 3")
  if( GAME_LASER <= CurrentGame)
  {
  ColorChat(0, GREY, "Start 4")
  Player_ShootLaser(id)
  set_pdata_float(entity, 47, 9999.0, 4 )
  }
 }
 return HAM_IGNORED
}


hornet 06-04-2013 10:54

Re: Detect Shoot
 
Retrieve pev_owner with pev().

TheDS1337 06-04-2013 10:58

Re: Detect Shoot
 
I think this is not the write forwards to use it to detect when you shoot, try use TraceAttack

hornet 06-04-2013 11:07

Re: Detect Shoot
 
Quote:

Originally Posted by DeagLe.Studio (Post 1964363)
I think this is not the write forwards to use it to detect when you shoot, try use TraceAttack

It can definately be hooked more efficiently for this case. There's a tutorial on "properly catching shot event".

EpicMonkey 06-04-2013 11:13

Re: Detect Shoot
 
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_usp", "Ham_Attack" )

will be called when +attack is used even if the weapon has 0 ammo

hornet 06-04-2013 19:50

Re: Detect Shoot
 
Quote:

Originally Posted by EpicMonkey (Post 1964374)
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_usp", "Ham_Attack" )

will be called when +attack is used even if the weapon has 0 ammo

Hence why I said it can be hooked more efficiently ;)

fl0werD 06-04-2013 20:16

Re: Detect Shoot
 
Test my code!
PHP Code:

RegisterHamHam_Weapon_PrimaryAttack"weapon_usp""CUSP__PrimaryAttack_Pre", .Post ); 

PHP Code:

public CUSP__PrimaryAttack_PreiEntity )
{
    if( 
pev_validiEntity ) != )
        return;

    new 
iPlayer get_pdata_cbaseiEntity41 );

    
client_printiPlayerprint_chat"Paukan vzorvis'!!" );




All times are GMT -4. The time now is 16:22.

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