.rec file
From SA-MP Wiki
| Revision as of 15:10, 3 July 2012 Mauzen (Talk | contribs) (→Vehicle data) ← Previous diff |
Revision as of 15:10, 3 July 2012 Mauzen (Talk | contribs) (→Vehicle data) Next diff → |
||
| Line 76: | Line 76: | ||
| {{rec.header|52-55|float|Vehicle health}} | {{rec.header|52-55|float|Vehicle health}} | ||
| {{rec.header|56|byte|Driver health}} | {{rec.header|56|byte|Driver health}} | ||
| - | {{rec.header|56|byte|Driver armour}} | + | {{rec.header|57|byte|Driver armour}} |
| {{rec.header|58|byte|Currently hold weaponID }} | {{rec.header|58|byte|Currently hold weaponID }} | ||
| {{rec.header|59|byte|Siren state}} | {{rec.header|59|byte|Siren state}} | ||
Revision as of 15:10, 3 July 2012
| Note: This article is based on the file structure as it is in version 0.3d. It might be different for previous or later releases. |
| Note: All the data was just collected by one person (User:Mauzen), and might be incorrect in some points. For more accurate and detailed results this needs confirmation by other people. |
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.
[**] Im not sure why and how quaternions are used here yet.
Vehicle data
Data blocks for vehicle records are slightly shorter, and just 68 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.
