Raised This Month: $ Target: $400
 0% 

Solved [L4D2]Can SDKHooks have plugin conflicts?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 12-22-2022 , 15:49   [L4D2]Can SDKHooks have plugin conflicts?
Reply With Quote #1

I'm trying to make some var changes when players shoot teammates. I'm running another plugin which blocks damage (prevention of friendly fire). Is it safe to hook OnTakeDamage and use it in another plugin? I'm not trying to change/block damage in this second one, just want to set some global vars.

The reason i'm asking is because - witch damage to players is being blocked somehow, and sometimes the hook stops firing for specific clients after a while. I can't use l4d2 player_hurt event for what i'm trying to do, because it doesnt activate with my friendly protection plugin.

There could be some problem with the plugin some other way of course, but here is the way i'm using it, does it look safe? Thanks!

Code:
int MyVar[MAXPLAYERS+1];

public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_OnTakeDamage, OnTakePlayerDamage);
}

public Action OnTakePlayerDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
	if(IsClientInGame(attacker) && IsClientInGame(victim) && attacker != victim)
	{
		if(!IsFakeClient(attacker) && !IsFakeClient(victim))
		{
			if(GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2)
			{
				MyVar[attacker] = 1;
			}
		}
	}
}

Last edited by Morning; 12-22-2022 at 19:56.
Morning is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-22-2022 , 17:59   Re: [L4D2]Can SDKHooks have plugin conflicts?
Reply With Quote #2

About the answer to your thread title, it's a yes. I believe I have mentioned it somewhere else that crashes will happen often if two different plug-ins handle the same entity but only if you modify one datum or some of the data of a function then returning Plugin_Changed in one plug-in and accidentally blocking that function from being called (in other words, returning Plugin_Handled) in the other.

Last edited by cravenge; 12-22-2022 at 18:00.
cravenge is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-22-2022 , 18:25   Re: [L4D2]Can SDKHooks have plugin conflicts?
Reply With Quote #3

Yes, it depends on the plugin load order. Those loaded later will overwrite plugins loaded earlier using the same hook, this also applies to all forwards provided by plugins/extensions.
__________________
Silvers is offline
Morning
Member
Join Date: May 2021
Old 12-22-2022 , 19:56   Re: [L4D2]Can SDKHooks have plugin conflicts?
Reply With Quote #4

Right, thanks that's useful to know for the future!

I'll try using SDKHook_OnTakeDamagePost.
Morning 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 08:22.


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