summaryrefslogtreecommitdiff
path: root/source/sourcemod/scripting/gokz-core/demofix.sp
blob: 3839fad0237a1f13e36e54431695b263485808b7 (plain)
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
65
66
67
68
69
70
71
72
73
static ConVar CV_EnableDemofix;
static Handle H_DemofixTimer;
static bool mapRunning;

void OnPluginStart_Demofix()
{
	AddCommandListener(Command_Demorestart, "demorestart");
	CV_EnableDemofix = AutoExecConfig_CreateConVar("gokz_demofix", "1", "Whether GOKZ applies demo record fix to server. (0 = Disabled, 1 = Update warmup period once, 2 = Regularly reset warmup period)", _, true, 0.0, true, 2.0);
	CV_EnableDemofix.AddChangeHook(OnDemofixConVarChanged);
	// If the map is tweaking the warmup value, we need to rerun the fix again.
	// FindConVar("mp_warmuptime").AddChangeHook(OnDemofixConVarChanged);
	// We assume that the map is already loaded on late load.
	if (gB_LateLoad)
	{
		mapRunning = true;
	}
}

void OnMapStart_Demofix()
{
	mapRunning = true;
}

void OnMapEnd_Demofix()
{
	mapRunning = false;
}

void OnRoundStart_Demofix()
{
	// DoDemoFix();
}

public Action Command_Demorestart(int client, const char[] command, int argc)
{
	FixRecord(client);
	return Plugin_Continue;
}

static void FixRecord(int client)
{
	// For some reasons, demo playback speed is absolute trash without a round_start event.
	// So whenever the client starts recording a demo, we create the event and send it to them.
	Event e = CreateEvent("round_start", true);
	int timelimit = FindConVar("mp_timelimit").IntValue;
	e.SetInt("timelimit", timelimit);
	e.SetInt("fraglimit", 0);
	e.SetString("objective", "demofix");

	e.FireToClient(client);
	delete e;
}

public void OnDemofixConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
	// DoDemoFix();
}

public Action Timer_EnableDemoRecord(Handle timer)
{
	EnableDemoRecord();
	return Plugin_Continue;
}

static void DoDemoFix()
{

}

static void EnableDemoRecord()
{

}