The damage of each door (note that the hood and the trunk are also doors) will be saved in 1 byte (which is 8 bits). You can only change the state of one bit for every door at each time - so you have to call the function twice if you want to damage and open the door.
It seems like there is no bit which stores if the door will lock or not.
Notice that you count the bits from behind - so the first is the rightmost bit
The states of the 2 rear doors cannot be handled by GetVehicleDamageStatus and UpdateVehicleDamageStatus.
Notice that I count the bytes from behind - so the first is the rightmost byte
The following code tells that the hood is removed, the front left door damaged, the front right door opened and the trunk is damaged and opened:
00000001 00000010 00000011 00000100
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 you in this case is this:
16909060
First byte (hood):
0 (000) 1 (001) 2 (010) 3 (011) 4 (100) 5 (101) 6 (110) 7 (111)
°--° °[]° °~~° °{}° ° ° ° ° ° ° ° °
| | | | | | | | | | | | | | | |
°--° °--° °--° °--° °--° °--° °--° °--°
Second byte (trunk):
0 (000) 1 (001) 2 (010) 3 (011) 4 (100) 5 (101) 6 (110) 7 (111)
°--° °--° °--° °--° °--° °--° °--° °--°
| | | | | | | | | | | | | | | |
°--° °[]° °--° °{}° ° ° ° ° ° ° ° °
Third byte (drivers door):
0 (000) 1 (001) 2 (010) 3 (011) 4 (100) 5 (101) 6 (110) 7 (111)
°--° °--° °--° °--° °--° °--° °--° °--°
| | -- | § | ww | | | | |
°--° °--° °--° °--° °--° °--° °--° °--°
Fourth byte (co-drivers door):
0 (000) 1 (001) 2 (010) 3 (011) 4 (100) 5 (101) 6 (110) 7 (111)
°--° °--° °--° °--° °--° °--° °--° °--°
| | | -- | § | ww | | | |
°--° °--° °--° °--° °--° °--° °--° °--°
Legend:
Static Doors Hood / Trunk
° - Light | - healthy, closed -- - healthy, closed
-- - healthy, opened [] - healthy, opened
§ - damaged, closed ~~ - damaged, closed
ww - damaged, opened {} - damaged, opened
- missing - missing
Usefull little snippet to avoid working with the bits and bytes too much;
enum Door
{
DOOR_HOOD,
DOOR_TRUNK,
DOOR_DRIVER
DOOR_PASSENGER
}
enum DoorState(<<= 1)
{
IS_OPENED = 1,
IS_DAMAGED,
IS_REMOVED
}
stock GetDoorState(doorStates, Door:door, DoorState:doorState)
return (doorStates >>> (8 * door)) & doorState;
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
// simple
if(GetDoorState(doors, DOOR_DRIVER, IS_DAMAGED))
{
SendClientMessage(playerid, -1, "The driver door of your vehicle is damaged!");
}
// or even combined
if(GetDoorState(doors, DOOR_HOOD, IS_OPENED | IS_DAMAGED))
{
SendClientMessage(playerid, -1, "The hood of your vehicle is both opened and damaged!");
}