Custom Search

GTA IV Scripts explained

I have decided to start working on a section to explain how I created some of the GTA IV natives and let you peer into the world of writing scripts to work with Grand Theft Auto IV using the Script Hook SDK.

Microsoft C++ Script Hook

The compiler I will be demonstrating is Microsoft C++. You don't actually need a compiler to use GTA IV Script Hook, but you will spend hours of debugging very complex code if you don't use it. So be sure to download a free copy if you haven't already.

Please note: This is not a C++ tutorial, but should give you some of the basics to get started. Some of the primary things you will need to know is how to create your own functions, objects, variables, arrays, pointers (helpful), loops, conditions, etc. If you are a beginner programming you may want to study up a bit before trying to create your first "mod" or trainer.

Script Hook Native Names

A native name is a list of templates that provide hash references to memory in Grand Theft Auto IV. An example is GetCharCoordinates. This native selects an object in memory in correlation to a player's position at x, y, and z. I'm not going to provide a mathematical explanation, but will later explain how to utilize this in your code.

GTA IV Trainer

A trainer is a piece of software code that provides your player with a toolkit of multiple powers or abilities. Some examples are God mode, invisbility, speed walking, flying, manipulating objects, manipulating pedestrians, managing vehicle options, and many more.

My goal is to try to work on one hack every week or so. So for example I could start with the God Mode and explain how it works in code and break it down section by section. I will attempt my best at a comprehensive list from what I've learned in my experience with working with the Script Hook and native names.

It is possible later I may add a section on how to write your own Scripts using the Script Hook for Grand Theft Auto 5 too. This website is keeping me busy with other updates in the meantime, so stay tuned.

GTA IV Scripts categorized

So read below to discover the various scripts that were both copied and of my own creation. It is my vision that this guides you on understanding the true principles (as I teach them) of what types of mods exist. A mod is a modification of Grand Theft Auto IV file's to obtain an altercation or extension of something already present.

Activating the main player

When you are first learning the Script Hook it is essential to understand that GTA IV is made up of a bunch of objects. Even the player is an object, as also the vehicles, pedestrians, game objects, and so on.

In order to activate the player object (Niko) we need to call the GetPlayer() function below. This identifies where in the game memory we will find our player. Everything works completely off of GetPlayer and you will see it repeated a lot in Grand Theft Auto 4.

GTA IV Trainer
static Player GetPlayer() { Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); return playerIndex; } static Player GetPlayerStatic() { Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); return playerIndex; }

GTA IV God Mode

If the first example you will learn how to turn on God mode and give your player unlimited power. In God mode you cannot be shot, blown up, arrested, or stalked in any way. There are various functions you can add that will erase bullet wounds and other things.

GTA IV Trainer
void CustomFiberThread::DetermineIfGodmode() { Ped ped = GetPlayerPed(); SetPlayerInvincible(GetPlayer(), true, 1); SetCharCantBeDraggedOut(ped, true); SetCharWeaponSkill(ped, 1900); SetPlayerNeverGetsTired(playerIndex, true); SetCharStayInCarWhenJacked(ped, true); PrintStringWithLiteralStringNow ("STRING", "God Mode is on",7500,1); }

Native Name DetermineIfGodMode

First you will need to create a function name. The example selected above is called DetermineIfGodmode. I originally decided on this since I created a trigger switch that turned it on and off. Later I realized I never needed to turn off that power.

The first thing you must do is define an object for the Player. So the line Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId()) calls the native name ConvertIntToPlayerIndex to locate where the player is in memory. The ped is the object name we will use in the code example.

Below is an example of what happens when you have God Mode activated. You can jump off high buildings without dying. Your body will still spill blood on the ground and the player won't land on his feet, but no damage otherwise.

The next line calls the native name to intialize the God Mode as seen in the video. So the line SetPlayerInvincible(GetPlayer(), true, 1) will find the object at GetPlayer and the parameter true uses a boolean value to activate this power.

Next we see SetCharCantBeDraggedOut(ped, true). As the description of the native name states this prevents the player from being pulled out of a vehicle by a wandering pedestrian. The boolean value true is what activates this ability.

THen we see SetCharWeaponSkill(ped, 1900). This alters how many weapons are loaded into the player's inventory.

After this SetPlayerNeverGetsTired(playerIndex, true)

Next there is SetCharStayInCarWhenJacked(ped, true). This native name will not allow a character's car to be stolen.

The final part utilizes a Print String utility to show data on the screen. So the line PrintStringWithLiteralStringNow("STRING", "God Mode is on",7500,1) prints "God Mode is on" at the bottom center of the screen.

Native Name: PlayerIsInvisible()

The native allows the player to turn off the ability for other player's to see them. The player can still be tracked on the map by GPS coordinates unless you turn off that ability.

void CustomFiberThread::PlayerIsInvisible() { Ped ped = GetPlayerPed(); isPlayerVisible = !isPlayerVisible; SetCharVisible(ped, isPlayerVisible); const ch* displayString = (isPlayerVisible ? "Invisibility Off" : "Invisibility On"); SetNetworkIdExistsOnAllMachines(netid, true); PrintStringWithLiteralStringNow("STRING", displayString,7500,1); }

