Raised This Month: $ Target: $400
 0% 

[TF2] How to hook hitting a building?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 04-27-2016 , 17:20   Re: [TF2] How to hook hitting a building?
Reply With Quote #2

I don't think there is a hook. You can try this although there is an issue with it.
It works but getting the entity(sentry/dispenser/teleporter) isn't reliable since you can hit the building without looking at it. If you don't need the entity then you can delete GetClientAimTarget and your good to go. If you do need the entity maybe someone else knows a better way.

Code:
public void OnPluginStart()
{
	AddNormalSoundHook(Hook_EntitySound);
}

public Action Hook_EntitySound(
	int clients[64], 
	int &numClients, 
	char sample[PLATFORM_MAX_PATH], 
	int &client, 
	int &channel, 
	float &volume, 
	int &level, 
	int &pitch, 
	int &flags)
{
	if(StrEqual(sample, "weapons/wrench_hit_build_fail.wav") 
	|| StrEqual(sample, "weapons/wrench_hit_build_success1.wav") 
	|| StrEqual(sample, "weapons/wrench_hit_build_success2.wav"))
	{
		int entity = GetClientAimTarget(client, false);
		if(!IsValidEntity(entity))
			return Plugin_Continue;
		PrintToChat(client, "Building Hit! Client:%d Entity:%d", client, entity);
	}
	return Plugin_Continue;
}
__________________
Chaosxk is offline
 



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 21:08.


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