GTA: The trouble with cheats

2 min read
24 November 2023

(Warning: techy)

The cheats in the trilogy were activated by simply typing a sequence of characters.

On PC the sequence would be something like

ILOVESCOTLAND to make it rain or

GUNSGUNSGUNS to give the player loads of weapons.

The game remembers the last 20 or so keypresses and every time a new key is pressed, these keypresses are compared with the cheats. If there is a match, the cheat will activate.

The straightforward way of doing this would be to compare the string "ILOVESCOTLAND" with the string of keypresses. This approach would mean that the strings for the cheats would be in memory as readable text. Any hacker could easily find the cheats and they would all be discovered on the day of release.

This is why I used 'hash codes' to store the cheats. A hash code is a number that is calculated from a string. As an example; a simple hash algorithm could add up the ASCII values of each character of the string.

The hash code for ILOVESCOTLAND would be 983.

For GUNSGUNSGUNS it would be 951.

This is just an example. The actual Hash algorithm used is more complicated.

The game would also calculate the Hash code for the last 20 or so keypresses and compare the numbers.

The good news is that it is harder to hack the cheat because the code only stores the number (ie 983) and not the full string (ILOVESCOTLAND). This part worked because the cheats were not hacked. (They were eventually discovered by people trying random input until a cheat happened)

The bad news is that different strings can result in the same hash code.

This is why initially when cheats were discovered people found random strings (ie HDLMAAXOPK) and not the string I had set up (ie ILOVESCOTLAND)

This also meant the cheats triggered more often than I had planned. This caused cheats to sometimes happen unintentionally. This has actually happened during peoples' speed runs. These speed runs had to be aborted as the rules are clear. No cheats.

In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
May I 63
Joined: 2 years ago
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up

  • GTA: Streaming

    The hardest technical challenge to solve during the development of gta3 was the streaming. Streaming involves loading and un-loading models as the player moves...

    May I · 24 November 2023 · 10