summaryrefslogtreecommitdiff
path: root/src/csgo/console.cpp
blob: 0b16ceb2159372f6a3ecb65df0328c58c10562d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "hack.h"
#include "../menu.h"


struct CMD_TOGGLE {
  const char* name;
  const char* desc;
  SETTING<bool>& var;
};


void hack_toggle( CMD_TOGGLE cmd ) {
  con_clear();
  cmd.var = !cmd.var;
  
  menu_pages[menu_page].page_fn();
  show_paging( menu_page );
}

#define gcon_match( name ) !strncmp( buf + 1, name, strlen( name ) )

#define gcon_var( string ) { 0, strlen( string ) + 1, ( void* )string }

void __cdecl game_hack_toggle( VECTOR<STR<64>> args ) {
  static SETTING<bool>& bhop_active = *settings.find<bool>( "bhop_active"fnv );
  static SETTING<bool>& chams_active = *settings.find<bool>( "chams_active"fnv );
  static SETTING<bool>& glow_active = *settings.find<bool>( "glow_active"fnv );
  static SETTING<bool>& nightmode_active = *settings.find<bool>( "nightmode_active"fnv );
  static SETTING<bool>& noflash_active = *settings.find<bool>( "noflash_active"fnv );
  static SETTING<bool>& clantag_active = *settings.find<bool>( "clantag_active"fnv );

  static SETTING<bool>& aim_active = *settings.find<bool>( "aim_active"fnv );
  static SETTING<bool>& crosshair_active = *settings.find<bool>( "crosshair_active"fnv );
  static SETTING<bool>& rcs_active = *settings.find<bool>( "rcs_active"fnv );
  static SETTING<bool>& triggerteam_active = *settings.find<bool>( "triggerteam_active"fnv );

  char buf[512]{};

  for( auto& it : args )
    sprintf( buf, "%s\n%s", buf, it.data );

  CMD_TOGGLE cmd_toggle[10] = {
    { "hg_bhop"       , "toggles aim assist", bhop_active },
    { "hg_chams"      , "toggles bhop", chams_active },
    { "hg_glow"       , "toggles chams", glow_active },
    { "hg_night"      , "toggles clantag", nightmode_active },
    { "hg_flash"      , "toggles no flash", noflash_active },
    { "hg_clan"       , "toggles glow", clantag_active },
    { "hg_aim"        , "toggles nightmode", aim_active },
    { "hg_xhair"      , "toggles standalone rcs", crosshair_active },
    { "hg_rcs"        , "toggles team triggerbot", rcs_active },
    { "hg_triggerteam", "toggles recoil crosshair", triggerteam_active }
  };

  for( const auto& cmd : cmd_toggle ) {
    if( gcon_match( cmd.name ) ) {
      hack_toggle( cmd );
      return;
    }
  }

  if( gcon_match( "hg_help" ) ) {
    const HWND hconsole = FindWindowA( "Valve001", 0 );
    if( !hconsole )
      return;

    u_sleep( 1 * T_SEC / 5 );
    for( auto& cmd : cmd_toggle ) {
      sprintf( buf, "echo \"%s : %s\"", cmd.name, cmd.desc );
      
      COPYDATASTRUCT hconsole_out;
      hconsole_out.cbData = strlen( buf ) + 1;
      hconsole_out.dwData = 0;
      hconsole_out.lpData = ( void* )buf;
      SendMessageA( hconsole,
        WM_COPYDATA, 0,
        ( LPARAM )&hconsole_out
      );

      u_sleep( 1 * T_SEC / 20 );
    } 

    return;
  }

  const HWND hconsole = FindWindowA( "Valve001", 0 );
  if( !hconsole )
    return;

  COPYDATASTRUCT hconsole_out;
  hconsole_out.cbData = strlen( "echo \"invalid cmd, use \'hg_help\' for cmd list\"" ) + 1;
  hconsole_out.dwData = 0;
  hconsole_out.lpData = ( void* )"echo \"invalid cmd, use \'hg_help\' for cmd list\"";
  SendMessageA( hconsole,
    WM_COPYDATA, 0,
    ( LPARAM )&hconsole_out
  );
  
  return;
}