Raised This Month: $32 Target: $400
 8% 

CS:GO Player Used Healthshot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 07-08-2018 , 05:57   CS:GO Player Used Healthshot
Reply With Quote #1

Is there anyway to know when a player has used a healthshot?

Tried: weapon_fire is fired when player presses mouse1 but the healthshot animation can be cancelled after that.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-08-2018 , 06:25   Re: CS:GO Player Used Healthshot
Reply With Quote #2

You can use DHooks -> "CItem_Healthshot::CompleteUse(CCSPlayer *)".

"weapon_fire" is weird, the event is sent a lot for one healthshot used.
__________________
micapat is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 07-08-2018 , 07:14   Re: CS:GO Player Used Healthshot
Reply With Quote #3

Quote:
Originally Posted by micapat View Post
You can use DHooks -> "CItem_Healthshot::CompleteUse(CCSPlayer *)".
Never really worked with vtable offsets as such so didn't touch DHooks till now. Can you explain how would I hook it?

Something like this?

PHP Code:
int offset CItem_Healthshot::CompleteUse(CCSPlayer * );
DHookCreate(offsetHookType_EntityReturnType_BoolThisPointer_CBaseEntityCallbackfunction); 
Quote:
Originally Posted by micapat View Post
"weapon_fire" is weird, the event is sent a lot for one healthshot used.
Exactly! It keeps firing the whole time the animation lasts.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 07-08-2018 , 09:20   Re: CS:GO Player Used Healthshot
Reply With Quote #4

Hook in OnEntityDestroyed for me works
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 07-08-2018 , 09:55   Re: CS:GO Player Used Healthshot
Reply With Quote #5

Quote:
Originally Posted by _GamerX View Post
Hook in OnEntityDestroyed for me works
Oh really? Nice idea. Will definitely try this.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 07-08-2018 , 12:21   Re: CS:GO Player Used Healthshot
Reply With Quote #6

A similar thread: https://forums.alliedmods.net/showthread.php?t=285032

I tried the last solution but it doesn't work.
OnEntityDestroyed seems to have issues if you want to retrieve the user.
__________________
micapat is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 07-08-2018 , 12:53   Re: CS:GO Player Used Healthshot
Reply With Quote #7

Quote:
Originally Posted by micapat View Post
I tried the solution on this thread but that doesn't work.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
Maind
Member
Join Date: Dec 2009
Old 09-28-2018 , 15:03   Re: CS:GO Player Used Healthshot
Reply With Quote #8

Hi, with help of @peace-maker and @Pelipoika i've got the solution for that

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <dhooks>
 

// CItem_Healthshot::CompleteUse(CCSPlayer *) (probably returns void)
Handle hHealthshotCompleteUse;
int offsetHealthshotCompleteUse;
 
public 
OnPluginStart()
{
    
Handle temp LoadGameConfigFile("healthshot.games");
    if(
temp == INVALID_HANDLE)
        
SetFailState("Missing healthshot.games file in gamedata folder.");
    
offsetHealthshotCompleteUse GameConfGetOffset(temp"CompleteUse");
    if(
offsetHealthshotCompleteUse == -1)
        
SetFailState("Failed to get offset from healthshot.games file.");
    
CloseHandle(temp);
      
    
hHealthshotCompleteUse DHookCreate(offsetHealthshotCompleteUseHookType_EntityReturnType_VoidThisPointer_CBaseEntityHealthshotCompleteUse);
    
DHookAddParam(hHealthshotCompleteUseHookParamType_CBaseEntity);
}
 
public 
OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname"weapon_healthshot"))
    {
        
DHookEntity(hHealthshotCompleteUsetrueentity);
    }  
}
 
public 
MRESReturn HealthshotCompleteUse(pThisHandle hParams)
{
    
int client DHookGetParam(hParams1);
    
    
//Here you can do some stuff with client who used healthshot :)
    
    
return MRES_Ignored;

and current offsets for this
Code:
"Games"
{
	"csgo"
	{
		"Offsets"
		{
			"CompleteUse"
			{
				"windows"	"453"
				"linux"		"459"
			}
		}
	}
}
Maind 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 03:33.


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