-
Notifications
You must be signed in to change notification settings - Fork 3
/
demosplitter.sp
64 lines (49 loc) · 1.36 KB
/
demosplitter.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma semicolon 1
#define PLUGIN_AUTHOR "Totenfluch"
#define PLUGIN_VERSION "1.00"
#pragma newdecls required
#define SPLITTIME 60
int g_iCurrentSplitTime = 0;
char oldTime[20];
public Plugin myinfo =
{
name = "[T-RP] Demo Splitter",
author = PLUGIN_AUTHOR,
description = "Splitts demos in 1h chunks",
version = PLUGIN_VERSION,
url = "https://totenfluch.de"
};
public void OnPluginStart() {
g_iCurrentSplitTime = 0;
RegAdminCmd("sm_splitnow", splitDemoNow, ADMFLAG_ROOT, "Splits the Demo instantly");
}
public void OnMapStart() {
g_iCurrentSplitTime = 0;
CreateTimer(60.0, splitTick, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
FormatTime(oldTime, sizeof(oldTime), "%d-%m-%Y-%H-%M-%S", GetTime());
splitDemo();
}
public void OnMapEnd() {
ServerCommand("tv_stoprecord");
}
public Action splitTick(Handle Timer) {
g_iCurrentSplitTime++;
if (g_iCurrentSplitTime == SPLITTIME) {
splitDemo();
g_iCurrentSplitTime = 0;
}
}
public Action splitDemoNow(int client, int args) {
splitDemo();
g_iCurrentSplitTime = 0;
return Plugin_Handled;
}
public void splitDemo() {
char sTime[20];
FormatTime(sTime, sizeof(sTime), "%d-%m-%Y-%H-%M-%S", GetTime());
char demoTitle[64];
Format(demoTitle, sizeof(demoTitle), "TRP_%s_%s", oldTime, sTime);
ServerCommand("tv_stoprecord");
ServerCommand("tv_record %s", demoTitle);
strcopy(oldTime, sizeof(oldTime), sTime);
}