This will block players from suicide via grenade. There is a cvar that, if enabled, will allow players to still receive damage from grenades but will not allow them to die from them. If the cvar is disabled then all grenade damage is blocked. Grenades thrown by other players will still issue damage as normal.
Example, with cvar ngs_allowdamage = 1
Player starts round with 100 health and attempts to kill self with 4 nades.
Grenade 1 issues 50 dmg, health = 50
Grenade 2 issues 25 dmg, health = 25
Grenade 3 issues 30 dmg, dmg blocked, health = 25 ( since 30 dmg > 25 health )
Grenade 4 issues 10 dmg, health = 15
If cvar ngs_allowdamage = 0 then all grenade damage is blocked
#define PLUGIN "No Grenade Suicide"
#define VERSION "1.0"
#define AUTHOR "bugsy"
#define DMG_GRENADE ( 1 << 24 )
register_plugin( PLUGIN , VERSION , AUTHOR );
RegisterHam( Ham_TakeDamage , "player" , "fw_HamTakeDamage" );
g_pAllowDamage = register_cvar( "ngs_allowdamage" , "1" );
public fw_HamTakeDamage( iVictim , iInflictor , iAttacker , Float: fDamage , iBitDamage )
if ( ( iVictim != iAttacker ) || !iInflictor || !( iBitDamage & DMG_GRENADE ) )
new iCVar = get_pcvar_num( g_pAllowDamage );
new Float: fHealth;
pev( iVictim , pev_health , fHealth );
return ( !iCVar || ( iCVar && ( fDamage >= fHealth ) ) ) ? HAM_SUPERCEDE : HAM_IGNORED;