View previous topic :: View next topic |
Author |
Message |
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Mon Aug 20, 2018 1:59 am Post subject: |
|
|
OK with many days figuring what is the problem I have found out. It is my curly braces and my declarations position. Which I am not really sure about though.
Please compare the 2 pictures I have uploaded one is my old code and the other is my new code.
In the new code picture I have deleted some curly braces and I have moved the address declarations to another position etc please check if I have all the positioning in the new code picture right and is all my braces right aswell?
Or was the positioning of the declarations addresses and offset correct just the only thing wrong was the positioning of the: DWORD RifleAmmoAddress = LocalPlayerBasePointer + AmmoOffset ? Please give me some tips to avoid this mess in future.
============================================================
Description: |
|
Filesize: |
198.39 KB |
Viewed: |
3118 Time(s) |
|
Description: |
|
Filesize: |
164.1 KB |
Viewed: |
3119 Time(s) |
|
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Mon Aug 20, 2018 5:17 am Post subject: |
|
|
The second one is using LocalPlayerBasePointer on line 35 before you set it with RPM on line 48.
As for avoiding it in the future, pay attention to the order things will be done in. Saying x = y+1 is not like in math where afterwards anytime you see x you use y+1 instead, it is literally setting x to the current value of y + 1 and afterwards anytime you see x it uses that value (until it is changed).
Also enable warnings and pay attention to them! You should have gotten one for using an uninitialized variable.
Only the braces for main and the first else (line 17) are necessary. Braces are unneeded for if-statements and loops unless you want more than one line of code to run (a compound-statement). Though some style guides recommend always having them so you can't come back later and add a line that you think will only run when it's true because it's indented like the first but ends up running all the time because the language doesn't actually care about indentation.
I'd also personally recommend just having a return in the if(!hWnd) and then you don't need an else+braces, same for if(!hProcess). That will keep the code from being unnecessarily indented which can make it harder to read in long code.
_________________
|
|
Back to top |
|
|
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Thu Aug 30, 2018 12:23 am Post subject: |
|
|
FreeER wrote: | I'd also personally recommend just having a return in the if(!hWnd) and then you don't need an else+braces, same for if(!hProcess). That will keep the code from being unnecessarily indented which can make it harder to read in long code. |
Sorry for the late reply, I'm gonna include the new edited version there will be 2 pictures included.
- Are all the brackets all good now and is the coding right?
- Another question, you see where I am adding text to the console. Like I want to build a menu. Example:
MENU:
PRESS F1 - TURN ON/OFF
PRESS F2 - TURN ON/OFF
How should I position the text? Or I can position it anywhere? Abit confused sorry.
I really appreciate your help and time, thanks.
Description: |
|
Filesize: |
156.22 KB |
Viewed: |
3060 Time(s) |
|
Description: |
|
Filesize: |
134.77 KB |
Viewed: |
3060 Time(s) |
|
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Thu Aug 30, 2018 5:36 am Post subject: |
|
|
Quote: | - Are all the brackets all good now and is the coding right? | does it do what you want? If so, probably yes, if not then, obviously not.
btw. pastebin / github etc. are much better ways to share code since we can control the font size or copy paste it into an editor with working folding or regex searches, personal syntax highlighting, add comments etc.
Quote: | How should I position the text? Or I can position it anywhere? | anywhere? If you have a gui in theory you could probably position it off screen and then move it on screen whenever you want the user to see it...if you just have a console app then standard C++ really doesn't give you any control over such things. I think window's conio has a gotoxy, and it may have a way to just set a char buffer, so it can be done but it's probably not worth it. Just print whatever you want and anytime you update it print a bunch of new lines (or use system("cls") since you only care about windows) and reprint everything.
_________________
|
|
Back to top |
|
|
DEVCORE Cheater Reputation: 0
Joined: 11 Aug 2018 Posts: 28
|
Posted: Fri Aug 31, 2018 10:27 am Post subject: |
|
|
Have one more question please look at my latest picture as reference:
- You see where the headings are that are commented out. Rifle Ammo Function and Pistol Ammo Function in picture #2.
Inside that do you see where I have all my cout, “Your current rifle ammo is”, “Enter the value you want” etc.
I have placed them at those specific location because that the order of steps I’m thinking in my head.
But should I position them all together as one whole menu instead of separating them like this? If you have a look at picture #1 I have the heading Welcome To The Game Console Trainer seperate. Should I put all the cout together with the cout menu heading? Keeping the cout seperate from the rpm/wpm function? Or does it need to be separated and placed exactly where you want it to be executed like how I did it?
I hope you understand what I mean....
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Fri Aug 31, 2018 10:38 am Post subject: |
|
|
Just keep them in order that way you don't have to worry about things being done out of order and reusing the same variable overwriting the value before it was used or not putting a prompt before cin etc.
_________________
|
|
Back to top |
|
|
|