[TUT] Converting Hex to Decimal in "Measured Integer Value"

I literally have a problem with two of these particular mods, the Jet HUD, and the Supersonic, in GTA V. The script is somehow rejecting the process of an air vehicle that I'm in unless using predefined keys to make them readable in the script, thus writing default values and model/IDE hash into INI (Jet HUD) and XML (Supersonic) files. Truth is, I would like to handle this without using the predefined keys, so air vehicles that has either Jet HUD or Supersonic do not get tracked by the script. This is once happened when I accidentally pressed those predefined keys (Crouch, Jump, and Accelerate keys) in an Annihilator helicopter, which is an air vehicle but unfortunately, it is a helicopter and does have neither HUD nor Supersonic capabilities.

So this tutorial is made because some of you might want to use add-on vehicles but is still not readable by the script you are making.


Preparation

If you are looking for default vehicle/weapon/ped hashes (including official DLC ones), check out:
  1. Weapons and Explosions Hashes List
  2. Vehicles Hashes List
  3. Gunrunning DLC Weapons Hashes List
  4. Peds Hashes List

Download OpenIV if you don't have it already. This tutorial highly depends on it since we want to find proper and measured integer value from it.
Prepare yourself a Calculator (Windows Calculator is recommended) with Programmer settings.

To display Calculator with Programmer settings, click on 3 lines on top left and select Programmer (Windows 10).

Simple Explanation of Hex

Hex, or hexadecimal in long term, or a basis of 16 numerical value, is a numeric system that uses 16 symbols. Unlike decimal numeric system, hexadecimal uses 9 symbols starting from numbers 0 to 9, followed by additional 6 symbols starting from letters A to F (Google Indonesia).

What is the Maximum Value of Integer?

Okay, if you are not a programmer, let me explain this nice and simple.

In computer science, the term "integer" used to refer to any data type that represent integer, or some part of integers. A.k.a. Integral Data Type (Google Indonesia).

Integer is a numerical value. 0 to 9, 10, 100, 1000, or more, and without any dots (for US numerical value) or commas (for other country numerical value like Indonesia) and followed by another number (for example 30.55) is considered an integer.

Integer is, however, limited in a maximum value. If you look up "maximum integer value" without quotes in Google, the maximum integer value is 2,147,483,647 (2.1 million). If you try to exceed more than that then it's not an integer. Programmers then call it as "long integer" or "unsigned integer".

How to Convert Hex to Decimal and Displaying Other Numeric Values

Calculator in Windows does automatically to convert decimal to hex and vice versa when you type in specific number value by either typing on the keyboard or clicking on the numbers while the window is active. You can also toggle between octal and binary values by clicking on texts displayed on the picture below. It's also same for older Windows.

When you click one of them, some numbers on the window will inactive. For example, octal can have a maximum value of 7 before it's considered "10" like in decimal, so only digits 0 to 7 are active.

Getting a Vehicle Model Hash from OpenIV and Convert it

Let's start up with the simple one, for example the P-996 LAZER, one of the fighter jets in GTA V.

You can find the model with OpenIV in x64e.rpf|levels\gta5\vehicles.rpf.

You can also find its IDE block in common.rpf|data\levels\gta5\vehicles.meta and type ">lazer<" (without quotes) into the Search box of the text editor.


Alright, now here's the fun part. Click on Tools --> Hash Generator.

Type in "lazer" without quotes into the "input" text box and click "Generate."

It should display output number "3013282534", which is, however, an unsigned integer, or otherwise, not a value below 2.1 million. Now let's take a look at the Hex value.


It's now displayed as "0xB39B0AE6" and when you copy-paste it into the Calculator with HEX active,

bingo! The value is same/equivalent as the decimal one.


Now, if you try to look on the references or opening the XML of the Supersonic mod, you'll notice that P-996 LAZER uses the negative number to declare the vehicle hash of its model.

If you copy-paste that number into Calculator with DEC active,

you'll see the HEX value will be comprised with 8 "F" letters before the hash, which is the same one as you put into the OpenIV's Hash Generator, but the value is "flipped." "Flipped" means if the decimal value is higher than the maximum integer value, it will return a negative number. Don't be surprised, though, because this is normal in programming.


The maximum integer value in Hex is 7FFFFFFF16. In Decimal is explained before. If you try to put 8000000016 in Hex it's still printed as decimal, but not integer in computer programming. You know what I mean?

