View Single Post
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-08-2014 , 10:43   Re: Client index 0 is invalid?
Reply With Quote #23

Quote:
Originally Posted by gilmon View Post
Thanks for the help,sorry don't know how to call/hook this event,do you have any example?
This should work:
PHP Code:
#include <sourcemod>
#include <sdkhooks>

#define IsPlayer(%0) (1<=%0<=MaxClients && IsClientInGame(%0))

public Plugin:myinfo 
{
    
name "TK Somemore..",
    
author "wbyokomo",
    
description "Revert damage done to attacker.",
    
version "0.0.1",
    
url "<- URL ->"
}

public 
OnClientPostAdminCheck(id)
{
    
SDKHook(idSDKHook_OnTakeDamageOnTakeDamage)
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    
//attacker not valid/connected @ selfdamage
    
if(!IsPlayer(attacker) || victim == attacker) return Plugin_Continue;
    
    
//ok he is TK you
    
if(GetClientTeam(victim) == GetClientTeam(attacker))
    {
        
//SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR); 
        //do damage to attacker
        
SDKHooks_TakeDamage(attacker00damagedamagetype)
        
//set 0.0 damage to victim
        
damage 0.0
        
return Plugin_Changed;
    }
    
    return 
Plugin_Continue;

yokomo is offline