StartRecordingPlayerData: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;">
The parameter flags was added in v1.8 (not released as of 19.Dec.2023) and will not work in previous versions. See [[Special:PermanentLink/240|StartRecordingPlayerData]]
</poem>
{{Welcome|
{{Welcome|
desc=Starts recording player movements to a file which can be reproduced by an NPC|
desc=Starts recording player movements to a file which can be reproduced by an NPC|
params=<syntaxhighlight lang="lua">(playerid, recordtype, recordname[])</syntaxhighlight>
params=<syntaxhighlight lang="lua">(playerid, recordtype=3, recordname="", flags=60)</syntaxhighlight>
<poem>::playerid : The ID of the player whose actions to be recorded
<poem>::playerid : The ID of the player whose actions to be recorded
::recordtype : The [[RecordingTypes|type]] of the recording.
::recordtype : The [[RecordingTypes|type]] of the recording.
::recordname : The name of the file which will store the data. The file will be saved in npcscripts/recordings with an automatically added [[.rec_file|.rec]] extension.</poem>|
::recordname : The name of the file which will store the data. The file will be saved in <source inline>recordings</source> or <source inline>npcscripts/recordings</source> with an automatically added [[.rec_file|.rec]] extension. If this parameter is empty string or is omitted, plugin will create file based on system time, date and name of player. Provide <source inline>recdir 2</source> in  [[Server.cfg#recdir|server.cfg]] to save in <source inline>npcscripts/recordings</source>.
retvals=This function does not return any specific values.|
::flags : Specify one or more value combined from [[Recording_Flags|flags]] by using 'bitwise OR'. 0 means nothing will be recorded. </poem>|
retvals='''true''', on success and '''false''', on failure. Failure means the player is not connected.|
example=<source lang="lua">
example=<source lang="lua">
 
function onPlayerCommand(player,cmd,text)
{
if(cmd=="ofrecord")
{
if(player.IsAdmin==false)
{
ClientMessage("You need Admin privilege to use this command",player,255,255,255);
return;
}
if(player.Vehicle)
{
ClientMessage("You cannot be in vehicle when using this command",player,255, 255, 255);
return;
}
if(!text)
{
ClientMessage("Usage: /ofrecord filename",player,255, 255, 255);
return;
}
local success=StartRecordingPlayerData(player.ID, PLAYER_RECORDING_TYPE_ONFOOT, text);
if(success)
ClientMessage("[Recording]Started",player,255, 255, 255);
else
ClientMessage("Command Failed", player, 255, 255, 255);
}else if (cmd=="vrecord")
{
if(player.IsAdmin==false)
{
ClientMessage("You need Admin privilege to use this command",player,255,255,255);
return;
}
if(!player.Vehicle)
{
ClientMessage("You must be in a vehicle to use this command",player,255, 255, 255);
return;
}
if(!text)
{
ClientMessage("Usage: /vrecord filename",player, 255, 255, 255);
return;
}
local success=StartRecordingPlayerData(player.ID, PLAYER_RECORDING_TYPE_DRIVER, text);
if(success)
ClientMessage("[Recording]Started",player, 255, 255, 255);
else
ClientMessage("Command Failed", player,255, 255, 255);
}else if(cmd=="stoprecord")
{
local success=StopRecordingPlayerData(player.ID);
if(success)
ClientMessage("[Recording]Stopped",player, 255, 255, 255);
else
ClientMessage("Command Failed", player,255, 255, 255);
}
}
</source>|
</source>|
relfuncs=*[[StopRecordingPlayerData]]
relfuncs=*[[StopRecordingPlayerData]]
*[[StartRecordingAllPlayerData]]
}}
}}

Latest revision as of 14:53, 4 February 2024

The parameter flags was added in v1.8 (not released as of 19.Dec.2023) and will not work in previous versions. See StartRecordingPlayerData


Description:
Starts recording player movements to a file which can be reproduced by an NPC


Parameters:

(playerid, recordtype=3, recordname="", flags=60)

playerid : The ID of the player whose actions to be recorded
recordtype : The type of the recording.
recordname : The name of the file which will store the data. The file will be saved in recordings or npcscripts/recordings with an automatically added .rec extension. If this parameter is empty string or is omitted, plugin will create file based on system time, date and name of player. Provide recdir 2 in server.cfg to save in npcscripts/recordings.
flags : Specify one or more value combined from flags by using 'bitwise OR'. 0 means nothing will be recorded.


Return Values:
true, on success and false, on failure. Failure means the player is not connected.


Example

function onPlayerCommand(player,cmd,text)
{
	if(cmd=="ofrecord")
	{
		if(player.IsAdmin==false)
		{
			ClientMessage("You need Admin privilege to use this command",player,255,255,255);
			return;
		}
		if(player.Vehicle)
		{
			ClientMessage("You cannot be in vehicle when using this command",player,255, 255, 255);
			return;
		}
		if(!text)
		{
			ClientMessage("Usage: /ofrecord filename",player,255, 255, 255);
			return;
		}
		local success=StartRecordingPlayerData(player.ID, PLAYER_RECORDING_TYPE_ONFOOT, text);
		if(success)
			ClientMessage("[Recording]Started",player,255, 255, 255);
		else 
			ClientMessage("Command Failed", player, 255, 255, 255);
	}else if (cmd=="vrecord")
	{
		if(player.IsAdmin==false)
		{
			ClientMessage("You need Admin privilege to use this command",player,255,255,255);
			return;
		}
		if(!player.Vehicle)
		{
			ClientMessage("You must be in a vehicle to use this command",player,255, 255, 255);
			return;
		}
		if(!text)
		{
			ClientMessage("Usage: /vrecord filename",player, 255, 255, 255);
			return;
		}
		local success=StartRecordingPlayerData(player.ID, PLAYER_RECORDING_TYPE_DRIVER, text);
		if(success)
			ClientMessage("[Recording]Started",player, 255, 255, 255);
		else 
			ClientMessage("Command Failed", player,255, 255, 255);
	}else if(cmd=="stoprecord")
	{
		local success=StopRecordingPlayerData(player.ID);
		if(success)
			ClientMessage("[Recording]Stopped",player, 255, 255, 255);
		else 
			ClientMessage("Command Failed", player,255, 255, 255);
		
	}
}

Related Functions

The following functions may be helpful as they relate to this function in one way or another.