Raised This Month: $ Target: $400
 0% 

HE grenadefriedly fire off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 10-27-2011 , 20:24   HE grenadefriedly fire off
Reply With Quote #1

Is it possible to turn friendly fire off only for he grenades?
__________________
zipcore is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-27-2011 , 23:43   Re: HE grenadefriedly fire off
Reply With Quote #2

here simple code.
required sdkhooks
PHP Code:
#include <sdkhooks>

new Handle:mp_friendlyfire INVALID_HANDLE;
new 
bool:friendlyfire false;

public 
OnPluginStart()
{
    if((
mp_friendlyfire FindConVar("mp_friendlyfire")) == INVALID_HANDLE)
    {
        
SetFailState("Missing mp_friendlyfire");
    }

    
HookConVarChange(mp_friendlyfireconvar_changed);

    
// Plugin loaded during game...
    
if((friendlyfire GetConVarBool(mp_friendlyfire)))
    {
        
convar_changed(mp_friendlyfire"0""1");
    }
}

public 
convar_changed(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == mp_friendlyfire)
    {
        
decl bool:oldv;
        
oldv StringToInt(oldValue) != 0;

        if((
friendlyfire GetConVarBool(mp_friendlyfire)) != oldv)
        {
            if(
friendlyfire)
            {
                for(new 
1<= MaxClientsi++)
                {
                    if(
IsClientInGame(i))
                    {
                        
OnClientPutInServer(i);
                    }
                }
            }
            else
            {
                for(new 
1<= MaxClientsi++)
                {
                    if(
IsClientInGame(i))
                    {
                        
SDKUnhook(iSDKHook_OnTakeDamageOnTakeDamage);
                    }
                }
            }
        }
    }
}

public 
OnClientPutInServer(client)
{
    
friendlyfire SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage):0;
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if(
victim != attacker)
    {
        
decl String:clsname[30];
        
GetEntityClassname(inflictorclsnamesizeof(clsname));
        if(
StrEqual(clsname"hegrenade_projectile"false))
        {
            if(
GetClientTeam(victim) == GetClientTeam(attacker))
            {
                return 
Plugin_Handled;
            }
        }
    }

    return 
Plugin_Continue;

*edit
updated, try that code dam, lame code...
*edit, better one...
__________________
Do not Private Message @me

Last edited by Bacardi; 10-28-2011 at 06:28.
Bacardi 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 00:32.


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