/
nj_regen.sp
60 lines (52 loc) · 1.47 KB
/
nj_regen.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
// player_hurt trigger version
#pragma semicolon 1
#include <sourcemod>
#include <tf2>
#define PLUGIN_VERSION "0.0.3"
public Plugin:myinfo =
{
name = "nj_Regen",
author = "god",
description = "regen command",
version = PLUGIN_VERSION,
url = "http://github.com/withgod/sm-nj_regen"
};
public OnPluginStart()
{
CreateConVar("nj_regen_version", PLUGIN_VERSION, "nj Regen Command Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
RegConsoleCmd("nj_regen_on", Command_RegenOn);
RegConsoleCmd("nj_regen_off", Command_RegenOff);
RegConsoleCmd("nj_regen", Command_RegenHandle);
}
public Action:Command_RegenHandle(client, args)
{
new String:arg[128];
GetCmdArg(1, arg, sizeof(arg));
if (StrEqual(arg, "on"))
{
Command_RegenOn(client, args);
}
else if (StrEqual(arg, "off"))
{
Command_RegenOff(client, args);
}
else
{
PrintToChat(client, "[nj]invalid parameter. this plugin accept on/off");
}
}
public Action:Command_RegenOn(client, args)
{
PrintToChat(client, "[nj][regen on]activate regen mode");
HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
}
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
TF2_RegeneratePlayer(GetClientOfUserId(GetEventInt(event, "userid")));
return Plugin_Continue;
}
public Action:Command_RegenOff(client, args)
{
PrintToChat(client, "[nj][regen off]deactivate regen mode");
UnhookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
}