Raised This Month: $51 Target: $400
 12% 

[REQ] Disallow player to kill himself with GRENADE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
crazyeffect
Veteran Member
Join Date: Jul 2008
Location: Belgium
Old 05-21-2009 , 11:15   [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #1

Hey,

I disabled 'kill' command in my server, so now the people use a grenade when they are a zombie!

So i need a plugin that disables the grenade kill
__________________
crazyeffect is offline
Send a message via MSN to crazyeffect
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-21-2009 , 18:19   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #2

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

#define DMG_GRENADE      (1 << 24)

new NoDamage;
new 
NoKill;


public 
plugin_init()
{
    
register_plugin("No Grenade Self-Kill/Damage""1.0""Dores");
    
    
NoDamage register_cvar("amx_no_self_nade_damage""1");
    
NoKill register_cvar("amx_no_self_nade_kill""1");
    
    
RegisterHam(Ham_TakeDamage"player""PrePlayerDamaged");
}

public 
PrePlayerDamaged(idinflictorattackerFloat:damagedamagebit)
{
    static 
noDamage;
    static 
noKill;
    if (     !
inflictor
    
||      id != attacker
    
||      !(damagebit DMG_GRENADE)
    ||      ( !(
noDamage get_pcvar_num(NoDamage)) && !(noKill get_pcvar_num(NoKill)) )      )
        return;
    
    if (
noDamage)
        
SetHamParamFloat(40.0);
    
    else if (
noKill)
    {
        static 
Float:health;
        
pev(idpev_healthhealth);
        
        
// the damage passed through this forward isn't accurate, but o well...
        
if (health <= damage)
        {
            
SetHamParamFloat(40.0);
            
set_pev(idpev_health1.0);
        }
    }

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 05-22-2009 at 06:05.
Dores is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-21-2009 , 19:13   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #3

You don't have to check classname, just check if damagebit & (1<<24)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-22-2009 , 00:14   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #4

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.

Code:
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
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "No Grenade Suicide"
#define VERSION "1.0"
#define AUTHOR "bugsy"

#define DMG_GRENADE    ( 1 << 24 )

new g_pAllowDamage;

public 
plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
    
    
g_pAllowDamage register_cvar"ngs_allowdamage" "1" );
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker FloatfDamage iBitDamage )
{
    if ( ( 
iVictim != iAttacker ) || !iInflictor || !( iBitDamage DMG_GRENADE ) )
        return 
HAM_IGNORED;

    new 
iCVar get_pcvar_numg_pAllowDamage );    
    new 
FloatfHealth;
    
peviVictim pev_health fHealth );

    return ( !
iCVar || ( iCVar && ( fDamage >= fHealth ) ) ) ? HAM_SUPERCEDE HAM_IGNORED;

__________________

Last edited by Bugsy; 05-22-2009 at 01:05.
Bugsy is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-22-2009 , 06:00   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
You don't have to check classname, just check if damagebit & (1<<24)
i've never heard of that bit. O_o
updated.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 05-22-2009 at 06:05.
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-22-2009 , 06:32   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #6

When you see the damagebits from a grenade you see it's always 16777216 so 1 << 24. Maybe in cs code a new DMG_* has been added.
Arkshine is offline
Cuttlas
Senior Member
Join Date: Jan 2015
Old 11-19-2023 , 07:51   Re: [REQ] Disallow player to kill himself with GRENADE
Reply With Quote #7

nice job bro
__________________
To Infinity n Beyond

Last edited by Cuttlas; 11-19-2023 at 08:09.
Cuttlas is offline
Reply



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 10:44.


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