[TUTORIAL] Add AntTweakBar into your sobeit

_=Gigant=_

Well-known member
Joined
Mar 21, 2017
Messages
353
Reaction score
16
Hello, in this tutorial im going to teach you how to insert AntTweakBar into your sobeit and how to add functions in it
so lets start

1.first you need to have installed microsoft visual c++ and directx sdk to compile and edit sobeit source i have 2015 so i recommend that one 
- you can skip first step if you have already all that installed and prepared
2. download AntTweakBar from this link http://anttweakbar.sourceforge.net/doc/tools:anttweakbar:download 
3. now after you downloaded AntTweakBar we need needed files from its source to put into sobeit so needed files are:

AntTweakBar.h
AntPerfTimer.h
resource.h
TwBar.cpp
TwBar.h
TwColors.cpp
TwColors.h
TwDirect3D9.cpp
TwDirect3D9.h
TwEventWin.c
TwFonts.cpp
TwFonts.h
TwGraph.h
TwMgr.cpp
TwMgr.h
TwPrecomp.cpp
TwPrecomp.h
TwXCursors.h

you can download folder with this files from this link >> http://www.mediafire.com/file/28ms2a9ca7447g6/Ant+Needed+Files.rar

NOTE: if you get error cannot include main.h just right click on Tw .cpp files and select C/C++ > Precompiled Headers > Precompiled Header > Not Using Precompiled Headers
IT WILL BE SET TO Use /Yu you select Not Using Precompiled Headers

else to create precompiled headers right click on TwPrecomp.cpp and select Create /Yc and under it put 

Header File TwPrecomp.h
Header Output File $(IntDir)TwPrecomp.pch

and on other Tw .cpp files put the same headers just select Use /Yu

4.now when we have all files needed we need to include it into source put folder AntTweakBar with needed files into 
your sobeit project just drag it and drop it into source folder "src"
5. open visual studio, click on  "Show All Files" and refresh it, you will see refresh button near "Show All Files" button
6. after you refresh it the AntTweakBar folder will become visible right click on it and select "include in project"
7. click again "Show All Files" to go back to default editing menu and in there right click on "mod sa solution" go to "Add" and select "New Filter"
we add new filter to make it nice and organised :) :p
8. In the new filter put these files:

AntTweakBar.h
AntPerfTimer.h
resource.h
TwBar.cpp
TwBar.h
TwColors.cpp
TwColors.h
TwDirect3D9.cpp
TwDirect3D9.h
TwEventWin.c
TwFonts.cpp
TwFonts.h
TwGraph.h
TwMgr.cpp
TwMgr.h
TwPrecomp.cpp
TwPrecomp.h
TwXCursors.h

9. now we need to include "AntTweakBar.h" into main.h so put #include "AntTweakBar.h" 
you dont need to include these TwPrecomp.h TwXCursors.h etc...
 10.now we need to initialize our AntTweakBar so go to proxyIDirect3DDevice9.cpp click in its code and press ctrl + f and 
the search option will pop up and in there find  renderHandler when you find it you need to put this code between

if (!proxyIDirect3DDevice9_init)
{
                      //here you put code for ant explanation down below
proxyIDirect3DDevice9_init = 1;
}

so it will look something like this 

if (!proxyIDirect3DDevice9_init)
{
LoadSpriteTexture();

*(uint8_t *)0xBAB22C = gta_hp_bar->red;
*(uint8_t *)0xBAB22D = gta_hp_bar->green;
*(uint8_t *)0xBAB22E = gta_hp_bar->blue;
*(uint8_t *)0xBAB22F = gta_hp_bar->alpha;

*(uint8_t *)0xBAB230 = gta_money_hud->red;
*(uint8_t *)0xBAB231 = gta_money_hud->green;
*(uint8_t *)0xBAB232 = gta_money_hud->blue;
*(uint8_t *)0xBAB233 = gta_money_hud->alpha;

memset_safe((void *)(g_dwSAMP_Addr + 0x9D9D0), 0x5051FF15, 4);

TwInit(TW_DIRECT3D9, origIDirect3DDevice9); //// THIS IS FOR OUR TW BAR
TwWindowSize(pPresentParam.BackBufferWidth, pPresentParam.BackBufferHeight);//// THIS IS FOR OUR TW BAR

proxyIDirect3DDevice9_init = 1;
}

now after you done properly everything from last steps we can continue :v

11.now again activate search option ctrl + f and find    End of common D3D functions.
look up and you will see code:

