AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Damage friend fire (https://forums.alliedmods.net/showthread.php?t=282181)

wEEk 05-01-2016 01:23

Damage friend fire
 
Hello, I wish you could Toggle friendly fire but none cause any damaged a Player Is Possible ? , In any case only of the effect of beating and to draw blood

fysiks 05-01-2016 02:46

Re: Damage friend fire
 
What?

safetymoose 05-01-2016 02:52

Re: Damage friend fire
 
Sure you can, just hook Ham_TakeDamage, check player's teams and return HAM_SUPERCEDE to block the damage.

Something like:
PHP Code:

#include <hamsandwich>
#include <cstrike>

// Plugin init
public plugin_init()
{
           
// Hook Ham_TakeDamage
           
Register_Ham(Ham_TakeDamage"player""fw_TakeDamage")
}

// Ham Take Damage Forward
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
           
// Non-player damage or self damage
           
if (victim == attacker || !is_user_alive(attacker))
                 return 
HAM_IGNORED

           
// Check if they are from the same team and block damage
           
if (cs_get_user_team(attacker) == cs_get_user_team(victim))
                return 
HAM_SUPERCEDE

           
return HAM_IGNORED



siriusmd99 05-01-2016 04:03

Re: Damage friend fire
 
Week , do you think it were more realistic to add aso some slap efect, i mean that player knows that he is being hit by teammate. I think it would be awesome :)

klippy 05-01-2016 06:20

Re: Damage friend fire
 
I think he wants only effects to take place (blood, punch, pain sound), but only block the damage.

That's why, Safetymoose, instead of completely blocking the TakeDamage call with HAM_SUPERCEDE, null the damage. I guess that should work.
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#pragma semicolon 1

new PLUGIN[]  = "";
new 
AUTHOR[]  = "";
new 
VERSION[] = "0.00";

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage"false);
}

public 
Player_TakeDamage(thisiInflictoriAttackerFloatfDamagebitsDamageType)
{
    if(
iAttacker != this && is_user_alive(iAttacker) && cs_get_user_team(iAttacker) == cs_get_user_team(this))
    {
        
SetHamParamFloat(40.0);
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;




All times are GMT -4. The time now is 18:34.

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