AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set Damage for Different Distance and Weapons (https://forums.alliedmods.net/showthread.php?t=210592)

Alekkkk 03-12-2013 11:03

Set Damage for Different Distance and Weapons
 
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 ?


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

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