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

DHooks (Dynamic Hooks - Dev Preview)


Post New Thread Reply   
 
Thread Tools Display Modes
Apina
AlliedModders Donor
Join Date: May 2013
Old 05-30-2015 , 14:16   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #301

DHookSetParamString(hParams, 2, "Text"); this dosent work after 5-10 minutes stoping hooking message
Apina is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-30-2015 , 19:58   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #302

Apina. Show ALL of your code.
__________________
Neuro Toxin is offline
Apina
AlliedModders Donor
Join Date: May 2013
Old 05-31-2015 , 17:21   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #303

PHP Code:
#include <sourcemod>
#include <dhooks>
#include <sdktools>

new Handle:hClientPrintf INVALID_HANDLE;

public 
OnPluginStart()
{    
    new 
Handle:gameconf LoadGameConfigFile("clientprintf-hook.games");
    if(
gameconf == INVALID_HANDLE)
    {
        
SetFailState("Failed to find clientprintf-hook.games.txt gamedata");
    }
    new 
offset GameConfGetOffset(gameconf"ClientPrintf");
    if(
offset == -1)
    {
        
SetFailState("Failed to find offset for ClientPrintf");
        
CloseHandle(gameconf);
    }
    
StartPrepSDKCall(SDKCall_Static);
    if(!
PrepSDKCall_SetFromConf(gameconfSDKConf_Signature"CreateInterface"))
    {
        
SetFailState("Failed to get CreateInterface");
        
CloseHandle(gameconf);
    }
    
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_PointerVDECODE_FLAG_ALLOWNULL);
    
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
    
    new 
String:interface[64];
    if(!
GameConfGetKeyValue(gameconf"EngineInterface", interface, sizeof(interface)))
    {
        
SetFailState("Failed to get engine interface name");
        
CloseHandle(gameconf);
    }
    
    new 
Handle:temp EndPrepSDKCall();
    new 
Address:addr SDKCall(temp, interface, 0);
    
    
CloseHandle(gameconf);
    
