Results 1 to 6 of 6
  1. #1
    cspp's Avatar
    Join Date
    Oct 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    how ho hook engine function

    Lets say I need to hook g_pEngine->pfnPlaySound

    g_pEngine->pfnPlaySound = myfunc ( do I need to pass cl_enginefunc_s struct to it or not? )
    because return g_pEngine->pfnPlaySound(soound,vol,pitch ) leed to crash . I suppose myfunc shoud be structure* void.
    Can someone explain how to do it properly

  2. #2
    I love myself
    나도 너를 사랑해

    Former Staff
    Premium Member
    Jhem's Avatar
    Join Date
    Mar 2012
    Gender
    male
    Location
    167,646,447
    Posts
    5,150
    Reputation
    1220
    Thanks
    7,393
    My Mood
    Stressed
    Let me see your code.

  3. #3
    Threadstarter
    New Member
    cspp's Avatar
    Join Date
    Oct 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    Code:
    void HookFunction(){
    
    	
    
    	g_pClient->HUD_Redraw = HUD_Redraw;
    	g_pClient->HUD_Frame = HUD_Frame;	
    	
    	
    	
    	g_pEngine->pfnPlaySound = plays;  //here
    
    
    
    
    
    and
    
    void [or what??] plays(const char *sound,float vol, float pitch)
    {
    	
    	ConsolePrintColor(22, 222, 22, "hook sound %s \n",sound);
    
    	return g_pEngine->pfnPlaySound(sound, vol, pitch);   //wrong 
    }
    - - - Updated - - -

    I found return g_Engine.pfnPlaySound(sound, vol, pitch); is correct

    I have another question


    if I hook simple command like disconnect


    Code:
    pcmd_t hookdisc;
    
    hookdisc = CommandByName("disconnect");	
    hookdisc->function = (xcommand_t)mydisconnect;
    
    
    void mydisconnect()
    {
    
    
    
    how to return original function ? because if I do engine-> clientcmd disconenct  it will be infinite loop
    Last edited by cspp; 07-07-2019 at 05:47 AM.

  4. #4
    I love myself
    나도 너를 사랑해

    Former Staff
    Premium Member
    Jhem's Avatar
    Join Date
    Mar 2012
    Gender
    male
    Location
    167,646,447
    Posts
    5,150
    Reputation
    1220
    Thanks
    7,393
    My Mood
    Stressed
    First of all, you can't return a void.

    Are you sure that your sound parameters are correct?.

    Code:
    int plays(const char *sound,float vol, float pitch)
    {
    	if(g_pEngine)
               ConsolePrintColor(22, 222, 22, "Engine Found \n",sound);
    
    	return g_pEngine->pfnPlaySound(sound, vol, pitch);   //wrong 
    }

  5. #5
    Threadstarter
    New Member
    cspp's Avatar
    Join Date
    Oct 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    yes because original func (pfnPlaySound) is void.
    so
    Code:
    void plays(const char *sound,float vol, float pitch)
    {
    	if(!blockplaysound)
    	return g_Engine.pfnPlaySound(sound, vol, pitch);
    }
    works well.
    Last edited by cspp; 07-08-2019 at 09:06 AM. Reason: updated

  6. #6
    I love myself
    나도 너를 사랑해

    Former Staff
    Premium Member
    Jhem's Avatar
    Join Date
    Mar 2012
    Gender
    male
    Location
    167,646,447
    Posts
    5,150
    Reputation
    1220
    Thanks
    7,393
    My Mood
    Stressed
    Okay, i'm gonna mark this thread as solved. Contact me if you want to re-open it again.
    //Solved.

Similar Threads

  1. How to dump Engine/Cshell (With Pics)
    By zmansquared in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 115
    Last Post: 01-06-2011, 07:42 AM
  2. How to add multiple functions to your auto-on hack!
    By Spookerzz in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 35
    Last Post: 10-10-2010, 06:32 PM
  3. [Vista Users]How to Fix Engine.exe Crashing (Photo Tutorial)
    By DarknessInc in forum Combat Arms Hacks & Cheats
    Replies: 25
    Last Post: 10-10-2008, 04:38 PM
  4. How do u define function in VB6
    By ilovepie21 in forum WarRock - International Hacks
    Replies: 5
    Last Post: 03-02-2008, 12:20 PM
  5. tut How to hook tut 6
    By llvengancell in forum WarRock - International Hacks
    Replies: 1
    Last Post: 06-26-2007, 03:24 PM