Hack Forums
[C] Rapid Fire keeps closing after you input a number - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Rapid Fire keeps closing after you input a number (/showthread.php?tid=3866373)



Rapid Fire keeps closing after you input a number - Moon Rock - Nov 14, 2013

So I'm trying to make a rapid fire hack with 2 options. If you enter 1 then the program should make a you do 5 shots, and if you enter 2 then it's full auto, but once you input a number the program closes.

CODE:
Code
#include <windows.h>
#include <iostream>
#include <string>
#include <ctime>
#define KeyDown(Key) (GetAsyncKeyState(Key) & 0x8000)// keyboard hook

using namespace std;

int main()
{
    int Option;
    cout << "\n\n\t\t    1.x5 Shot" << endl;
    cout << "\n\n\t\t    2.Full Auto" << endl;
    cin >> Option;
    
    POINT p;
    
    if (Option == 2)
    {
       if (KeyDown(0x46))
       {
       GetCursorPos( &p );//Gets Position of cursor
       mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, NULL);//Left click hold down
       Sleep(50);
       mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);//Left click lets go
       Sleep(50);
       cout << "\n\n\t\tFull Auto Working!" << endl;
       }
    }
    else if (Option == 1)
    {
       int rep = 0;
       if (KeyDown (0x46))
       {
          while(rep < 5)
          {
          GetCursorPos ( &p );
          mouse_event (MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, NULL);
          Sleep(50);
          mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
          rep++;
          cout << "Tripple shot working!" << endl;
          }
       }
    return 0;
    }
}



* - xSilent - Nov 14, 2013

You have to add a loop around everything if you want it to stay open and accept multiple commands.

Code
while (true)
{
    //Your code should be in this loop

    //After you accept input

    if (Option == -1) //Or some whatever else to exit the loop
  break;

    //If they don't use a closing value, your program will execute normally as above
}

return 0; //Then the program closes normally : EDITED



* - Mouse❤️ - Nov 15, 2013

And just a heads up, unless every gun in the game you're working with is semi-auto and depends solely on how quickly you click the mouse, that won't work. You'll actually have to hack the fire rate of the game. As in get the memory value where its stored and modify it.


* - Moon Rock - Nov 15, 2013

(Nov 14, 2013 11:57 PM)xSilent Wrote:  You have to add a loop around everything if you want it to stay open and accept multiple commands.

Code
while (true)
{
    //Your code should be in this loop

    //After you accept input

    if (Option == -1) //Or some whatever else to exit the loop
  break;

    //If they don't use a closing value, your program will execute normally as above
}

return 0; //Then the program to close normally.

Oh I get it, thanks I got it to work.


(Nov 15, 2013 07:20 AM)Rodaxoleaux Wrote:  And just a heads up, unless every gun in the game you're working with is semi-auto and depends solely on how quickly you click the mouse, that won't work. You'll actually have to hack the fire rate of the game. As in get the memory value where its stored and modify it.

It works with CoD4 and BO2 last time I used it.