First we intialize the player object using Ped ped = GetPlayerPed(). The next line isPlayerVisible = !isPlayerVisible is a toggle switch. It turns the invisible on/off through a menu selection (menus will be discussed much later). Finally we use SetCharVisible(ped, isPlayerVisible) to activate the player at "ped" and set the boolean value of isPlayerVisible to false the first time we activate it.

Then the line const ch* displayString = (isPlayerVisible ? "Invisibility Off" : "Invisibility On") saves a character value called displayString to switch between two display values "Invisibility Off" or "Invisiblity On". It alternates between each value depending on which boolean is active.

After this the line SetNetworkIdExistsOnAllMachines(netid, true) turns on the network tracking for the player so we can utilize this in Multiplayer mode.

Finally we use PrintStringWithLiteralStringNow("STRING", displayString,7500,1) to print the display values to the screen.

Menu Options in the trainer

If you hover over the picture above you will see the following menu selections (in the upper left corner) for my trainer: Object List, Game Switches, Player Options, Vehicle Options, Teleport Options, Future Reserved, Ped Controller, Extra Options, and Network Settings.

Please note: The option Top Menu always returns the trainer back to the first menu. This is because there are multiple submenus included within.

The Object List includes: Forward thru Skip Object list, Backward thru Skip Object list, Attach Object to Vehicle, Detach Object from Vehicle, Rotate Spawned Object, Delete Object, Object Visibility ON/OFF, Active Spawned Object, Apply Force to Object, Rotate Object on Car, Rotate Object X, Rotate Object Y, Rotate Object Z, Move Object North, Move Object South, Move Object East and Move Object West.

The Game Switches includes: Walk/Fly/Swim Rate speed Backward, Numpad (ON/OFF), Floating (ON/OFF), Object Speed, Reset Hovering Rate speed, Reset Object Speed, Reset Vehicle Speed, Freeze Player, Helicopter Speed Cheat, GTA Function View Status, Relationship (ON/OFF), Mouse Setup, Menu Mouse, Eject Peds from cars, Gravity Gun Active, Num Keys=Explosion, Numpad Keys=Objects, and Remove All Weapons.

The Player Options includes: Player Selector, God Mode (ON/OFF), Restore Player's Health, Weapons Set 1, Weapons Set 2, Cops don't attack, Give Player Money, Warp into nearest Vehicle, Player Visibility (ON/OFF), Attach Player to Vehicle ON/OFF, Gravity Control, Weapon Cue Stick, Execute Player, Stupid Cops, Increase Shoot Rate, Decrease Shoot Rate, Reset Shoot Rate, Firing Accuracy Rate, Fire Bullets, Ragdoll, and Go through doors.

The Vehicle Options includes: Forward thru Vehicle list, Backward thru Vehicle list, Spawn Vehicle, Vehicle God Mode, Vehicle is Fixed, Vehicle Speed, Explode closest Vehicle, Flip Car, Vehicle Invisibility (ON/OFF), Active Spawned Vehicle, Delete Car, Vehicle Speed(Quicker), Freeze Car in air, Unfreeze Car in air, Close Car Doors, Car Neons, Spawn Emergency Vehicle, Crash Cars Into Peds, Increase Remote Car's Direction, Decrease Remote Car's Direction, Revive Dead Car, Change Vehicle Color, Tire Bursting, Hijack Car, and Release Hijacked Car.

The Teleport Options includes: Forward thru Teleport Location, Backward thru Teleport Location, Activate Teleporter, Save Teleport Location, and Activate Saved Teleport.

The Ped Options includes: Ped Forward Scroll, Ped Backward Scroll, Spawn Ped, Swat Spawner, Ped Spawner, Execute Ped, Player Sit Down, Set Ped on fire, Bodyguards, Lift ped out of water, Pull ped out of car, Passenger Ped, Revive Dead Pedestrian, Attach walking peds to Car, Steal object from Ped, Freeze Ped in range, and Unfreeze Ped in range.

The Power Options includes: God Mode (ON/OFF), Restore Player's Health, Firewalk, Tornado Vehicle, Tornado Vehicle Reset, Rocket Explosions, Player Attack, Bullet Force, Increase Ped Radius X, Increase Ped Radius Y, Increase Ped Radius Z, and Reset All Ped Radius Values.

The Extra Options includes: Change the Weather, Time Forward, Attach Vehicle together, Car hydralics, Attach Ped to Car, Future Reserved, Water level mode, Water Level raise, Camera in Front, Camera Behind, Fire Extinguisher, Change Radio Station, and Clear entire area.

The Network Settings includes: Player Settings, Block MP Car Controller, and Kick Network Player.

Newer Menu Options added to the trainer

The following menus were added much later. This is because when I was modifying my code for Grand Theft Auto IV trainer I was constantly discovering how to do new things, such as new powers, etc. This greatly expanded the trainer into a massive overskill, but it was fun trying out all kinds of things.

The Animation Options includes: Player Smoking, Player Waving, Player Arguing, and Bullet Time (Matrix style).

