.rec file

From NPC for VCMP 0.4 Servers
Revision as of 14:06, 4 January 2023 by Habi (talk | contribs)
Jump to navigation Jump to search

.rec files

The rec files are the files recorded by the VCMP server using the plugin-npc04relxx. Normally, the files are created by recording a player's action. They then can be used by the npc scripts for playback so that the npcs reproduce exactly the same actions. Only rec files in the npscripts/recordings directory can be accessed by the npc scripts, while the rec files created normally lie in a folder also named 'recordings' in the server 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. ).

HEADER[8]DATABLOCK[76]DATABLOCK[76]... ( for on foot recordings, datablock size is 76 in v.1.3 )

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. It is 1000 for recordings created by the first version (April 2022) of the program, whereas in release v1.4 it is 1001. The other 4 bytes represent an integer which is 1 for on foot recordings and 2 for vehicle recordings.

Offset* type meaning
0-3 integer File identifier, always e9 03 00 00
4-7 integer 1 for onfoot recordings, 2 for vehicle recordings

[*]Offset is relative to the beginning of the file.

Data blocks

On-foot data


Offset* type meaning
0-3 unsigned integer time in ms when to apply this block's data
4-7 unsigned integer the players keys
8-11 float player's position x co-ordinate
12-15 float player's position y co-ordinate
16-19 float player's position z co-ordinate
20-23 float player's Angle
24 unsigned char Health
25 unsigned char Armour
26 unsigned char Weapon
27 bool IsCrouching
28-31 float player's speed x co-ordinate
32-35 float player's speed y co-ordinate
36-39 float player's speed z co-ordinate
40 bool IsAiming
41-44 float player's aim direction x co-ordinate
45-48 float player's aim direction y co-ordinate
49-52 float player's aim direction z co-ordinate
53-56 float player's aim position x co-ordinate
57-60 float player's aim position y co-ordinate
61-64 float player's aim position z co-ordinate
65 (new) bool IsReloading
66-67 (new) unsigned short ammo

[*]Offset is relative to the datablock

Vehicle data


Offset* type meaning
0-3 unsigned integer time in ms when to apply this block's data
4-5 unsigned short Vehicle ID
6-9 unsigned integer player's keys
10-13 float vehicle rotation quaternion x component
14-17 float vehicle rotation quaternion y component
18-21 float vehicle rotation quaternion z component
22-25 float vehicle rotation quaternion w component
26-29 float vehicle position x co-ordinate
30-33 float vehicle position y co-ordinate
34-37 float vehicle position z co-ordinate
38-41 float vehicle speed x component
42-45 float vehicle speed y component
46-49 float vehicle speed z component
50-53 float vehicle Health
54 unsigned char player Health
55 unsigned char player Armour
56 unsigned char player Current Weapon
57-60 unsigned integer vehicle Damage
61-64 float Turret x
65-68 float Turret y
69-70 (new) unsigned short Ammo

[*]Offset is relative to the datablock


Note: Thanks to samp-npc-wiki-rec-file-data