CloseHandle(temp);
    
    if(!
addrSetFailState("Failed to get engine ptr");
    
    
hClientPrintf DHookCreate(offsetHookType_RawReturnType_VoidThisPointer_IgnoreHook_ClientPrintf);
    
DHookAddParam(hClientPrintfHookParamType_Edict);
    
DHookAddParam(hClientPrintfHookParamType_CharPtr);
    
DHookRaw(hClientPrintffalseaddr);
}
public 
MRESReturn:Hook_ClientPrintf(Handle:hParams)
{
    
decl String:buffer[1024];
    
DHookGetParamString(hParams2buffer1024);
    if(
StrContains(buffer"Введите в чат !нож") != -1
    {
        
DHookSetParamString(hParams2"Введите в чат !knife");
        return 
MRES_ChangedHandled;
    }
    return 
MRES_Ignored;

Attached Files
File Type: sp Get Plugin or Get Source (plugin.sp - 87 views - 2.0 KB)
Apina is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 05-31-2015 , 22:23   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #304

Tested still can't reproduce I spammed my command and the hook fired every time and changed the text correctly over multiple map changes reconnects and time it still worked. Why are you hooking that? That looks like a plugin that should just be modified. Also where is the text printed to?
Dr!fter is offline
cam0
Senior Member
Join Date: Feb 2015
Old 06-02-2015 , 15:01   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #305

I've created a teleport hook using the SDKTools Teleport offset.

It seems to be functioning correctly, but, how can I overwrite the angles?
Code:
public MRESReturn Hook_DHooks_Teleport(int client, Handle hParams){     if(!IsClientConnected(client) || IsFakeClient(client) || !IsPlayerAlive(client))         return MRES_Ignored;         if(!DHookIsNullParam(hParams, 2)){         float angles[3];         for(int i=0;i<3;i++){             angles[i] = DHookGetParamObjectPtrVar(hParams, 2, i*4, ObjectValueType_Float);                         if(angles[i] != g_fLastAngles[client][i])                 DHookSetParamObjectPtrVar(hParams, 2, i*4, ObjectValueType_Float, g_fLastAngles[client][i]);         }         //TeleportEntity(client, NULL_VECTOR, g_fLastAngles[client], NULL_VECTOR);     }         return MRES_Handled; }

This isn't working currently. g_fLastAngles is backed up in OnPlayerRunCmd for this purpose. It's supposed to ignore the trigger_teleport's setting of whether or not to use the destination angles.
cam0 is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 06-02-2015 , 20:16   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #306

Quote:
Originally Posted by cam0 View Post
I've created a teleport hook using the SDKTools Teleport offset.

It seems to be functioning correctly, but, how can I overwrite the angles?
Code:
public MRESReturn Hook_DHooks_Teleport(int client, Handle hParams){     if(!IsClientConnected(client) || IsFakeClient(client) || !IsPlayerAlive(client))         return MRES_Ignored;         if(!DHookIsNullParam(hParams, 2)){         float angles[3];         for(int i=0;i<3;i++){             angles[i] = DHookGetParamObjectPtrVar(hParams, 2, i*4, ObjectValueType_Float);                         if(angles[i] != g_fLastAngles[client][i])                 DHookSetParamObjectPtrVar(hParams, 2, i*4, ObjectValueType_Float, g_fLastAngles[client][i]);         }         //TeleportEntity(client, NULL_VECTOR, g_fLastAngles[client], NULL_VECTOR);     }         return MRES_Handled; }

This isn't working currently. g_fLastAngles is backed up in OnPlayerRunCmd for this purpose. It's supposed to ignore the trigger_teleport's setting of whether or not to use the destination angles.
Without the rest of the code i cant really say but try DHookSetParamVector and make sure you have it set to ParamType_Vector (or w/e it is)
Dr!fter is offline
cam0
Senior Member
Join Date: Feb 2015
Old 06-03-2015 , 03:55   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #307

Quote:
Originally Posted by Dr!fter View Post
Without the rest of the code i cant really say but try DHookSetParamVector and make sure you have it set to ParamType_Vector (or w/e it is)
Creating the Hook
Code:
public void OnLibraryAdded(const char[] name){     if(StrEqual(name, "dhooks") && g_hTeleport == INVALID_HANDLE){         Handle hGameData = LoadGameConfigFile("sdktools.games");         if(hGameData == INVALID_HANDLE)             return;                 int iOffset = GameConfGetOffset(hGameData, "Teleport");                 CloseHandle(hGameData);                 if(iOffset == -1)             return;                 g_hTeleport = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, Hook_DHooks_Teleport);                 if(g_hTeleport == INVALID_HANDLE){             PrintToServer("\n!! g_hTeleport -> INVALID_HANDLE !!\n");             return;         }                 DHookAddParam(g_hTeleport, HookParamType_VectorPtr);         DHookAddParam(g_hTeleport, HookParamType_ObjectPtr);         DHookAddParam(g_hTeleport, HookParamType_VectorPtr);         DHookAddParam(g_hTeleport, HookParamType_Bool); // CS:GO only                 for(int i=1;i<=MaxClients;i++)         {             if(IsClientInGame(i))                 OnClientPutInServer(i);         }     } }

OnClientPutInServer
Code:
public void OnClientPutInServer(int client){     if(g_hTeleport != INVALID_HANDLE)         DHookEntity(g_hTeleport, false, client); }

I don't get any errors or issues at all, it just doesn't seem to want to work.
cam0 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-03-2015 , 07:13   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #308

I was having issues overriding params for GiveNamedItem.

I also had posthosts being called for prehooks I tried to block with MRES_Supercede. I'm not sure i'm doing it right and am yet to post an example to clarify how I would block GiveNamedItem or override a param.

I worked around it for now and don't have time to throw together an example / how to replicate.

I prob wont get around to posting an example / verifying replication:- until the weekend.

I did however, leave heaps of comments of what i was expecting here.
__________________
Neuro Toxin is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 06-03-2015 , 08:33   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #309

Quote:
Originally Posted by cam0 View Post
Creating the Hook
Code:
public void OnLibraryAdded(const char[] name){     if(StrEqual(name, "dhooks") && g_hTeleport == INVALID_HANDLE){         Handle hGameData = LoadGameConfigFile("sdktools.games");         if(hGameData == INVALID_HANDLE)             return;                 int iOffset = GameConfGetOffset(hGameData, "Teleport");                 CloseHandle(hGameData);                 if(iOffset == -1)             return;                 g_hTeleport = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, Hook_DHooks_Teleport);                 if(g_hTeleport == INVALID_HANDLE){             PrintToServer("\n!! g_hTeleport -> INVALID_HANDLE !!\n");             return;         }                 DHookAddParam(g_hTeleport, HookParamType_VectorPtr);         DHookAddParam(g_hTeleport, HookParamType_ObjectPtr);         DHookAddParam(g_hTeleport, HookParamType_VectorPtr);         DHookAddParam(g_hTeleport, HookParamType_Bool); // CS:GO only                 for(int i=1;i<=MaxClients;i++)         {             if(IsClientInGame(i))                 OnClientPutInServer(i);         }     } }

OnClientPutInServer
Code:
public void OnClientPutInServer(int client){     if(g_hTeleport != INVALID_HANDLE)         DHookEntity(g_hTeleport, false, client); }

I don't get any errors or issues at all, it just doesn't seem to want to work.

Ill look into it.

Quote:
Originally Posted by Neuro Toxin View Post
I was having issues overriding params for GiveNamedItem.

I also had posthosts being called for prehooks I tried to block with MRES_Supercede. I'm not sure i'm doing it right and am yet to post an example to clarify how I would block GiveNamedItem or override a param.

I worked around it for now and don't have time to throw together an example / how to replicate.

I prob wont get around to posting an example / verifying replication:- until the weekend.

I did however, leave heaps of comments of what i was expecting here.
There is a bug with returning supercede for void functions that ive fixed locally while i work on other bugs as there has been a few showing up recently.
Dr!fter is offline
cam0
Senior Member
Join Date: Feb 2015
Old 06-04-2015 , 02:28   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #310

Quote:
Originally Posted by Dr!fter View Post
Ill look into it.
Okay, thank you. I've tried a few other combinations including using TeleportEntity() in the hook but that doesn't seem to work either.
cam0 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 19:15.


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