The Freeze Vehicle Options includes: Freeze Car in Air, Unfreeze Car, Increase Car toward West, Decrease Car toward East, Increase Car toward South, Decrease Car toward North, Move Car Up, Move Car Down, Change Radio Station, Freeze nearby Vehicle, and Unfreeze nearby Vehicle.

The Lift/Freeze Ped Options includes: Increase Ped Radius, Decrease Ped Radius, Reset All Lift Ped Values, Increase Ped Throw West, Decrease Ped Throw East, Increase Ped Throw South, Decrease Ped Throw North, Increase Ped Throw Up, Decrease Ped Throw Down, Lift Ped off Ground, Make Ped Invisible, Throw All Peds in Area, Freeze Nearby Ped, Unfreeze Nearby Ped, Move Ped to Right, and Move Ped to Left.

The Speed Controls Options includes: Increase Walk Speed, Decrease Walk Speed, Increase Car Speed, Decrease Car Speed, Helicopter Speed Forward, Car Variable Speed Increment, Car Variable Speed Decrement, Game Test Display, Apply Gravity to Peds, Increase Fire Radius, Decrease Fire Radius, and Increase Fire Radius2.

The Vehicle Spawner Options includes: ADMIRAL, AIRTUG, AMBULANCE, BANSHEE, BENSON, BIFF, BLISTA, BOBCAT, BOXVILLE, BUCCANEER, BURRITO, BURRITO2, BUS, CABBY, CAVALCADE, CHAVOS, COGNOSCENTI, COMET, COQUETTE, and DF8.

The Vehicle Mass Destruction Options includes: Explode Car (ON/OFF), Increase throw Car West Force, Decrease throw Car East Force, Increase throw Car South Force, Decrease throw Car North Force, Increase throw Car Up Force, Decrease throw Car Down Force, Applying Force to Vehicle, Helicopter Combat, Move Frozen Car West, Move Frozen Car East, Move Frozen Car South, Move Frozen Car North, Move Frozen Car Up, Move Frozen Car Down, Hijack Car(s) From Above, and Release Hijacked Car(s).

The Fire Controls include: Firewalk, Increase Fire toward West, Decrease Fire toward East, Increase Explosion Type, Decrease Explosion Type, Increase Fire Radius, Decrease Fire Radius, and Reset Fire Values.

The Explosion Controls include: Make Explosion, Increase Exlosion toward West, Decrease Explosion toward East, Decrease Explosion toward North, Increase Explosion toward South, Increase Explosion Up, Decrease Explosion Down, Increase Explosion Type, Decrease Explosion Type, Increase Explosion Radius, Decrease Explosion Radius, Reset Explosion Values, and Monster Explosion(s).

How the menus work

GTA IV Trainer
The menu list is activated with F6. The player can then use the arrow keys to scroll up and down through the list. As each menu item is scrolled over it is highlighted in a light green color. Pressing enter when hovered over any menu item will activate the sub menus for that section. So for example if you press enter while over the Vehicle Options you will see the list of options the player can do with the cars in the game. Finally selecting Top Menu from the sub menus returns the user to the top menu. You can also press F6 to turn it off and on, which resets the menus too.
Menu Options code explained

So I am going to attempt to explain what each menu function does section by section. This is going to be a major project so bear with me as I find time to work on this.

Menu Options code explained

So I am going to attempt to explain what each menu function does section by section. This is going to be a major project so bear with me as I find time to work on this.

Menu code function explained

Take a look at the code below. It controls the menu you saw earlier. Each section for MenuDS is connected to a specific menu in numerical order. I set them all to char (stands for character) so they can be utilized with text displays, such as "Vehicle Options".

The ClearMenuLines() clears the menu from the screen so we can keep it clear from any display issues. The function CallMenu() shows it on the screen.

The last part of the function returns each menu item so it can be retrieved by the compiler.

