forked from UNLOZE/sm-plugins
[AutoRecorder] Add two natives for information.
This commit is contained in:
@@ -15,6 +15,8 @@ bool g_bIsRecording = false;
|
||||
bool g_bIsManual = false;
|
||||
|
||||
int g_iStartedRecording;
|
||||
int g_iRecordingNumber = 1;
|
||||
int g_iRecordingFromTick;
|
||||
|
||||
// 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)
|
||||
@@ -28,6 +30,15 @@ public Plugin myinfo =
|
||||
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()
|
||||
{
|
||||
g_hAutoRecord = CreateConVar("sm_autorecord_enable", "1", "Enable automatic recording", _, true, 0.0, true, 1.0);
|
||||
@@ -94,6 +105,8 @@ public void OnMapEnd()
|
||||
StopRecord();
|
||||
g_bIsManual = false;
|
||||
}
|
||||
|
||||
g_iRecordingNumber = 1;
|
||||
}
|
||||
|
||||
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
|
||||
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_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;
|
||||
}
|
||||
}
|
||||
|
||||
public int Native_GetDemoRecordingNumber(Handle hPlugin, int numParams)
|
||||
{
|
||||
return g_iRecordingNumber;
|
||||
}
|
||||
|
||||
public int Native_GetDemoRecordingTick(Handle hPlugin, int numParams)
|
||||
{
|
||||
return GetGameTickCount() - g_iRecordingFromTick;
|
||||
}
|
||||
Reference in New Issue
Block a user