aboutsummaryrefslogtreecommitdiff
path: root/scripting/yuuko_maptimer.sp
blob: a90222f7c85532512aae8d4aff0a15686d1efa7f (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
74
75
76
77
78
79
80
81
#include <sourcemod>
#include <console>
#include <timers>

public Plugin myinfo = {
	name = "yuuko's map timer commands",
	author = "yuuko",
	description = "exposes the map-related bits of <timers> to the console",
	version = SOURCEMOD_VERSION,
	url = "https://www.partyvan.io/"
};

public Action Command_ExtendMapTimeLimit(int client, int args)
{
	if (args != 1) {
		PrintToConsole(client, "Usage: sm_extendmaptimelimit <seconds>");
		return Plugin_Handled;
	}
	int seconds = 0;
	if (!GetCmdArgIntEx(1, seconds)) {
		PrintToConsole(client, "argument must be an integer");
		return Plugin_Handled;
	}
	if (!ExtendMapTimeLimit(seconds)) {
		PrintToConsole(client, "operation not supported");
		return Plugin_Handled;
	}
	PrintToConsole(client, "map time limit extended");
	return Plugin_Handled;
}

public Action Command_GetMapTimeLimit(int client, int args)
{
	if (args != 0) {
		PrintToConsole(client, "Usage: sm_getmaptimelimit");
		return Plugin_Handled;
	}
	int minutes = 0;
	if (!GetMapTimeLimit(minutes)) {
		PrintToConsole(client, "operation not supported");
		return Plugin_Handled;
	}
	PrintToConsole(client, "%d", minutes);
	return Plugin_Handled;
}

public Action Command_GetMapTimeLeft(int client, int args)
{
	if (args != 0) {
		PrintToConsole(client, "Usage: sm_getmaptimeleft");
		return Plugin_Handled;
	}
	int seconds = 0;
	if (!GetMapTimeLeft(seconds)) {
		PrintToConsole(client, "operation not supported");
		return Plugin_Handled;
	}
	PrintToConsole(client, "%d", seconds);
	return Plugin_Handled;
}

public void OnPluginStart()
{
    RegAdminCmd(
    	"sm_extendmaptimelimit",
    	Command_ExtendMapTimeLimit,
    	ADMFLAG_CHANGEMAP,
    	"extend map time limit by argv[1] seconds"
    );
    RegConsoleCmd(
    	"sm_getmaptimelimit",
    	Command_GetMapTimeLimit,
    	"get map time limit, in minutes for some reason (api docs are a lie)"
    );
    RegConsoleCmd(
    	"sm_getmaptimeleft",
    	Command_GetMapTimeLeft,
    	"get (approximate) time left out of map time limit, in seconds"
    );
}