StartRecordingPlayerData: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
retvals=This function does not return any specific values.|
retvals=This function does not return any specific values.|
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]]
}}
}}

Revision as of 07:26, 10 March 2022


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


Parameters:

(playerid, recordtype, recordname[])

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 npcscripts/recordings with an automatically added .rec extension.


Return Values:
This function does not return any specific values.


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.