/
myjailbreak_rankme.sp
176 lines (141 loc) · 4.84 KB
/
myjailbreak_rankme.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* MyJailbreak - Ratio - RankMe Support.
* by: shanapu
* https://github.com/shanapu/MyJailbreak/
*
* Copyright (C) 2016-2017 Thomas Schmidt (shanapu)
*
* This file is part of the MyJailbreak SourceMod Plugin.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************************
STARTUP
******************************************************************************/
// Includes
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <colors>
#include <autoexecconfig>
#include <mystocks>
#include <rankme>
#include <myjailbreak>
// Compiler Options
#pragma semicolon 1
#pragma newdecls required
// Console Variables
ConVar gc_iMinRankMePointsRatio;
ConVar gc_iMinRankMePointsWarden;
char g_sPrefixW[64];
char g_sPrefixR[64];
// Info
public Plugin myinfo = {
name = "MyJailbreak - RankMe Support for Ratio & Warden",
author = "shanapu, Addicted, good_live",
description = "Adds support for lokizitos RankMe plugin to MyJB ratio & warden",
version = MYJB_VERSION,
url = MYJB_URL_LINK
};
// Start
public void OnPluginStart()
{
// Translation
LoadTranslations("MyJailbreak.Ratio.phrases");
LoadTranslations("MyJailbreak.Warden.phrases");
// AutoExecConfig
AutoExecConfig_SetFile("Ratio", "MyJailbreak");
AutoExecConfig_SetCreateFile(true);
gc_iMinRankMePointsRatio = AutoExecConfig_CreateConVar("sm_ratio_rankme", "0", "0 - disabled, how many rankme points a player need to join ct? (only if stamm is available)", _, true, 0.0);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
// AutoExecConfig
AutoExecConfig_SetFile("Warden", "MyJailbreak");
AutoExecConfig_SetCreateFile(true);
gc_iMinRankMePointsWarden = AutoExecConfig_CreateConVar("sm_warden_rankme", "0", "0 - disabled, how many rankme points a player need to become warden? (only if stamm is available)", _, true, 0.0);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
// Hooks
HookEvent("player_spawn", Event_OnPlayerSpawn, EventHookMode_Post);
}
public void OnAllPluginsLoaded()
{
if (!LibraryExists("myratio") && !LibraryExists("warden"))
{
SetFailState("MyJailbreaks Ratio (ratio.smx) and Warden (warden.smx) plugins are missing. You need at least one of them.");
}
}
public void OnConfigsExecuted()
{
ConVar cBuffer = FindConVar("sm_ratio_prefix");
cBuffer.GetString(g_sPrefixR, sizeof(g_sPrefixR));
cBuffer = FindConVar("sm_warden_prefix");
cBuffer.GetString(g_sPrefixW, sizeof(g_sPrefixW));
}
public Action MyJailbreak_OnJoinGuardQueue(int client)
{
if (RankMe_GetPoints(client) < gc_iMinRankMePointsRatio.IntValue)
{
CPrintToChat(client, "%s %t", g_sPrefixR, "ratio_rankme", gc_iMinRankMePointsRatio.IntValue);
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action warden_OnWardenCreate(int client, int caller)
{
if (RankMe_GetPoints(client) < gc_iMinRankMePointsWarden.IntValue)
{
CPrintToChat(client, "%s %t", g_sPrefixW, "warden_rankme", gc_iMinRankMePointsWarden.IntValue);
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action Event_OnPlayerSpawn(Event event, const char[] name, bool bDontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!IsValidClient(client, false, false))
return Plugin_Continue;
if (GetClientTeam(client) != CS_TEAM_CT)
return Plugin_Continue;
if (MyJailbreak_IsEventDayRunning())
return Plugin_Continue;
if (RankMe_GetPoints(client) < gc_iMinRankMePointsRatio.IntValue)
{
CPrintToChat(client, "%s %t", g_sPrefixR, "ratio_rankme", gc_iMinRankMePointsRatio.IntValue);
CreateTimer(5.0, Timer_SlayPlayer, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Continue;
}
return Plugin_Continue;
}
public Action Timer_SlayPlayer(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if ((IsValidClient(client, false, false)) && (GetClientTeam(client) == CS_TEAM_CT))
{
ForcePlayerSuicide(client);
ChangeClientTeam(client, CS_TEAM_T);
CS_RespawnPlayer(client);
MinusDeath(client);
}
return Plugin_Stop;
}
void MinusDeath(int client)
{
if (IsValidClient(client, true, true))
{
int frags = GetEntProp(client, Prop_Data, "m_iFrags");
int deaths = GetEntProp(client, Prop_Data, "m_iDeaths");
SetEntProp(client, Prop_Data, "m_iFrags", (frags + 1));
SetEntProp(client, Prop_Data, "m_iDeaths", (deaths - 1));
}
}