AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   CS:GO Player Used Healthshot (https://forums.alliedmods.net/showthread.php?t=308922)

yash1441 07-08-2018 05:57

CS:GO Player Used Healthshot
 
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.

micapat 07-08-2018 06:25

Re: CS:GO Player Used Healthshot
 
You can use DHooks -> "CItem_Healthshot::CompleteUse(CCSPlayer *)".

"weapon_fire" is weird, the event is sent a lot for one healthshot used.

yash1441 07-08-2018 07:14

Re: CS:GO Player Used Healthshot
 
Quote:

Originally Posted by micapat (Post 2601880)
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 (Post 2601880)
"weapon_fire" is weird, the event is sent a lot for one healthshot used.

Exactly! It keeps firing the whole time the animation lasts.

_GamerX 07-08-2018 09:20

Re: CS:GO Player Used Healthshot
 
Hook in OnEntityDestroyed :) for me works

yash1441 07-08-2018 09:55

Re: CS:GO Player Used Healthshot
 
Quote:

Originally Posted by _GamerX (Post 2601947)
Hook in OnEntityDestroyed :) for me works

Oh really? Nice idea. Will definitely try this.

micapat 07-08-2018 12:21

Re: CS:GO Player Used Healthshot
 
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.

yash1441 07-08-2018 12:53

Re: CS:GO Player Used Healthshot
 
Quote:

Originally Posted by micapat (Post 2602011)

I tried the solution on this thread but that doesn't work.

Maind 09-28-2018 15:03

Re: CS:GO Player Used Healthshot
 
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"
                        }
                }
        }
}



All times are GMT -4. The time now is 20:45.

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