If you are a programmer and try to put integer values higher like this, it'll throw an error during compiling. Simply put, you can either change the data type of such variable to a long integer (long) or universal integer (uint), or use a negative number equivalent to that hex. But since the scripts are compiled and cannot be changed its data type, using a negative number is a viable solution.

You'll see before that HEX value is comprised of 8 "F" letters before the model hash. So let's try to put 8 of them before the 8000000016, so it formed the value FFFFFFFF8000000016.

Try put 1 in the Hex (by clicking + and 1, followed by =, or type +, 1 and = on the keyboard in sequence).


If it's done correctly then you'll see in decimal the maximum integer value in negative number.

In conclusion, any model hash value in Hex that is higher than 7FFFFFFF16 can still be recorded in the script if the integer number is in negative. Simply put, if you try to put "minus 1" (-1) on Calculator with DEC active (or type on keyboard/click 1 and then press ±), the HEX value will be FFFFFFFFFFFFFFFF16. Again don't be surprised. This is normal. You just only need to pull the first 8 hex digits (from right to left as in any numeric data types) so it can form the model hash of particular model.



Getting an Addon Vehicle Model Hash and Convert it

There are a lot of add-on vehicle mods published over the internet until today, and the scripts I used are particularly based from one of the add-on packs. They are named uniquely, which resulted a random hash value if you put them into the OpenIV Hash Generator.

However, these add-on vehicles' hash model can be only retrieved from special programs or scripts that can record the vehicle model, and only a few was made. In programming a script for V, there is a function where you can refer to a text (string) instead of numerical value, such as

(WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_CARBINERIFLE_MK2")

This is a sample I got from the Mk2 Weapons Deal mod, which is open-source for developers who wanted to add more weapons into the "unofficial buy" system other than in Ammu-Nation.

For script programmers, I'd say it's easy, but what if you want to deal add-on things like new peds and such?


Let me pull out a sample from PANICO TOTAL's War Pack / Special Edition USA [Add-On] mod that I'm using today.

I'm gonna put the "F-35B Marines" from the list PANICO TOTAL has offered into both
Jet HUD and Supersonic scripts.

Open up its Readme. You'll see a list of vehicle names along with its spawn name for trainer usage. In the list, the "F-35B Marines" has a model name f35bm.

Run OpenIV and select GTA V. Then click Tools --> Hash Generator. Type f35bm and click on "Hex" radio button.

The output value will be displayed as 0x2D2B2A33. Let's put that into a Calculator with HEX active.

Check the DEC value. If the value is lower than maximum integer value then it's safe to continue by copy-pasting the DEC value from Calculator into Jet_HUD_Aircrafts.ini.


Now here's the sample with the hash value higher than maximum integer value.

"F/A-18D Hornet" has a model name fa18d, and its output will be displayed as 0xB278252B.
 You'll see the DEC value at near 3 million, which if you just paste them into Jet_HUD_Aircrafts.ini, the script won't read it, because the script uses integer value, not long integer or unsigned integer. Trust me. If you add the hash manually in a condition like this (or still in hexadecimal value), HUD elements or Supersonic effects will not appear if you hop into "F/A-18D Hornet" unless you press the predefined keys (Crouch, Jump, and Accelerate keys) to register the aircraft into the script.

To make them readable, you'll have to convert the DEC value to a negative number.  Before you do that, ensure that the hex value is higher than 7FFFFFFF16 as I mentioned before. Add 8 "F" letters BEFORE the hash value of the model, not AFTER. You should see the hex value as FFFFFFFFB278252B16. Paste that into Calculator with HEX active.


There you have the negative decimal value for use with the scripts that really uses the integer data type. Copy-paste the DEC value from Calculator into Jet_HUD_Aircrafts.ini and you are ready to test the appearance of HUD elements in "F/A-18D Hornet."


Conclusion/Closing

A single letter of a model name will represent a hash value, either in decimal or hexadecimal. Even a word can form a hash value in OpenIV Hash Generator. For example, "TuxBird" (one of my YT channels I subscribed lately) has a hash value in OpenIV.

My advice on using this method is double-check your model name and IDE before using Hash Generator and convert them into proper integer value. A typo can cause different hash value to appear, so be careful.


I hope this tutorial helps you out, although very long if you look at it. Thanks for reading and I'll see you again on the next post.

Comments

  1. He also claims that the video game industry corrupts people and sows violence against each other. LaPierre then turned his attention to the rest of the media, saying that films like American Psycho and Natural Born killers "are aired like propaganda loops" and that they, like some music videos out there, glorify murder as a way of life.

    gta 5 apk

    ReplyDelete

Post a Comment