AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Mirror Damage <hamsandwich> (https://forums.alliedmods.net/showthread.php?t=209824)

^SmileY 03-02-2013 10:23

Mirror Damage <hamsandwich>
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>

#define IsPlayer(%0) (1 <= %0 <= g_iMaxPlayers)

new g_iMaxPlayers;
new 
p_FriendlyFire;

public 
plugin_init()
{
    
register_plugin("Team Damage Mirror",AMXX_VERSION_STR,"SmileY");
    
    
RegisterHam(Ham_TakeDamage,"player","fw_HamTakeDamage");
    
    
g_iMaxPlayers get_maxplayers();
    
    
p_FriendlyFire get_cvar_pointer("mp_friendlyfire");
}

public 
fw_HamTakeDamage(iVictim,iInflictor,iAttacker,Float:fDamage,iDmgBits)
{
    if(
iVictim != iAttacker && IsPlayer(iAttacker) && is_user_alive(iAttacker) && get_user_team(iVictim) == get_user_team(iAttacker) && get_pcvar_num(p_FriendlyFire))
    {
        
SetHamParamEntity(1,iAttacker);
        
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED;


Its a correct way and secure?

ConnorMcLeod 03-02-2013 11:59

Re: Mirror Damage <hamsandwich>
 
Correct.

You can use following code, allow you to set mp_mirordamage to 0.3 (Used TraceAttack so you won't collect nades and falldamage):

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN ""

const m_iTeam 114
#define cs_get_user_team_index(%0)  get_pdata_int(%0, m_iTeam)

new g_iMaxPlayers
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

new mp_mirrordamagemp_friendlyfire

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
mp_mirrordamage get_cvar_pointer("mp_mirrordamage")
    
mp_friendlyfire get_cvar_pointer("mp_friendlyfire")
    
RegisterHam(Ham_TraceAttack"player""OnCBasePlayer_TraceAttack"false)
    
g_iMaxPlayers get_maxplayers()
}

public 
OnCBasePlayer_TraceAttack(idiAttackerFloat:flDamageFloat:fVecDir[3], ptrbitsDamageType)
{
    if( 
IsPlayer(iAttacker)
    &&  
id != iAttacker
    
&&  is_user_alive(iAttacker)
    &&  
cs_get_user_team_index(iAttacker) == cs_get_user_team_index(id)
    &&  
get_pcvar_num(mp_friendlyfire)  )
    {
        new 
Float:flMirorDamage get_pcvar_float(mp_mirrordamage)
        if( 
flMirorDamage )
        {
            
SetHamParamEntity(1iAttacker)
            
SetHamParamFloat(3flDamage flMirorDamage)
            
// SetHamParamVector(4, Float:{0.0,0.0,0.0}) // try this one if you get strange blood directions
            
return HAM_HANDLED
        
}
    }
    return 
HAM_IGNORED



^SmileY 03-02-2013 12:30

Re: Mirror Damage <hamsandwich>
 
Thanks.


All times are GMT -4. The time now is 21:39.

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