Raised This Month: $241 Target: $400
 60% 

Notices

Help me SDKHook_OnTakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alex123pavlov
Member
Join Date: Jun 2018
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 online now
LenHard
Senior Member
Join Date: Jan 2016
Old 06-25-2018 , 04:37   Re: Help me SDKHook_OnTakeDamage
Reply With Quote #2

PHP Code:
public void OnEntityCreated(int iEntity, const char[] sClassName)
{
    if (
StrContains(sClassName"prop_physics") != -1) {
        
SDKHook(iEntitySDKHook_SpawnPostOnEntitySpawned);
    }
}

public 
void OnEntitySpawned(int iEntity)
{
    if (
IsValidEntity(iEntity)) {
        
SDKHook(iEntitySDKHook_OnTakeDamageOnTakeDamage);
    }

Make sure to see the prop/entity spawns before hooking damage.
__________________


Currently accepting private requests.

Last edited by LenHard; 06-25-2018 at 07:16.
LenHard is offline
Reply


Thread Tools
Display Modes

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 01:55.


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