-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhvh_public.sp
More file actions
101 lines (82 loc) · 2.69 KB
/
hvh_public.sp
File metadata and controls
101 lines (82 loc) · 2.69 KB
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
94
95
96
97
98
99
100
101
#include <sourcemod>
#include <cstrike>
ConVar um_rage_quit;
ConVar um_reset_score;
public Plugin:myinfo =
{
name = "unmatched.gg HvH Public",
author = "imi-tat0r",
description = "Core functionality for unmatched.gg public servers",
version = "1.0"
};
public void OnPluginStart()
{
um_rage_quit = CreateConVar("um_rage_quit", "1", "If this cvar is enabled, rage quit is enabled", FCVAR_NOTIFY | FCVAR_REPLICATED);
um_reset_score = CreateConVar("um_reset_score", "1", "If this cvar is enabled, reset score is enabled", FCVAR_NOTIFY | FCVAR_REPLICATED);
ServerCommand("mp_backup_round_file \"\"");
ServerCommand("mp_backup_round_file_last \"\"");
ServerCommand("mp_backup_round_file_pattern \"\"");
ServerCommand("mp_backup_round_auto 0");
RegConsoleCmd("rq", Command_RageQuit);
RegConsoleCmd("ragequit", Command_RageQuit);
RegConsoleCmd("rs", Command_ResetScore);
RegConsoleCmd("resetscore", Command_ResetScore);
}
public void OnMapStart()
{
ServerCommand("mp_backup_round_file \"\"");
ServerCommand("mp_backup_round_file_last \"\"");
ServerCommand("mp_backup_round_file_pattern \"\"");
ServerCommand("mp_backup_round_auto 0");
}
public Action Command_RageQuit(int client, int args)
{
// feature disabled
if (!GetConVarBool(um_rage_quit))
return Plugin_Handled;
// invalid client
if (!IsValidClient(client))
return Plugin_Handled;
// get client name
char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));
// public shame
PrintToChatAll("[unmatched.\x10gg\x01] \x04%s\x01 just rage quit.", name)
// kick message
KickClient(client, "Rage quit!");
return Plugin_Handled;
}
public Action Command_ResetScore(int client, int args)
{
// feature disabled
if (!GetConVarBool(um_reset_score))
return Plugin_Handled;
// invalid client
if (!IsValidClient(client))
return Plugin_Handled;
// get client name
char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));
// check if already 0
if(GetClientDeaths(client) == 0 && GetClientFrags(client) == 0 && CS_GetClientAssists(client) == 0 && CS_GetMVPCount(client) == 0)
{
PrintToChat(client, "[unmatched.\x10gg\x01] Your score already is 0.")
return Plugin_Continue;
}
// reset stats
SetEntProp(client, Prop_Data, "m_iFrags", 0);
SetEntProp(client, Prop_Data, "m_iDeaths", 0);
CS_SetMVPCount(client, 0);
CS_SetClientAssists(client, 0);
CS_SetClientContributionScore(client, 0);
// public shame
PrintToChatAll("[unmatched.\x10gg\x01] Player \x04%s\x01 just reset their score.", name)
return Plugin_Handled;
}
stock bool IsValidClient(int client)
{
if(client <= 0 ) return false;
if(client > MaxClients) return false;
if(!IsClientConnected(client)) return false;
return IsClientInGame(client);
}