/
SnowHP_SetHP_Gravity.sp
93 lines (68 loc) · 1.77 KB
/
SnowHP_SetHP_Gravity.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "xFlane"
#define PLUGIN_VERSION "1.00"
#define PREFIX "[SM]"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
//#include <sdkhooks>
#pragma newdecls required
public Plugin myinfo =
{
name = "[SM] Set hp and gravity",
author = PLUGIN_AUTHOR,
description = "",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
LoadTranslations("common.phrases");
/* Commands */
RegAdminCmd("sm_sethp", Command_SetHP, ADMFLAG_KICK);
RegAdminCmd("sm_setgravity", Command_SetGravity, ADMFLAG_KICK);
}
/* Commands */
public Action Command_SetHP(int client, int args)
{
if(args < 2)
{
PrintToChat(client, "%s Syntax error: sm_sethp <client> <amount>", PREFIX);
return Plugin_Handled;
}
char Arg1[MAX_NAME_LENGTH];
GetCmdArg(1, Arg1, MAX_NAME_LENGTH);
int target = FindTarget(client, Arg1, .immunity = false);
if(target == -1)
{
return Plugin_Handled;
}
char Arg2[16];
GetCmdArg(2, Arg2, 16);
int amount = StringToInt(Arg2);
SetEntityHealth(target, amount);
PrintToChat(client, "%s ADMIN: %N has changed %N health to %i.", PREFIX, client, target, amount);
return Plugin_Handled;
}
public Action Command_SetGravity(int client, int args)
{
if(args < 2)
{
PrintToChat(client, "%s Syntax error: sm_setgravity <client> <amount>", PREFIX);
return Plugin_Handled;
}
char Arg1[MAX_NAME_LENGTH];
GetCmdArg(1, Arg1, MAX_NAME_LENGTH);
int target = FindTarget(client, Arg1, .immunity = false);
if(target == -1)
{
return Plugin_Handled;
}
char Arg2[16];
GetCmdArg(2, Arg2, 16);
float amount = StringToFloat(Arg2);
SetEntityGravity(target, amount);
PrintToChat(client, "%s ADMIN: %N has changed %N gravity to %.2f.", PREFIX, client, target, amount);
return Plugin_Handled;
}