Since there's a shit ton of misinformation floating around and a lot of people who really don't know what they're doing (partially including me for a bit) I decided to post this here. Why? Because I want someone else to make a C++ cheat for gmod one of these days and not paste it from weeabot or d3x's or fami's cheats.
Why do we need engine prediction?
LocalPlayer is **
NOT** predicted in your createmove calls. You will be using outdated data for your aimbot/bhop/garbage cheat and therefore you'll lose in hvh.
Why not velocity prediction?
Why would you not want to use the exact method the engine uses to predict instead of inaccurate math to predict a player's position.
How do we do it?
Below is some general pseudo code that you can get the gist of easily. Underneath will be an explanation of why each step exsists.
Code:
backup curtime
backup frametime
set curtime to interval_per_tick * GetTickBase
set frametime to interval_per_tick
set m_pCurrentCommand to the current command
Setup movedata struct
Call SetupMove pass local player, current command, nullptr and movedata
Call FullWalkMove pass localplayer, current command, and movedata
Call FinishMove pass local player, current command, and movedata
set m_pCurrentCommandto nullptr
set frametime to old frametime
set curtime to old curtime
Explanation of code
Backing up curtime and frametime are pretty straight forward, we'll be modifying those values and we want to be able to restore them.
frametime is really just the tickrate of the server
curtime is very straight forward
In certain source games (aka not csgo) the 'current tick' isn't set in time so we do that. (Shitty explanation, do your own research if you want to understand why this is important)
Setupmove in general handles all of your flags and netvar changes (read through the function please)
Wait a second, where's ProcessMovement!!!!! Instead of calling SetHost and ProcessMovement, you can call FullWalkMove instead which has a couple bonuses including some velocity fixes that you should read up on if you want 100% perfect prediction. Ever wondered why you can't hit entities while their Z velocity is over 200? (wink wink)
FullWalkMove is our main 'prediction' function which basically calls a bunch of others and if you really care you should read up on what each one does.
FinishMove does exactly what you think it does.
And oh my god look! It's that garbage
AAA everyone uses and thinks they're cool!
Finally, reset the current command and frametime and curtime. This prediciton should be able to work in any source game so this doesn't just reflect gmod.