Raised This Month: $ Target: $400
 0% 

Set Damage for Different Distance and Weapons


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 03-12-2013 , 11:03   Set Damage for Different Distance and Weapons
Reply With Quote #1

The goal is to set different damage for different weapons for different distances of attacker and victim.

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

#define SHORT_RANGE    150
#define MEDIUM_RANGE    1000
#define LONG_RANGE    2000

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

new g_iMaxPlayers

new g_s_AKdmg

public plugin_init() 
{
    
register_plugin"""""" )
    
    
RegisterHamHam_TakeDamage"player""ham_TakeDamage" )
    
    
g_s_AKdmg register_cvar"amx_aksdmg""250" )
    
    
g_iMaxPlayers get_maxplayers()
}

public 
ham_TakeDamagevictiminflictorattackerFloat:damagedamagebits )
{
    if( !
is_user_alivevictim ) || !is_user_connectedattacker ) || !IsPlayerattacker ) )
        return 
HAM_SUPERCEDE;
        
    static 
iVOrigin], iAOrigin]
    static 
iDistance
    
new iGun get_user_weaponattacker )
        
    
get_user_originvictimiVOrigin )
    
get_user_originattackeriAOrigin )
        
    
iDistance get_distanceiVOriginiAOrigin )
    
    if( 
iDistance <= SHORT_RANGE )
    {
        switch( 
iGun )
        {
            case 
CSW_AK47
            {
                
damage get_pcvar_floatg_s_AKdmg )
                
SetHamParamFloat4damage )
            }
            
// Do the same for other weapons
        
}
    }
    
// Do the same for the other ranges..
    
    
return HAM_HANDLED;

Is there a better way to do it ?
__________________
Alekkkk is offline
Send a message via Skype™ to Alekkkk
 


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:42.


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