.rec file
{{{content}}}
{{{content}}}
{{{content}}}
{{{content}}}
{{{content}}}
{{{content}}}
{{{content}}}
{{{content}}}
Loose test
.rec files
The `.rec` files are SA-MP's files for recorded NPC movements and actions. Normally, these files are created in-game by recording a player's actions. They can then be used by NPC scripts to play back the exact recorded actions. Only files in the `npcmodes/recordings/` directory can be accessed by NPC scripts, while in-game recorded files are stored in the `scriptfiles` directory.
General structure
The `.rec` file format consists of a header, followed by a non-separated sequence of data blocks. Every data block completely describes the player state at a specific moment, enabling fluent storage of the NPC's actions. Data is stored as bytes in little endian order. Single data values can be 1, 2, or 4 bytes long, represented as bytes, shorts, integers, or floats in IEEE-754 format. Some should be signed and others unsigned, depending on usage in PAWN scripts. To work with `.rec` files, a hex editor is required.
`HEADER[8]DATABLOCK[72]DATABLOCK[72]...`
File header
The `.rec` file header has the same structure for both vehicle and on-foot recordings. It is 8 bytes long:
- The first 4 bytes are an integer, which always has the value 1000 (probably to identify it as an NPC recording for SA-MP).
- The next 4 bytes are another integer: "1" for vehicle recordings or "2" for on-foot recordings, with only the lowest bytes used.
Header Structure
Offset | Type | Meaning |
---|---|---|
0-3 | integer | File identifier, always `0xE8030000` (decimal 1000) |
4-7 | integer | 1 for vehicle recordings, 2 for on-foot recordings |
Offset is relative to the file's beginning.
Data blocks
On-foot data
On-foot data blocks in `.rec` files are 72 bytes long. Each block describes a player's state and actions at a particular time. The structure includes most actions, though certain details, like aim vector, may use quaternions for rotation.
On-foot Data Block Structure
Offset | Type | Meaning |
---|---|---|
0-3 | unsigned integer | Time to apply this block's attributes [ms] |
4-5 | signed short | Left/right key code (e.g., `0x00FF` for left, `0xFF00` for right) |
6-7 | signed short | Up/down key code |
8-9 | unsigned short | Additional key code (e.g., `KEY_HANDBRAKE`) |
10-13 | float | X position |
14-17 | float | Y position |
18-21 | float | Z position |
22-25 | float | Quaternion component 1 for facing angles |
26-29 | float | Quaternion component 2 for facing angles |
30-33 | float | Quaternion component 3 for facing angles |
34-37 | float | Quaternion component 4 for facing angles |
38 | byte | Health |
39 | byte | Armour |
40 | unsigned byte | ID of the current held weapon |
41 | unsigned byte | Current special action (not all are functional with NPCs) |
42-45 | float | Current X velocity |
46-49 | float | Current Y velocity |
50-53 | float | Current Z velocity |
54-57 | float | Current surfing X |
58-61 | float | Current surfing Y |
62-65 | float | Current surfing Z |
66-67 | unsigned short | Current surfing vehicle ID |
68-69 | unsigned short | Current animation index |
70-71 | short | Animation parameters (requires further investigation) |
Offset is relative to the beginning of the data block. Quaternions can rotate the character fully, including upside down.
Vehicle data
Data blocks for vehicle records are 67 bytes long. Though less analyzed, the structure is similar to on-foot data, capturing core attributes.
Vehicle Data Block Structure
Offset | Type | Meaning |
---|---|---|
0-3 | unsigned integer | Time to apply this block's attributes |
4-5 | short | Vehicle ID (seems unimportant) |
6-7 | unsigned short | Left/right key code |
8-9 | unsigned short | Up/down key code |
10-11 | signed short | Additional key code |
12-15 | float | Vehicle rotation quaternion component 1 |
16-19 | float | Vehicle rotation quaternion component 2 |
20-23 | float | Vehicle rotation quaternion component 3 |
24-27 | float | Vehicle rotation quaternion component 4 |
28-31 | float | X position |
32-35 | float | Y position |
36-39 | float | Z position |
40-43 | float | X velocity |
44-47 | float | Y velocity |
48-51 | float | Z velocity |
52-55 | float | Vehicle health |
56 | byte | Driver health |
57 | byte | Driver armour |
58 | byte | Currently held weapon ID |
59 | byte | Siren state |
60 | byte | Gear state |
61-62 | unsigned short | Trailer ID |
63-66 | Unknown | (Unknown data) |
Offset is relative to the beginning of the data block. Key order may be incorrect.