summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/include/GlobalAPI/stocks.inc
blob: 52596c4df4fd1bfcbe18614728b1aa4394899e95 (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
// ================== DOUBLE INCLUDE ========================= //

#if defined _GlobalAPI_Stocks_included_
#endinput
#endif
#define _GlobalAPI_Stocks_included_

// =========================================================== //

/**
 * Gets plugin's display name from its handle
 *
 * @param plugin				Plugin handle to retrieve name from
 * @return						String representation of the plugin name
 */
stock char[] GetPluginDisplayName(Handle plugin)
{
	char pluginName[GlobalAPI_Max_PluginName_Length] = "Unknown";
	GetPluginInfo(plugin, PlInfo_Name, pluginName, sizeof(pluginName));

	return pluginName;
}

/**
 * Gets plugin's version from its handle
 *
 * @param plugin				Plugin handle to retrieve version from
 * @return						String representation of the plugin version
 */
stock char[] GetPluginVersion(Handle plugin)
{
	char pluginVersion[GlobalAPI_Max_PluginVersion_Length] = "Unknown";
	GetPluginInfo(plugin, PlInfo_Version, pluginVersion, sizeof(pluginVersion));

	return pluginVersion;
}

/**
 * Gets current map's "display name"
 *
 * @param buffer				Buffer to store the result in
 * @param maxlength				Max length of the buffer
 * @noreturn
 */
stock void GetMapDisplay(char[] buffer, int maxlength)
{
	char map[PLATFORM_MAX_PATH];
	GetCurrentMap(map, sizeof(map));
	GetMapDisplayName(map, map, sizeof(map));
	
	FormatEx(buffer, maxlength, map);
}

/**
 * Gets current map's full (game dir) path
 *
 * @param buffer				Buffer to store result in
 * @param maxlength				Max length of the buffer
 * @noreturn
 */
stock void GetMapFullPath(char[] buffer, int maxlength)
{
	char mapPath[PLATFORM_MAX_PATH];
	GetCurrentMap(mapPath, sizeof(mapPath));
	
	Format(buffer, maxlength, "maps/%s.bsp", mapPath);
}