Tire States
note
To be used with GetVehicleDamageStatus and UpdateVehicleDamageStatus.
note
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.
Example
The following code tells that for a 4-wheeled vehicle two tires are popped and two are not:
0101
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:
5
Info table
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.
Legend:
4-wheeled vehicles
4 bits for 4-wheeled vehicles: (FL)(BL)(FR)(BR) (Front-Left, Back-Left, Front-Right and Back-Right).
0: (0000)
1: (0001)
2: (0010)
3: (0011)
4: (0100)
5: (0101)
6: (0110)
7: (0111)
8: (1000)
9: (1001)
10: (1010)
11: (1011)
12: (1100)
13: (1101)
14: (1110)
15: (1111)
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).
0: (00)
1: (01)
2: (10)
3: (11)
After 3 the values are repeated, so 4 is 0, 5 is 1 and so on.
Example usage
To pop the back two tires of a 4-wheeled vehicle while keeping the front unchanged: