forked from ugurbayraktarr/Plugins-for-CSGO-Servers
-
Notifications
You must be signed in to change notification settings - Fork 3
/
basecomm.sp
262 lines (221 loc) · 7.06 KB
/
basecomm.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Communication Plugin
* Provides fucntionality for controlling communication on the server
*
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* 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.
* 1
* 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/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include <sourcemod>
#include <sdktools>
#undef REQUIRE_PLUGIN
#include <adminmenu>
#include <colors>
#pragma semicolon 1
public Plugin:myinfo =
{
name = "Basic Comm Control",
author = "AlliedModders LLC",
description = "Provides methods of controlling communication.",
version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/"
};
new bool:g_Muted[MAXPLAYERS+1]; // Is the player muted?
new bool:g_Gagged[MAXPLAYERS+1]; // Is the player gagged?
new bool:gagGor[MAXPLAYERS+1]; // Gag Görme
new gagGorMesajSure[MAXPLAYERS+1];
new g_GagTarget[MAXPLAYERS+1];
ConVar g_Cvar_Deadtalk; // Holds the handle for sm_deadtalk
ConVar g_Cvar_Alltalk; // Holds the handle for sv_alltalk
new bool:g_Hooked = false; // Tracks if we've hooked events for deadtalk
TopMenu hTopMenu;
#include "basecomm/gag.sp"
#include "basecomm/natives.sp"
#include "basecomm/forwards.sp"
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
CreateNative("BaseComm_IsClientGagged", Native_IsClientGagged);
CreateNative("BaseComm_IsClientMuted", Native_IsClientMuted);
CreateNative("BaseComm_SetClientGag", Native_SetClientGag);
CreateNative("BaseComm_SetClientMute", Native_SetClientMute);
RegPluginLibrary("basecomm");
return APLRes_Success;
}
public OnPluginStart()
{
LoadTranslations("common.phrases");
LoadTranslations("basecomm.phrases");
g_Cvar_Deadtalk = CreateConVar("sm_deadtalk", "0", "Controls how dead communicate. 0 - Off. 1 - Dead players ignore teams. 2 - Dead players talk to living teammates.", 0, true, 0.0, true, 2.0);
g_Cvar_Alltalk = FindConVar("sv_alltalk");
RegAdminCmd("sm_mute", Command_Mute, ADMFLAG_CHAT, "sm_mute <player> - Removes a player's ability to use voice.");
RegAdminCmd("sm_gag", Command_Gag, ADMFLAG_CHAT, "sm_gag <player> - Removes a player's ability to use chat.");
RegAdminCmd("sm_silence", Command_Silence, ADMFLAG_CHAT, "sm_silence <player> - Removes a player's ability to use voice or chat.");
RegAdminCmd("sm_unmute", Command_Unmute, ADMFLAG_CHAT, "sm_unmute <player> - Restores a player's ability to use voice.");
RegAdminCmd("sm_ungag", Command_Ungag, ADMFLAG_CHAT, "sm_ungag <player> - Restores a player's ability to use chat.");
RegAdminCmd("sm_unsilence", Command_Unsilence, ADMFLAG_CHAT, "sm_unsilence <player> - Restores a player's ability to use voice and chat.");
RegAdminCmd("sm_gaggor", Command_GagGor, ADMFLAG_CHAT, "Gag görme ayarı");
g_Cvar_Deadtalk.AddChangeHook(ConVarChange_Deadtalk);
g_Cvar_Alltalk.AddChangeHook(ConVarChange_Alltalk);
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say_team", Command_SayTeam);
/* Account for late loading */
TopMenu topmenu;
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != null))
{
OnAdminMenuReady(topmenu);
}
for(new i=0; i<=MaxClients; i++)
{
gagGor[i] = true;
}
}
public OnMapStart()
{
for(new i=0; i<=MaxClients; i++)
{
gagGor[i] = true;
}
}
public OnAdminMenuReady(Handle aTopMenu)
{
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */
if (topmenu == hTopMenu)
{
return;
}
/* Save the Handle */
hTopMenu = topmenu;
/* Build the "Player Commands" category */
TopMenuObject player_commands = hTopMenu.FindCategory(ADMINMENU_PLAYERCOMMANDS);
if (player_commands != INVALID_TOPMENUOBJECT)
{
hTopMenu.AddItem("sm_gag", AdminMenu_Gag, player_commands, "sm_gag", ADMFLAG_CHAT);
}
}
public ConVarChange_Deadtalk(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (g_Cvar_Deadtalk.IntValue)
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
g_Hooked = true;
}
else if (g_Hooked)
{
UnhookEvent("player_spawn", Event_PlayerSpawn);
UnhookEvent("player_death", Event_PlayerDeath);
g_Hooked = false;
}
}
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
g_Gagged[client] = false;
g_Muted[client] = false;
return true;
}
public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
{
if (client && g_Gagged[client])
{
return Plugin_Stop;
}
return Plugin_Continue;
}
public void ConVarChange_Alltalk(ConVar convar, const char[] oldValue, const char[] newValue)
{
int mode = g_Cvar_Deadtalk.IntValue;
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i))
{
continue;
}
if (g_Muted[i])
{
SetClientListeningFlags(i, VOICE_MUTED);
}
else if (g_Cvar_Alltalk.BoolValue)
{
SetClientListeningFlags(i, VOICE_NORMAL);
}
else if (!IsPlayerAlive(i))
{
if (mode == 1)
{
SetClientListeningFlags(i, VOICE_LISTENALL);
}
else if (mode == 2)
{
SetClientListeningFlags(i, VOICE_TEAM);
}
}
}
}
public Event_PlayerSpawn(Event event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(event.GetInt("userid"));
if (!client)
{
return;
}
if (g_Muted[client])
{
SetClientListeningFlags(client, VOICE_MUTED);
}
else
{
SetClientListeningFlags(client, VOICE_NORMAL);
}
}
public Event_PlayerDeath(Event event, const String:name[], bool:dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!client)
{
return;
}
if (g_Muted[client])
{
SetClientListeningFlags(client, VOICE_MUTED);
return;
}
if (g_Cvar_Alltalk.BoolValue)
{
SetClientListeningFlags(client, VOICE_NORMAL);
return;
}
int mode = g_Cvar_Deadtalk.IntValue;
if (mode == 1)
{
SetClientListeningFlags(client, VOICE_LISTENALL);
}
else if (mode == 2)
{
SetClientListeningFlags(client, VOICE_TEAM);
}
}