Raised This Month: $ Target: $400
 0% 

Event shot with a specific weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-29-2009 , 09:06   Event shot with a specific weapon
Reply With Quote #1

how to register the event of shot with a specific weapon?
__________________
alan_el_more is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-29-2009 , 09:13   Re: Event shot with a specific weapon
Reply With Quote #2

RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_weaponname", "Forward_WeaponAttack").

Replace "weapon_weaponname" with the weapon_* names(i.e: weapon_deagle).
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-29-2009 , 09:15   Re: Event shot with a specific weapon
Reply With Quote #3

Quote:
Originally Posted by Dores View Post
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_weaponname", "Forward_WeaponAttack").

Replace "weapon_weaponname" with the weapon_* names(i.e: weapon_deagle).
thanks
__________________

Last edited by alan_el_more; 03-29-2009 at 09:23.
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-29-2009 , 09:16   Re: Event shot with a specific weapon
Reply With Quote #4

You can also use CurWeapon event and to filter it, or use VEN's method to catch weapons shot : http://forums.alliedmods.net/showthread.php?t=54887
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-29-2009 at 09:21.
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-29-2009 , 09:23   Re: Event shot with a specific weapon
Reply With Quote #5

and as i to determine the attacker and the victim?
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-29-2009 , 09:35   Re: Event shot with a specific weapon
Reply With Quote #6

The method you have to choose depend on if you want to catch all shots, or if you only want to catch shots that hit a player.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-29-2009 , 09:37   Re: Event shot with a specific weapon
Reply With Quote #7

what i want to make an item extra that the buy it, he gives you a awp and shoot infecting the victim
please don't do all the plugin
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-29-2009 , 10:07   Re: Event shot with a specific weapon
Reply With Quote #8

I would use Ham_TraceAttack, register it with classname "player", then if bitdamage is DMG_BULLET, then check if idattacker is between 1 and maxplayers, and then if attacker weapon is your custom infecting weapon.

Code:
	/**
	 * Description:		Usually called whenever an entity gets attacked by a hitscan (such as a gun) weapon.
	 *					Use the get/set tr2 natives in fakemeta to handle the traceresult data.
	 *					Do not use a handle of 0 as a traceresult in execution, use create_tr2() from Fakemeta
	 *					to pass a custom handle instead.  (Don't forget to free the handle when you're done.)
	 * Forward params:	function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
	 * Return type:		None.
	 * Execute params:	ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
	 */
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-29-2009 , 10:14   Re: Event shot with a specific weapon
Reply With Quote #9

i am means noob in this. can you explain how to use with an example?
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-29-2009 , 10:39   Re: Event shot with a specific weapon
Reply With Quote #10

PHP Code:
#include <amxmodx>
// #include <fakemeta>
#include <hamsandwich>

#define MAX_PLAYERS    32
#define IsPlayer(%1)    (1 <= %1 <= g_iMaxPlayers)

new g_iMaxPlayers
new g_bIsAlive[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)
    
RegisterHam(Ham_Killed"player""Player_Killed_Post"1)

    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage")

    
g_iMaxPlayers get_maxplayers()
}

public 
Player_Spawn_Post(id)
{
    
g_bIsAlive[id] = is_user_alive(id)
}

public 
Player_Killed_Post(id)
{
    
g_bIsAlive[id] = is_user_alive(id)
}

public 
Player_TakeDamage(idiInflictoriAttackerFloat:flDamagebitsDamageType)
{
    if(    
flDamage
    
&&    bitsDamageType == DMG_BULLET
    
&&    IsPlayer(iAttacker)
    &&    
g_bIsAlive[iAttacker]
    &&    
get_user_weapon(iAttacker) == CSW_AWP
//    &&    g_bHasInfectingAwp[iAttacker] // that's up to you
    
&&    pev(idpev_takedamage)
    {
        
// iAttacker has infected id
        // procced to infection there
        
        
return HAM_HANDLED
    
}
    return 
HAM_IGNORED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 09:03.


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