Raised This Month: $ Target: $400
 0% 

Mirror Damage <hamsandwich>


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-02-2013 , 10:23   Mirror Damage <hamsandwich>
Reply With Quote #1

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?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-02-2013 , 11:59   Re: Mirror Damage <hamsandwich>
Reply With Quote #2

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

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-02-2013 at 12:01.
ConnorMcLeod is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-02-2013 , 12:30   Re: Mirror Damage <hamsandwich>
Reply With Quote #3

Thanks.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Reply


Thread Tools
Display Modes

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 21:39.


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