int MainMenu(int Mnlmt, char* MenuDs0, char* MenuDs1, char* MenuDs2, char* MenuDs3, char* MenuDs4, char* MenuDs5, char* MenuDs6, char* MenuDs7, char* MenuDs8, char* MenuDs9, char* MenuDs10, char* MenuDs11, char* MenuDs12, char* MenuDs13, char* MenuDs14, char* MenuDs15, char* MenuDs16, char* MenuDs17, char* MenuDs18, char* MenuDs19, char* MenuDs20, char* MenuDs21, char* MenuDs22, char* MenuDs23, char* MenuDs24, char* MenuDs25, char* MenuDs26, char* MenuDs27) { MenuLimit = Mnlmt; MenuD0 = MenuDs0; // ************ MenuD1 = MenuDs1; // Object List MenuD2 = MenuDs2; // Game Switches MenuD3 = MenuDs3; // Player Options MenuD4 = MenuDs4; // Vehicle Options MenuD5 = MenuDs5; // Teleport Options MenuD6 = MenuDs6; // Ped Options MenuD7 = MenuDs7; // Power Options MenuD8 = MenuDs8; // Extra Options MenuD9 = MenuDs9; // Network Settings MenuD10 = MenuDs10; // Animation MenuD11 = MenuDs11; // Mass Destruction MenuD12 = MenuDs12; // Freeze Vehicle Options MenuD13 = MenuDs13; // Lift Ped Options MenuD14 = MenuDs14; // Speed Controls MenuD15 = MenuDs15; // Fire Controls MenuD16 = MenuDs16; // Explosion Controls MenuD17 = MenuDs17; // Player Selector MenuD18 = MenuDs18; MenuD19 = MenuDs19; MenuD20 = MenuDs20; MenuD21 = MenuDs21; MenuD22 = MenuDs22; MenuD23 = MenuDs23; MenuD24 = MenuDs24; MenuD25 = MenuDs25; MenuD26 = MenuDs26; MenuD27 = MenuDs27; ClearMenuLines(); CallMenu(); return MenuLimit; return *MenuD0; return *MenuD1; return *MenuD2; return *MenuD3; return *MenuD4; return *MenuD5; return *MenuD6; return *MenuD7; return *MenuD8; return *MenuD9; return *MenuD10; return *MenuD11; return *MenuD12; return *MenuD13; return *MenuD14; return *MenuD15; return *MenuD16; return *MenuD17; return *MenuD18; return *MenuD19; return *MenuD20; return *MenuD21; return *MenuD22; return *MenuD23; return *MenuD24; return *MenuD25; return *MenuD26; return *MenuD27; }

Calling MenuDisplay

First we set variables playerMenuToggle, helpMenuToggle, helpMenu2Toggle to zero. Then we call the TitleDisplay function and then KeyCheck. Each of these functions are explained further below.

The first parameter (that shows 18) keeps track of in the Main Menu function is how many items are in this list. It doesn't include the blank fields. This is also where menuItem passes the correct item number to MenuExec01 (below) so that we can execute that specific trainer menu item.

The code below also shows how each parameter (from MenuDx) above is filled with text selections. An example would be "Teleport Options".

Later in the code these are passed to a function that draws the display on the screen. The MenuExec01(menuItem) calls another subroutine to control the menus. I will explain that next.

void CustomFiberThread::MenuDisplay() { playerMenuToggle=0; helpMenuToggle=0; helpMenu2Toggle=0; TitleDisplay(); KeyCheck(); // ROOT MENU MainMenu(18, "***************","Object List","Game Switches","Player Options","Vehicle Options","Teleport Options","Ped Options","Power Options","Extra Options","Network Settings","Animation","Freeze Vehicle","Lift Ped Options","Speed Controls","Vehicle Spawner(list)","Vehicle Mass Destruction","Fire Controls","Explosion Controls","","","","","","","","","",""); MenuExec01(menuItem); // scroll thru menuLevel lists (item 1,2,3,4,5,6,7,8,9,10) main_menu = true; // This line sets the option to false/true. False=Not at Main Menu. True=At Main Menu }

MenuExec01

So the MenuExec01 code below checks to see which item number is selected (which menu the player selected) and then it sets the menuLevel to the appropriate menu category. The comments explain what is really going on.

void CustomFiberThread::MenuExec01(u32 item) { // Build menu selection for all menu items if(item==1) menuLevel=0; // Main menu if(item==2) menuLevel=1; // Go to Object List if(item==3) menuLevel=2; // Go to Game Switches if(item==4) menuLevel=3; // Go to Player Options if(item==5) menuLevel=4; // Go to Vehicle Options if(item==6) menuLevel=5; // GO to Teleport Options if(item==7) menuLevel=6; // Go to Ped Options if(item==8) menuLevel=7; // Go to Power Options if(item==9) menuLevel=8; // Go to Extra Options if(item==10) menuLevel=9; // Go to Network Settings if(item==11) menuLevel=10; // Go to Animation Settings if(item==12) menuLevel=11; // Go to Mass Destruction Settings if(item==13) menuLevel=12; // Go To Freeze Vehicle Options if(item==14) menuLevel=13; // Go To Lift Ped Options if(item==15) menuLevel=14; // Go To Speed Control Options if(item==16) menuLevel=15; // Go To Fire Control Options if(item==17) menuLevel=16; // Go To Explosion Controls if(item==18) menuLevel=17; // Go To Player Selector }

The rest of the menu code is explained

Next we are going to see which keys are being pressed so we can begin to scroll through the menus. The kprev8 means that the user pressed the 8 key on the number pad. So in this example we are going to set another variable kprev8 = kcur8 to keep track of it. Then we are decrementing the menuItem. This is because the numpad 8 key moves the menu selector up.

In the next section we see that kprev2 is being checked to see if the 2 key was pressed on the number pad. It also records the variable kprev2 = kcur2 and then increments the menuItem variable because the numpad 2 key moves the menu selector down.

//Code Snippet 1 // NUMPAD8 Scroll up through menu if (kprev8 != kcur8) { kprev8 = kcur8; if (kcur8) menuItem--; } // NUMPAD2 Scroll down through menu if (kprev2 != kcur2) { kprev2 = kcur2; if (kcur2) menuItem++; }

Checking the menu range

Now we are using if(menuItem < 1) to be sure we are not scrolling off the top of the menu. If the variable menuItem is less than 1 then we are going to set menuItem = MenuLimit. MenuLimit is a defined variable that keeps track of the number of items added to each MainMenu function.

Likewise in the section if(menuItem > MenuLimit) this makes certain that we don't scroll off the bottom of the menu. If the variable menuItem is greater than MenuLimit then we are keeping menuItem = 1 which flips it back to the top so we can wrap it.

The next section that shows if(kprev5 != kcur5) waits for the user to press the numpad 5 key and then sets the variable kprev5 = kcur5. Next the statement if(kcur5 && main_menu==true) means that the main_menu is active then it sets main_menu back to false because we are no longer at the main menu. This is because pressing the 5 key on the number pad activates the sub menu display.

The function ClearMenuLines() clears out the main menu on the screen and the function SubMenuDisplay() shows the sub menu in place of the previous main menu. After this that statement ends with the curly braces

If the numpad 5 key is not selected then we call the function CallMenu() to reload the main menu.

// Code Snippet 2 if(menuItem < 1) menuItem = MenuLimit; // Check to see if menu limit reaches the first parameter in MainMenu if(menuItem > MenuLimit) // When it does flip it back to 1 or to the max possible menuItem =1; // Display main menu at start and when Top Menu is selected // To add a new menu be sure to also change Menu_Settings(11) to Menu_Settings(12), etc if (kprev5 != kcur5) { kprev5 = kcur5; if (kcur5 && main_menu==true) { main_menu==false; // We are no longer at the MenuDisplay(). We went to SubMenuDisplay() ClearMenuLines(); SubMenuDisplay(); } CallMenu(); // Show each menu listing (as numpad 8/2 are utilized) } } }

How the sub menus work

Shown below is a picture of the sub menu as seen in Grand Theft Auto IV. The sub menus are used to access various other controls in the trainer.

Calling SubMenuDisplay

So in this function we are setting playerMenuToggle to zero, helpMenuToggle to zero, and helpMenu2Toggle to zero. Next we are going to call the TitleDisplay (which will be explained below SubMenuDisplay). The TitleDisplay shows game stats that keep track of changing properties. Then we are calling KeyCheck() to be sure the keys are active.

Now we check if (menuLevel > 0), which is checking to see in the menuLevel > 0 which means that we are not at the main menu. Then we are setting main_menu to false since we are in the sub menu section.

The statement else if (menuLevel < 1) means that we have left the sub menu and we are going to the main menu again. Once this is true main_menu is set to true and menuLevel is set to zero.

Finally the numpad 2 keys are checked when comparing the statement if(kprev2 !=kcur2). After this condition succeeds when if(kcur2) then the variable submenItem is increased which means the player is moving down through the sub menu list.

The final part of this code is the statement if (kprev5 != kcur5) which checks to see if the number 5 key was pressed on the number pad which will execute the function on that menu.

// Code Snippet 1 void CustomFiberThread::SubMenuDisplay() { playerMenuToggle=0; helpMenuToggle=0; helpMenu2Toggle=0; TitleDisplay(); KeyCheck(); if (menuLevel > 0) // menuLevel changes when item=2,3,4,5,6 (scrolling thru menu list) { main_menu = false; // This line sets the option to false/true. False=Not at Main Menu. True=At Main Menu } else if (menuLevel < 1) { main_menu = true; menuLevel=0; } // NUMPAD2 Scroll down through menu if (kprev2 != kcur2) { kprev2 = kcur2; if (kcur2) submenuItem++; } // NUMPAD5 Execute menu function if (kprev5 != kcur5) { kprev5 = kcur5;

SubMenu continued - Object List menu

This part begins the explanation of the other parts of the SubMenu function. So the section below that shows if (menuLevel==1) will be true if the user selected the Object List menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Object List. Then the function MenuExec2 is called to manage the control functionality for the object menu.

//Code Snippet 1 // *********************** THIS MENU IS EXECUTED THE FIRST TIME BEFORE WE SELECT SOMETHING ********** // Below is an impressive menu function. It has saved me countless hours adding new menu items. All I have to // do is add a new item to the list and change the counter. The counter in the example menu below is: // MainMenu(22 (counter) // NOTE: Before this menu system was developed, I had to debug my menu items above (if item== (etc) to // see which condition belonged to which menu. Now it's as easy as adding the menu item and adding the // condition. An example is in this area - (void CustomFiberThread::MenuExec17(u32 item) area // OBJECT LIST //if (kcur5 && menuLevel==1) if (menuLevel==1) { MainMenu(22, "< ---- OBJECT LIST MENU ---- >","Forward thru Object list","Backward thru Object list","Spawn Object" ,"Forward thru Skip Object list","Backward thru Skip Object list","Attach Object to Vehicle","Detach Object from Vehicle" ,"Rotate Spawned Object","Delete Object","Object Visibility ON/OFF","Active Spawned Object:" ,"Apply Force to Object","Rotate Object on Car","Rotate Object X","Rotate Object Y" ,"Rotate Object Z","Move Object North","Move Object South","Move Object East","Move Object West" ,"Top Menu","","","","","",""); MenuExec2(submenuItem); }

Game Switches menu

This part begins the explanation of the Game Switches menu. So the section below that shows if (menuLevel==2) will be true if the user selected the Game Switches menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Game Switches List. Then the function MenuExec3 is called to manage the control functionality for the game switches menu.

// GAME SWITCHES if (menuLevel==2) { MainMenu(22, "< ---- GAME SWITCHES MENU ---- >","Hovering Rate Speed","Walk/Fly/Swim Rate speed Forward" ,"Walk/Fly/Swim Rate speed Backward","Numpad (ON/OFF)","Floating (ON/OFF)","Object Speed" ,"Reset Hovering Rate speed","Reset Object Speed","Reset Vehicle Speed","Freeze Player" ,"Helicopter Speed Cheat","GTA Function View Status","Relationship (ON/OFF)","Mouse Setup" ,"Menu Mouse","Eject Peds from cars","Gravity Gun Active","Numpad Keys=Explosion" ,"Numpad Keys=Objects","Remove All Weapons","Top Menu","","","","","",""); MenuExec3(submenuItem); }

Player Options menu

This part begins the explanation of the Player Options menu. So the section below that shows if (menuLevel==3) will be true if the user selected the Player Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Player Options List. Then the function MenuExec4 is called to manage the control functionality for the player options menu.

// PLAYER OPTIONS if (menuLevel==3) { MainMenu(23, "< ---- PLAYER OPTIONS MENU ---- >","Player Selector","God Mode (ON/OFF)","Restore Player's Health" ,"Weapons Set 1","Weapons Set 2","Cops don't attack","Give Player Money","Warp into nearest vehicle" ,"Player Visibility (ON/OFF)","Attach Player to Vehicle ON/OFF","Gravity Control","Weapon Cue Stick" ,"Execute Player","Stupid Cops","Increase Shoot Rate","Decrease Shoot Rate","Reset Shoot Rate" ,"Firing Accuracy Rate","Fire Bullets","Ragdoll","Go through doors","Top Menu","","","","",""); MenuExec4(submenuItem); }

Vehicle Options menu

This part begins the explanation of the Vehicle Options menu. So the section below that shows if (menuLevel==4) will be true if the user selected the Vehicle Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Vehicle Options List. Then the function MenuExec5 is called to manage the control functionality for the vehicle options menu.

// VEHICLE OPTIONS if (menuLevel==4) { MainMenu(27, "< ---- VEHICLE OPTIONS MENU ---- >","Forward thru Vehicle list","Backward thru Vehicle list","Spawn Vehicle" ,"Vehicle God Mode","Vehicle is Fixed","Vehicle Speed","Explode closest Vehicle","Flip Car" ,"Vehicle Invisibility (ON/OFF)","Active Spawned Vehicle","Delete Car","Vehicle Speed(Quicker)","Freeze Car in air" ,"Unfreeze Car in air","Close Car Doors","Car Neons","Spawn Emergency Vehicle", "Crash Cars Into Peds","Increase Remote Car's Direction","Decrease Car's Remote Direction" ,"Revive Dead Car","Change Vehicle Color","Tire Bursting","Hijack Car","Release Hijacked Car" ,"Top Menu",""); MenuExec5(submenuItem); }

Teleport Options menu

This part begins the explanation of the Teleport Options menu. So the section below that shows if (menuLevel==5) will be true if the user selected the Teleport Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Teleport Options List. Then the function MenuExec6 is called to manage the control functionality for the teleport options menu.

// TELEPORT if (menuLevel==5) { MainMenu(7, "< ---- TELEPORT OPTIONS MENU ---- >","Forward thru Teleport Location","Backward thru Teleport Location" ,"Activate Teleporter","Save Teleport Location","Activate Saved Teleport","Top Menu","","","","","","" ,"","","","","","","","","","","","","","",""); MenuExec6(submenuItem); }

Ped Options menu

This part begins the explanation of the Ped Options menu. So the section below that shows if (menuLevel==6) will be true if the user selected the Ped Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Ped Options List. Then the function MenuExec7 is called to manage the control functionality for the ped options menu.

// PED OPTIONS if (menuLevel==6) { MainMenu(25, "< ---- PED OPTIONS MENU ---- >","Ped Forward Scroll","Ped Backward Scroll","Spawn Ped","Swat Spawner","Ped Spawner" ,"Apply Force to Ped","Active Spawned Ped:","Delete Ped","Make Ped drop weapon","Provoke fights","Ped Raise Hands", "Execute Ped","Player Sit Down","Set Ped on fire","Bodyguards","Lift ped out of water","Pull ped out of car" ,"Passenger Ped","Revive Dead Pedestrian","Attach walking peds to Car" ,"Steal object from Ped","Freeze Ped in range","Unfreeze Ped in range","Top Menu","","",""); MenuExec7(submenuItem); }

Power Options menu

This part begins the explanation of the Power Options menu. So the section below that shows if (menuLevel==7) will be true if the user selected the Power Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Power Options List. Then the function MenuExec8 is called to manage the control functionality for the power options menu.

// POWER OPTIONS if (menuLevel==7) { MainMenu(14, "< ---- POWER OPTIONS MENU ---- >","God Mode (ON/OFF)","Restore Player's Health","Firewalk" ,"Tornado Vehicle","Tornado Vehicle Reset","Rocket Explosions","Player Attack","Bullet Force" ,"Increase Ped Radius X","Increase Ped Radius Y","Increase Ped Radius Z","Reset All Ped Radius values" ,"Top Menu","","","","","","","","","","","","","",""); MenuExec8(submenuItem); }

Extra Options menu

This part begins the explanation of the Extra Options menu. So the section below that shows if (menuLevel==8) will be true if the user selected the Extra Options menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Extra Options List. Then the function MenuExec9 is called to manage the control functionality for the extra options menu.

// EXTRA OPTIONS if (menuLevel==8) { MainMenu(21, "< ---- EXTRA OPTIONS MENU ---- >","Change the Weather","Time Forward","Attach Vehicles together" ,"Car hydralics","Attach Ped to Car","Future Reserved","Water level mode", "Water Level raise" ,"Water Level reset","Rotate Jet(s)","Flip Object","Fighter Jets","Driver Mission","Fire jet guns" ,"Camera in Front","Camera Behind","Fire Extinguisher","Change Radio Station" ,"Clear entire area","Top Menu","","","","","","",""); MenuExec9(submenuItem); }

Network Settings menu

This part begins the explanation of the Network Settings menu. So the section below that shows if (menuLevel==9) will be true if the user selected the Network Settings menu. Next the MainMenu function is prefilled in with the new data containing the sub menu items for the Network Settings List. Then the function MenuExec10 is called to manage the control functionality for the network settings menu.

// NETWORK SETTINGS if (menuLevel==9) { MainMenu(5, "< ---- NETWORK SETTINGS MENU ---- >","Player Settings","Block MP Car Controller","Kick Network Player", "Top Menu","","","","","","","","","","","","","","","","","","","","","","",""); MenuExec10(submenuItem); }

Remaining menus

The remaining menus consist of options for Animation, Freeze Vehicle, Lift/Freeze Ped, Speed, Vehicle Spawner, Vehicle Mass Destruction, Fire, and Explosions.

The last part that shows if (kprev8 !=kcur8) checks to see if the user pressed the 8 key on the number pad and this moves the menu up in the sub menu list.

The next section shows if (submenu < 1) to say if the submenu item is less than 1 then we have reached the top of the menu and the trainer will set the variable setmenuItem = MenuLimit. The MenuLimit keeps track of the total Items found in each sub menu. After this we checked if (submenuItem > MenuLimit) to see if the user has scrolled down and reached the last menu item there. Then we set the variable submenuItem equal to 1.

Finally we call the function CallSubMenu() to bring up the sub menu items and set the variable kcur5 = 0 since we have already pressed the enter key here.

Calling TitleDisplay

This function keeps track of the menu,status displays, and the copyright screen of the trainer. It also takes care of drawing the box that created the menu. The menus are drawn with the command DrawRect.

The GetMousePosition command shows the coordinates of the player in a status display.

This section also displays the status for Current Weather, God Mode, Car Invincibility mode, Floating mode, Numpad Keys, Hovering Rate Speed, Teleport location, current spawned object, player, and the current spawned vehicle.

void CustomFiberThread::TitleDisplay() { playerMenuToggle=0; helpMenuToggle=0; helpMenu2Toggle=0; SetTextColour(155, 120, 130, 205); //255,100,0,255=orange SetTextScale(.6f,.37f); SetTextBackground(120); DisplayTextWithLiteralString(.01f, .015f, "STRING", "My Super Mega Trainer Menu: F6 to exit"); // plot x,y, x+w, y+h DrawRect((.009), (.120), .210, .270, 0, 0, 0, 125); // x, y, width, height, red, green, blue, alpha) // y(170) h(180) //23 SetTextColour(255, 255, 0, 255); SetTextScale(.2f,.22f); //SetTextDropshadow(40, 255, 255, 100, 2, 1); DisplayTextWithLiteralString(.45f, .97f, "STRING", "By StevorNtheHouse (c) 2009"); // Mouse coordinates /* f32 pX, pY; GetMousePosition(&pX, &pY); menuxoff=pX; menuyoff=pY; char temp1[300]; sprintf_s(temp1,300,"X: %f Y: %f" , menuxoff,menuyoff); SetTextScale(.3,.22); DisplayTextWithLiteralString(.5, .5, "STRING", temp1); */ //////////////////////////////////////////////////// //SetTextColour(255, 255, 132, 255); //SetTextScale(.2f,.22f); //SetTextDropshadow(40, 255, 255, 100, 2, 1); //DisplayTextWithLiteralString(.45f, .89f, "STRING", "Number value:"); // Draw Stat Rectangles DrawRect(.900, .980, .270, .220, 0, 0, 0, 120); // Box for Status Menu (bottom right corner) // .160, 0,0,0,100 //DrawRect(.900, .995, .250, .045, 0, 0, 0, 100); // x, y, w, h Black line DrawRect(.090, .995, .185, .065, 0, 0, 0, 200); // Box for Player Coordinates ViewPlayerCoordinates(); SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .870f, "STRING", "Current Weather:"); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.912, .870f, "STRING", weathermod[weatherX+2]); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .885f, "STRING", "God Mode:"); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .900f, "STRING", "Floating:"); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .915f, "STRING", "Numpad Keys:"); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .930f, "STRING", "Hovering Rate Speed:"); SetTextColour(255, 255, 0, 255); char temp4[300]; sprintf_s(temp4, 300," %i" , hoveringControl); SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.905f, .930f, "STRING", temp4); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .945f, "STRING", "Teleporter:"); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .960f, "STRING", "Object:"); if (objectNum > 0) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.836f, .960f, "STRING", spawnedListObj[listView]); } else { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.836f, .960f, "STRING", "None"); // Object Display } SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.785f, .975f, "STRING", "Vehicle:"); if (vehicleNum > 0) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.836f, .975f, "STRING", spawnedListVeh[listVehView]); } else { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.836f, .975f, "STRING", "None"); } char temp2[300]; sprintf_s(temp2, 300," %s" , TelName[TeleNamecntr-2]); SetTextScale(.2f, .16f); if (telFlag==1) // Use this to set Teleport to "None" first time mod is run { SetTextColour(255, 255, 0, 255); DisplayTextWithLiteralString(.855f, .945f, "STRING", temp2); } if (numFlag < 1) // First time game is run Numpad line will display "OFF" { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.935f, .915f, "STRING", "OFF"); } if (isInvincible==true) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.912f, .885f, "STRING", "ON"); } else { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.935f, .885f, "STRING", "OFF"); // was 933 } if (floatActive < 1) // Will display "OFF" before Floating ON/OFF menu is activated { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.935f, .900f, "STRING", "OFF"); } if (isFloating==true && floatActive > 0) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.935f, .900f, "STRING", "OFF"); } else if(isFloating==false && floatActive > 0) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.912f, .900f, "STRING", "ON"); } if (isNumPadActive==true && numFlag==1) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.912f, .915f, "STRING", "ON"); } else if (isNumPadActive==false && numFlag==1) { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.935f, .915f, "STRING", "OFF"); } if (objectNum > 0 && menuLevel==1) // Will show in Object menu after object is spawned { SetTextColour(255, 255, 0, 255); SetTextScale(.2f, .16f); DisplayTextWithLiteralString(.15f, .215f, "STRING", spawnedListObj[listView]); // .15f, .200f } }

Calling KeyCheck

This function is very simple. It checks which keys are being pressed such as the number pad keys and the function (f1) keys.

Once it has checked the state with GetAsyncKeyState then a value of 1 is passed to kcur. An example is if the user pressed the F6 key (for the menu) then keycurF6 will be set to 6. When the player presses it again, keycurF6 will contain a zero.

static void KeyCheck() { pressF5 = GetAsyncKeyState(VK_NUMPAD5); if (GetAsyncKeyState(VK_NUMPAD0)) // key logic kcur0 = 1; else kcur0 = 0; if (GetAsyncKeyState(VK_NUMPAD1)) // key logic kcur1 = 1; else kcur1 = 0; if (GetAsyncKeyState(VK_NUMPAD2)) // key logic kcur2 = 1; else kcur2 = 0; if (GetAsyncKeyState(VK_NUMPAD3)) // key logic kcur3 = 1; else kcur3 = 0; if (GetAsyncKeyState(VK_NUMPAD4)) // key logic kcur4 = 1; else kcur4 = 0; if (pressF5) // key logic kcur5 = 1; else kcur5 = 0; if (GetAsyncKeyState(VK_NUMPAD6)) // key logic kcur6 = 1; else kcur6 = 0; if (GetAsyncKeyState(VK_NUMPAD7)) // key logic kcur7 = 1; else kcur7 = 0; if (GetAsyncKeyState(VK_NUMPAD8)) // key logic kcur8 = 1; else kcur8 = 0; if (GetAsyncKeyState(VK_NUMPAD9)) // key logic kcur9 = 1; else kcur9 = 0; if (GetAsyncKeyState(VK_F1)) // key logic kcurF1 = 1; else kcurF1 = 0; if (GetAsyncKeyState(VK_F6)) // key logic kcurF6 = 1; else kcurF6 = 0; if (GetAsyncKeyState(VK_F7)) // key logic kcurF7 = 1; else kcurF7= 0; if (GetAsyncKeyState(VK_F8)) kcurF8 = 1; else kcurF8 = 0; if (GetAsyncKeyState(VK_F9)) // key logic kcurF9 = 1; else kcurF9= 0; if (GetAsyncKeyState(VK_F10)) // key logic kcurF10 = 1; else kcurF10= 0; }

GTA IV: My Super Mega Trainer

This trainer includes everything from flying, running very fast, spawning vehicles/objects/pedestrians, teleporting , changing the weather, moving the camera, explosions, pushing cars out of your way, animation, controls, etc. You are actually getting access to the full trainer. So be nice since you will now be very powerful.

The videos below show how to setup the Script Hook, explain how the Teleport Options menu works, and the final one explains how the Script Hook communicates to Grand Theft Auto IV using the Microsoft c++ compiler.



next button

Questions? Ask Here

Subscribe to the Programmermind newsletter
Privacy Notice: Programmer Mind will not compromise your privacy