-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkpointcachetest.sp
66 lines (53 loc) · 1.38 KB
/
checkpointcachetest.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
65
66
#include <sourcemod>
#include <shavit/core>
#include <shavit/checkpoints>
cp_cache_t gA_Cache;
int gI_CacheIdx;
public void OnPluginStart()
{
RegConsoleCmd("sm_loadcache", Command_Load, "Description");
RegConsoleCmd("sm_savecache", Command_Save, "Description");
RegConsoleCmd("sm_printclients", Command_PrintClients, "Description");
}
void DeleteCheckpointCache(cp_cache_t cache)
{
delete cache.aFrames;
delete cache.aEvents;
delete cache.aOutputWaits;
delete cache.customdata;
}
public Action Command_Load(int client, int args)
{
bool result = Shavit_LoadCheckpointCache(client, gA_Cache, gI_CacheIdx, sizeof(cp_cache_t));
PrintToChat(client, "load result = %d", result);
return Plugin_Handled;
}
public Action Command_Save(int client, int args)
{
if (args < 2)
{
PrintToChat(client, "usage: !savecache target index");
return Plugin_Handled;
}
DeleteCheckpointCache(gA_Cache);
char arg1[8], arg2[8];
GetCmdArg(1, arg1, 8);
GetCmdArg(2, arg2, 8);
int target = StringToInt(arg1);
gI_CacheIdx = StringToInt(arg2);
cp_cache_t emptycache;
gA_Cache = emptycache;
Shavit_SaveCheckpointCache(client, target, gA_Cache, gI_CacheIdx, sizeof(cp_cache_t));
return Plugin_Handled;
}
public Action Command_PrintClients(int client, int args)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i))
{
PrintToChat(client, "%d = %N", i, i);
}
}
return Plugin_Handled;
}