View Single Post
Author Message
alex123pavlov
Member
Join Date: Jun 2018
Location: Moscow
Old 06-24-2018 , 21:02   Help me SDKHook_OnTakeDamage
Reply With Quote #1

I have made the menu from propa, I want to add to each prop health, have found here such code at a forum
Code:
#include <sdkhooks>

public void OnEntityCreated(int entity, const char[] classname) {
	if(StrContains(classname, "prop_physics", false) >= 0) {
		SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
	}
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom) {
	if(attacker <= 0 || !IsClientInGame(attacker)) {
		return Plugin_Continue;
	}
	int attackerTeam = GetClientTeam(attacker);
	if(attackerTeam == 2 && damagetype != DMG_SLASH) {
		return Plugin_Handled;
	} else if(attackerTeam == 3) {
		damage = 10.0;
		return Plugin_Changed;
	}
	return Plugin_Continue;
}
I have put his propa have ceased to receive a loss.
prop_physics - have ceased to break, Help me please.
alex123pavlov is offline