if (cheat_state->_generic.menu)
RenderMenu();
                            
                            // HERE ABOVE no_render:; WE DRAW OUT TW BAR SO CODE WILL LOOK SOMETHING LIKE
              no_render:;
render->EndRender();

if (cheat_state->_generic.menu)
RenderMenu();

if (MySobeit->TWBAR) 
{
TwDraw();

static bool menuinit;
if (!menuinit)
{
initializeBarsMenu(); //here error will pop up because we dont have it defined yet so lets move to next step :3
menuinit = true;
}

}
              
              no_render:;
render->EndRender();

12. now we need to define some stuff into keyhook.cpp to find it type name of this file into search bar and in it again activate search option ctrl + f
and in there find LRESULT CALLBACK wnd_proc and under this code we need to initialize few stuff for our tw bar 

if (g_Input != nullptr && !g_Input->iInputEnabled && GetForegroundWindow() == wnd)
{
if (menu_wndproc(umsg, wparam, lparam))
return 0;
}

// UNDER THIS UPPER CODE PUT  THIS CODE IT WILL LOOK SOMETHING LIKE THIS

if (g_Input != nullptr && !g_Input->iInputEnabled && GetForegroundWindow() == wnd)
{
if (menu_wndproc(umsg, wparam, lparam))
return 0;
}

if (MySobeit->TWBAR) //TWBAR is boolean function you can put any boolean function but you need to define it in your menu.cpp
{
if (!gta_menu_active())
{
if (TwEventWin(wnd, umsg, wparam, lparam))
return 0;
}

}

13. we sitll have to define our tw bar menu "initializeBarsMenu();" so put void initializeBarsMenu() into your menu.cpp
it will look something like this 

TwBar *twBar_SETTINGS;

void initializeBarsMenu()
{
char menuParameters[512];
int iMainMenuPosX = pPresentParam.BackBufferWidth / 2 - 400 / 2;
int iMainMenuPosY = pPresentParam.BackBufferHeight - 275;

iMainMenuPosX = (pPresentParam.BackBufferWidth / 2) - (405 / 2) - 800;
iMainMenuPosY = (pPresentParam.BackBufferHeight / 2) - (235 / 2) - 350;
sprintf(menuParameters, " Settings label=' ' color='50 255 255 255' position='%d %d' size='370 800' fontsize='2' valueswidth=250 ", iMainMenuPosX, iMainMenuPosY);
TwDefine(menuParameters);
TwDefine(" Settings text='dark'");

TwAddVarRW(twBar_SETTINGS, "AirBrk Speed", TW_TYPE_FLOAT, &set.air_brake_speed, " min=0.1 max=5000.00  step= 1 group='Player' "); //THIS IS OUR FIRST FUNCTION FOR TW BAR

//you'll see here  twBar_SETTINGS put TwBar *twBar_SETTINGS; before void initializeBarsMenu() like i did 

}

15. DONT FORGET TO PUT DEFINITONS OF TwBar *twBar_SETTINGS; void initializeBarsMenu() into your menu.h so it will look something like this 

extern TwBar *twBar_SETTINGS;

void initializeBarsMenu();


14. after you did all that go back to your proxyIDirect3DDevice9.cpp to renderHandler and under TwWindowSize which we defined before now define twBar_SETTINGS so it will look like this


TwInit(TW_DIRECT3D9, origIDirect3DDevice9); 
TwWindowSize(pPresentParam.BackBufferWidth, pPresentParam.BackBufferHeight);

twBar_SETTINGS = TwNewBar(" MY TW BAR NAME"); // THIS WILL INITIALIZE OUR WINDOWS 

15. thats it for now il post source as soon as i get some free time btw here is the screenshot if you dont belive this works :3

https://s17.postimg.org/lcsq1ieov/sa-mp-040.png
 

CSprite

Active member
Joined
Nov 12, 2016
Messages
94
Reaction score
7
I think that would be useful for someone who know codding ... =]]
 

ini

Well-known member
Joined
Sep 28, 2015
Messages
321
Reaction score
115
CSprite said:
I think that would be useful for someone who know codding ... =]]

if you know codding you dont need it xd
When you can just check La Pirula Project source code wich is using ATB.
But anyways check-> ATB
 

_=Gigant=_

Well-known member
Joined
Mar 21, 2017
Messages
353
Reaction score
16
AR3S said:
tbh who would use atb in 2018?

i saw some guys asking for help about anttweakbar how to include it into their sobeit so i decided to post this tutorial someone will find this useful...
 
Top