summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-replays/commands.sp
blob: 43251f6622649c6ce824717fb4c54354d3316e4d (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
void RegisterCommands()
{
	RegConsoleCmd("sm_replay", CommandReplay, "[KZ] Open the replay loading menu.");
	RegConsoleCmd("sm_replaycontrols", CommandReplayControls, "[KZ] Toggle the replay control menu.");
	RegConsoleCmd("sm_rpcontrols", CommandReplayControls, "[KZ] Toggle the replay control menu.");
	RegConsoleCmd("sm_replaygoto", CommandReplayGoto, "[KZ] Skip to a specific time in the replay (hh:mm:ss).");
	RegConsoleCmd("sm_rpgoto", CommandReplayGoto, "[KZ] Skip to a specific time in the replay (hh:mm:ss).");
}

public Action CommandReplay(int client, int args)
{
	DisplayReplayModeMenu(client);
	return Plugin_Handled;
}

public Action CommandReplayControls(int client, int args)
{
	ToggleReplayControls(client);
	return Plugin_Handled;
}

public Action CommandReplayGoto(int client, int args)
{
	int seconds;
	char timeString[32], split[3][32];
	
	GetCmdArgString(timeString, sizeof(timeString));
	int res = ExplodeString(timeString, ":", split, 3, 32, false);
	switch (res)
	{
		case 1:
		{
			seconds = StringToInt(split[0]);
		}
		
		case 2:
		{
			seconds = StringToInt(split[0]) * 60 + StringToInt(split[1]);
		}
		
		case 3:
		{
			seconds = StringToInt(split[0]) * 3600 + StringToInt(split[1]) * 60 + StringToInt(split[2]);
		}
		
		default:
		{
			GOKZ_PrintToChat(client, true, "%t", "Replay Controls - Invalid Time");
			return Plugin_Handled;
		}
	}
	
	TrySkipToTime(client, seconds);
	return Plugin_Handled;
}