Mortal Headshot

Post Reply
User avatar
LookBehindYou
Administrator
Administrator
Posts: 145
Joined: Thu Nov 19, 2020 9:54 am

Description :
In case of headshot, you will kill in one shoot the enemy.
You can enable/disable this for each weapon.

Command
mh_weapon < weapon shortname > < value > (ADMIN_KICK flag is needed)
weapon shortname : See list below
value : 0 is disabled ; 1 is enabled

Weapons short names are :

Code: Select all

p228
scout
xm1014
mac10
aug
elite
fiveseven
ump45
sg550
galil
famas
usp
glock18
awp
mp5navy
m249
m3
m4a1
tmp
g3sg1
deagle
sg552
ak47
knife
p90
How to set cvars :

Put commands in ./amxmodx/amxx.cfg file

Examples :

Code: Select all

* mh_weapon < weapon shortname > < value >

Code: Select all

mh_weapon knife 1
mh_weapon glock 1
mh_weapon usp 0
Sma code :

Code: Select all

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

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

const bitsNotAllowedWeapons = 1 << CSW_SMOKEGRENADE | 1 << CSW_HEGRENADE | 1 << CSW_FLASHBANG | 1 << CSW_C4

new g_iMaxPlayers

new bool:g_weaponMortalHeadshot[ MAX_WEAPONS + 1 ]

public plugin_init() 
{
	register_plugin( "Mortal Headshot", "0.1.1", "eXtrem" )
	
	register_concmd( "mh_weapon", "ConsoleCommand_MortalHeadshot", ADMIN_KICK )
	
	RegisterHam( Ham_TraceAttack, "player", "HamTraceAttack" )
	
	g_iMaxPlayers = get_maxplayers()
}

public HamTraceAttack( victim, attacker, Float:damage, Float:tr[3], traceresult, dmgbits )
{
	if( !IsPlayer( attacker ) || victim == attacker )
		return HAM_IGNORED
	
	if( g_weaponMortalHeadshot[ get_user_weapon( attacker ) ] && get_tr2( traceresult , TR_iHitgroup ) == HIT_HEAD )
	{
		set_pev( victim, pev_health , 1 )
	}
	
	return HAM_IGNORED
}

public ConsoleCommand_MortalHeadshot( id, level, cid )
{
	if( !cmd_access( id, level, cid, 1 )  ) 
    { 
        return PLUGIN_HANDLED
    } 
	
	new szWeapon[ 32 ] = "weapon_"
		
	read_argv( 1, szWeapon[ 7 ], charsmax( szWeapon ) -7 )
	
	new weaponid = get_weaponid( szWeapon )
		
	if( weaponid && ~( 1 << weaponid ) & bitsNotAllowedWeapons )
	{
		new szValue[ 2 ]
		read_argv( 2, szValue, charsmax( szValue ) )
		
		g_weaponMortalHeadshot[ weaponid ] = szValue[ 0 ] == '0' ? false : true			
				
		console_print( id, "%s mortal headshot : %s", szWeapon, szValue[ 0 ] == '0' ? "disabled" : "enabled" )
	}
	
	return PLUGIN_HANDLED
}
Source : Alliedmodders
Image
Image
Image
Image

Discord: DoDeL#6420
Post Reply

Return to “Plugins”