Raised This Month: $12 Target: $400
 3% 

[TF2] Projectile stuffs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rcki
Junior Member
Join Date: Oct 2015
Old 07-16-2018 , 14:44   [TF2] Projectile stuffs
Reply With Quote #1

Is it possible to check what weapon shot a certain projectile? Currently I know how to check the classname of a projectile (I.E tf_projectile_pipe), but I'd like to figure out what gun shot out that projectile (loose cannon, normal gl, etc etc) Here's my code:
Code:
public OnEntityDestroyed(iEntity)
{
	decl String:classname[64];
	GetEntityClassname(iEntity, classname, sizeof(classname));
		
	if((!strcmp(classname, "tf_projectile_pipe")))
	{
		//do somehing
	}
}
I tried googling around, but I didn't find anything. Thanks in advance !
Rcki is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 07-16-2018 , 19:50   Re: [TF2] Projectile stuffs
Reply With Quote #2

Either the 'm_hOriginalLauncher' netprop or the 'm_hLauncher' netprop.
Drixevel is offline
Rcki
Junior Member
Join Date: Oct 2015
Old 07-17-2018 , 06:46   Re: [TF2] Projectile stuffs
Reply With Quote #3

Quote:
Originally Posted by Drixevel View Post
Either the 'm_hOriginalLauncher' netprop or the 'm_hLauncher' netprop.
Sorry, but how would one go about checking this? I'm new to all of this netprop stuff... Lets say I'd like to check if the weapon is the loose cannon, would I do something like this:
Code:
public OnEntityDestroyed(iEntity)
{
	decl String:classname[64];
	GetEntityClassname(iEntity, classname, sizeof(classname));
		
	if((!strcmp(classname, "tf_projectile_pipe")))
	{
		new weapon = GetEntProp(iEntity, Prop_Data, "m_hLauncher");
		if(weapon == 996){
                //do something
                }
	}
}
EDIT: I tried both m_hLauncher and m_hOriginalLauncher, they both return:
Code:
[SM] Exception reported: Property "m_hOriginalLauncher" not found (entity 341/tf_projectile_pipe)
[SM] Exception reported: Property "m_hLauncher" not found (entity 341/tf_projectile_pipe)
EDIT2: Nvm I found a way that works! Instead of directly finding the gun that fired the projectile, I first find the owner of the projectile with "m_hThrower", and then find out what the primary weapon that player is using:
Code:
public OnEntityDestroyed(iEntity)
{
	decl String:classname[64];
	GetEntityClassname(iEntity, classname, sizeof(classname));
		
	if((!strcmp(classname, "tf_projectile_pipe")))
	{
		new owner = GetEntPropEnt(iEntity, Prop_Data, "m_hThrower");
		new weaponind = GetIndexOfWeaponSlot(owner, TFWeaponSlot_Primary);
		if(weaponind == 996){
			//do something
		}
	}
}

stock GetIndexOfWeaponSlot(client, slot)
{
	new weapon = GetPlayerWeaponSlot(client, slot);
	return (weapon > MaxClients && IsValidEntity(weapon) ? GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex") : -1);
}
Thanks anyways!

Last edited by Rcki; 07-17-2018 at 07:05.
Rcki is offline
Cieniu97
Junior Member
Join Date: Sep 2021
Location: Poland
Old 10-10-2021 , 12:33   Re: [TF2] Projectile stuffs
Reply With Quote #4

It can throw some errors since stickybomb launcher is secondary.
Solution with m_hLauncher - > https://forums.alliedmods.net/showthread.php?t=334639
Cieniu97 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 21:11.


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