Even vehicles with more than 4 wheels (e.g. trucks) only have 4 tire states.
Which bit stores what?
The damage of all tires will be saved together in 1 nibble (which is 4 bits) for 4-wheeled vehicles and in 1 pair (which is 2 bits) for 2-wheeled vehicles. Each bit stores whether the corresponding tire is popped (value 1) or not (value 0).
- The first bit stores the state of the back-right tire for a 4-wheeled vehicle or the back tire for a 2-wheeled vehicle.
- The second bit stores the state of the front-right tire for a 4-wheeled vehicle or the front tire for a 2-wheeled vehicle.
- The third bit stores the state of the back-left tire for a 4-wheeled vehicle.
- The fourth bit stores the state of the front-left tire for a 4-wheeled vehicle.
Notice that the bits are counted from behind, so the first bit is the rightmost bit.
The following code tells that for a 4-wheeled vehicle two tires are popped and two are not:
However, SA-MP returns a decimal number so you have to convert it to a binary number first to get a result like above. What SA-MP would return given the example above is this:
Here is a visual representation of the tire states. Vehicle viewed from a top-down perspective, with the upper values being the front of the vehicle and the lower values the back of the vehicle.
4 bits for 4-wheeled vehicles: (FL)(BL)(FR)(BR) (Front-Left, Back-Left, Front-Right and Back-Right).
After 15 the values are repeated, so 16 is 0, 17 is 1 and so on.
2-wheeled vehicles (bikes)
2 bits for 2-wheeled vehicles: (F)(B) (Front and Back).
After 3 the values are repeated, so 4 is 0, 5 is 1 and so on.
To pop the back two tires of a 4-wheeled vehicle while keeping the front unchanged: