AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Event shot with a specific weapon (https://forums.alliedmods.net/showthread.php?t=88803)

alan_el_more 03-29-2009 09:06

Event shot with a specific weapon
 
how to register the event of shot with a specific weapon?

Dores 03-29-2009 09:13

Re: Event shot with a specific weapon
 
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_weaponname", "Forward_WeaponAttack").

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

alan_el_more 03-29-2009 09:15

Re: Event shot with a specific weapon
 
Quote:

Originally Posted by Dores (Post 792139)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_weaponname", "Forward_WeaponAttack").

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

thanks :D

ConnorMcLeod 03-29-2009 09:16

Re: Event shot with a specific weapon
 
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

alan_el_more 03-29-2009 09:23

Re: Event shot with a specific weapon
 
and as i to determine the attacker and the victim?

ConnorMcLeod 03-29-2009 09:35

Re: Event shot with a specific weapon
 
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.

alan_el_more 03-29-2009 09:37

Re: Event shot with a specific weapon
 
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 :D

ConnorMcLeod 03-29-2009 10:07

Re: Event shot with a specific weapon
 
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);
        */


alan_el_more 03-29-2009 10:14

Re: Event shot with a specific weapon
 
i am means noob in this. can you explain how to use with an example?

ConnorMcLeod 03-29-2009 10:39

Re: Event shot with a specific weapon
 
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




All times are GMT -4. The time now is 09:03.

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