.rec file
From SA-MP Wiki
Notes |
|
Contents |
.rec files
The .rec files are SA-MP's files for recorded NPC movements and actions. Normally the files are created ingame by recording a player's actions. Then they can be used by NPC scripts to be played back, so the NPC exactly repeats the recorded actions. Only files in the npcmodes/recordings/ directory can be accessed by NPC scripts, while ingame recorded files are stored to 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, and so the NPC's actions are stored fluently. The data is stored as bytes in little endian order. Single data values can be 1, 2 or 4 bytes long, and so either are bytes, shorts, integers or floats in IEEE-754 format. Some should be signed and others unsigned, but it depends on how you are using them and isnt important for the structure itself (the listed signed/unsigned are oriented on their common PAWN usage). Also, to work with .rec files, a hex editor is necessary of course.
HEADER[8]DATABLOCK[72]DATABLOCK[72]...
File header
The .rec file header got the same structure for both vehicle and on-foot recordings. It is 8 bytes long, where the first 4 bytes are an integer. As it seems it always has the value 1000, probably as a identifier so SA-MP knows it is a NPC recording. The other 4 bytes are another integer, either "1" for vehicle recordings, or "2" for on-foot recordings, so only the lowest bytes of it are in use, the rest is always 0.
[*] Offset is relative to the file's beginning
Data blocks
On-foot data
The data blocks of on-foot recordings are 72 bytes long, so offset +72 would refer to the beginning of the next data block. It contains about everything a normal player can do, I just didnt figure out if setting his aimvector is possible, maybe it is done via the quaternions.
[*] Offset relative to the beginning of the data block.
[**] The quaternions indeed rotate the character, allowing to put him upside down etc.
Vehicle data
Data blocks for vehicle records are slightly shorter, and just 67 bytes long. I didnt analyize them as much as I analyzed the on-foot data, but already got the most important attributes. All in all the structure is quite similar to the on-foot data.
[*] Offset relative to the beginning of the data block.
[**] The keys got a strange behaviour, probably this isnt the right order.