[AutoRecorder] Add two natives for information.
This commit is contained in:
parent
e167a1aca9
commit
ce2397e849
@ -15,6 +15,8 @@ bool g_bIsRecording = false;
|
|||||||
bool g_bIsManual = false;
|
bool g_bIsManual = false;
|
||||||
|
|
||||||
int g_iStartedRecording;
|
int g_iStartedRecording;
|
||||||
|
int g_iRecordingNumber = 1;
|
||||||
|
int g_iRecordingFromTick;
|
||||||
|
|
||||||
// Default: o=rx,g=rx,u=rwx | 755
|
// Default: o=rx,g=rx,u=rwx | 755
|
||||||
#define DIRECTORY_PERMISSIONS (FPERM_O_READ|FPERM_O_EXEC | FPERM_G_READ|FPERM_G_EXEC | FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC)
|
#define DIRECTORY_PERMISSIONS (FPERM_O_READ|FPERM_O_EXEC | FPERM_G_READ|FPERM_G_EXEC | FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC)
|
||||||
@ -28,6 +30,15 @@ public Plugin myinfo =
|
|||||||
url = "http://www.theville.org"
|
url = "http://www.theville.org"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
|
{
|
||||||
|
CreateNative("GetDemoRecordingNumber", Native_GetDemoRecordingNumber);
|
||||||
|
CreateNative("GetDemoRecordingTick", Native_GetDemoRecordingTick);
|
||||||
|
|
||||||
|
RegPluginLibrary("AutoRecorder");
|
||||||
|
return APLRes_Success;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
g_hAutoRecord = CreateConVar("sm_autorecord_enable", "1", "Enable automatic recording", _, true, 0.0, true, 1.0);
|
g_hAutoRecord = CreateConVar("sm_autorecord_enable", "1", "Enable automatic recording", _, true, 0.0, true, 1.0);
|
||||||
@ -94,6 +105,8 @@ public void OnMapEnd()
|
|||||||
StopRecord();
|
StopRecord();
|
||||||
g_bIsManual = false;
|
g_bIsManual = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_iRecordingNumber = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientPutInServer(int client)
|
public void OnClientPutInServer(int client)
|
||||||
@ -203,11 +216,14 @@ void StartRecord()
|
|||||||
// replace slashes in map path name with dashes, to prevent fail on workshop maps
|
// replace slashes in map path name with dashes, to prevent fail on workshop maps
|
||||||
ReplaceString(sMap, sizeof(sMap), "/", "-", false);
|
ReplaceString(sMap, sizeof(sMap), "/", "-", false);
|
||||||
|
|
||||||
ServerCommand("tv_record \"%s/auto-%s-%s\"", sPath, sTime, sMap);
|
ServerCommand("tv_record \"%s/auto-%s-%s-%d\"", sPath, sTime, sMap, g_iRecordingNumber);
|
||||||
g_bIsRecording = true;
|
g_bIsRecording = true;
|
||||||
g_iStartedRecording = GetTime();
|
g_iStartedRecording = GetTime();
|
||||||
|
|
||||||
LogMessage("Recording to auto-%s-%s.dem", sTime, sMap);
|
g_iRecordingNumber++;
|
||||||
|
g_iRecordingFromTick = GetGameTickCount();
|
||||||
|
|
||||||
|
LogMessage("Recording to auto-%s-%s-%d.dem", sTime, sMap, g_iRecordingNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,3 +235,13 @@ void StopRecord()
|
|||||||
g_bIsRecording = false;
|
g_bIsRecording = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Native_GetDemoRecordingNumber(Handle hPlugin, int numParams)
|
||||||
|
{
|
||||||
|
return g_iRecordingNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_GetDemoRecordingTick(Handle hPlugin, int numParams)
|
||||||
|
{
|
||||||
|
return GetGameTickCount() - g_iRecordingFromTick;
|
||||||
|
}
|
26
AutoRecorder/scripting/include/AutoRecorder.inc
Normal file
26
AutoRecorder/scripting/include/AutoRecorder.inc
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#if defined AutoRecorder_included
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define AutoRecorder_included
|
||||||
|
|
||||||
|
native int GetDemoRecordingNumber();
|
||||||
|
native int GetDemoRecordingTick();
|
||||||
|
|
||||||
|
public SharedPlugin __pl_AutoRecorder =
|
||||||
|
{
|
||||||
|
name = "AutoRecorder",
|
||||||
|
file = "AutoRecorder.smx",
|
||||||
|
#if defined REQUIRE_PLUGIN
|
||||||
|
required = 1
|
||||||
|
#else
|
||||||
|
required = 0
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined REQUIRE_PLUGIN
|
||||||
|
public void __pl_AutoRecorder_SetNTVOptional()
|
||||||
|
{
|
||||||
|
MarkNativeAsOptional("GetDemoRecordingNumber");
|
||||||
|
MarkNativeAsOptional("GetDemoRecordingTick");
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user