Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@
[submodule "sm_plugins/TF2-Dodgeball-Modified"]
path = sm_plugins/TF2-Dodgeball-Modified
url = https://github.com/Silorak/TF2-Dodgeball-Modified.git
[submodule "sm_plugins/mge"]
path = sm_plugins/mge
url = git@github.com:leighmacdonald/MGEMod.git
3 changes: 0 additions & 3 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ collections:

roles:
- name: hadret.rsyslog
- name: githubixx.ansible_role_wireguard
src: https://github.com/githubixx/ansible-role-wireguard.git
version: 17.1.0
39 changes: 24 additions & 15 deletions roles/sourcemod/files/addons/sourcemod/scripting/gbans.sp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ bool LateLoaded;

bool PlayerStatus[MAXPLAYERS + 1];


public Plugin myinfo =
{
name = "gbans",
Expand All @@ -38,6 +37,7 @@ public Plugin myinfo =
url = "https://github.com/leighmacdonald/gbans",
};


public void OnPluginStart()
{
LoadTranslations("common.phrases.txt");
Expand All @@ -46,22 +46,25 @@ public void OnPluginStart()
RegConsoleCmd("gb_help", onCmdHelp, "Get a list of gbans commands");
RegConsoleCmd("gb_mod", onCmdMod, "Ping a moderator");
RegConsoleCmd("mod", onCmdMod, "Ping a moderator");
RegConsoleCmd("seed", onCmdSeed, "Send a seed request to discord");

RegConsoleCmd("report", onCmdReport, "Report a player");
RegConsoleCmd("autoteam", onCmdAutoTeamAction);

RegAdminCmd("gb_ban", onAdminCmdBan, ADMFLAG_BAN);
RegAdminCmd("gb_reload", onAdminCmdReload, ADMFLAG_ROOT);

RegAdminCmd("gb_stv_record", Command_Record, ADMFLAG_KICK, "Starts a SourceTV demo");
RegAdminCmd("gb_stv_stoprecord", Command_StopRecord, ADMFLAG_KICK, "Stops the current SourceTV demo");

HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
HookEvent("player_connect_client", Event_PlayerConnect, EventHookMode_Pre);

AutoExecConfig_SetFile("gbans");

// Core settings
gb_core_host = AutoExecConfig_CreateConVar("gb_core_host", "localhost", "Remote gbans host", FCVAR_NONE);
gb_core_port = AutoExecConfig_CreateConVar("gb_core_port", "6006", "Remote gbans port", FCVAR_NONE, true, 1.0, true, 65535.0);
gb_core_port = AutoExecConfig_CreateConVar("gb_core_port", "6006", "Remote gbans port", FCVAR_NONE, true, 1.0, true, 65535.0);
gb_core_server_key = AutoExecConfig_CreateConVar("gb_core_server_key", "", "GBans server key used to authenticate with the service", FCVAR_NONE);

// In Game Tweaks
Expand All @@ -77,41 +80,42 @@ public void OnPluginStart()
gb_stv_timestop = AutoExecConfig_CreateConVar("gb_stv_timestop", "-1", "Hour in the day to stop recording (0-23, -1 disables)", FCVAR_NONE);
gb_stv_finishmap = AutoExecConfig_CreateConVar("gb_stv_finishmap", "1", "If 1, continue recording until the map ends", FCVAR_NONE, true, 0.0, true, 1.0);
gb_stv_path = AutoExecConfig_CreateConVar("gb_stv_path", "stv_demos/active", "Path to store currently recording demos", FCVAR_NONE);
gb_stv_path_complete = AutoExecConfig_CreateConVar("gb_stv_path_complete", "stv_demos/complete", "Path to store complete demos", FCVAR_NONE);
gb_stv_path_complete = AutoExecConfig_CreateConVar("gb_stv_path_complete", "stv_demos/complete", "Path to store complete demos", FCVAR_NONE);

AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();

//BuildPath(Path_SM, logFile, sizeof(logFile), "logs/gbans.log");

if (LateLoaded)
if(LateLoaded)
{
AccountForLateLoading();
}

reloadAdmins(true);
}


stock void AccountForLateLoading()
{
char auth[30];

for (int i = 1; i <= MaxClients; i++)
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i) && !IsFakeClient(i))
if(IsClientConnected(i) && !IsFakeClient(i))
{
PlayerStatus[i] = false;
}
if (IsClientInGame(i) && !IsFakeClient(i) && IsClientAuthorized(i) && GetClientAuthId(i, AuthId_Steam2, auth, sizeof(auth)))
if(IsClientInGame(i) && !IsFakeClient(i) && IsClientAuthorized(i) && GetClientAuthId(i, AuthId_Steam2, auth, sizeof auth))
{
checkPlayer(i);
}
}
}

public void OnConfigsExecuted() {


public void OnConfigsExecuted()
{
gb_stv_minplayers.AddChangeHook(OnConVarChanged);
gb_stv_ignorebots.AddChangeHook(OnConVarChanged);
gb_stv_timestart.AddChangeHook(OnConVarChanged);
Expand All @@ -120,7 +124,7 @@ public void OnConfigsExecuted() {

char sPath[PLATFORM_MAX_PATH];

gb_stv_path.GetString(sPath, sizeof(sPath));
gb_stv_path.GetString(sPath, sizeof sPath);
if(!DirExists(sPath))
{
initDirectory(sPath);
Expand All @@ -135,11 +139,11 @@ public void OnConfigsExecuted() {

CreateTimer(300.0, Timer_CheckStatus, _, TIMER_REPEAT);

StopRecord();
StopRecord();

if(!gStvMapChanged)
{
// STV does not function until a map change has occurred.
// STV does not function until a map change has occurred.
gbLog("Restarting map to enabled STV");
gStvMapChanged = true;
char mapName[128];
Expand All @@ -148,11 +152,13 @@ public void OnConfigsExecuted() {
}
}


public void OnClientDisconnect_Post(int client)
{
CheckStatus();
}


public void OnMapEnd()
{
if(gIsRecording)
Expand All @@ -162,15 +168,18 @@ public void OnMapEnd()
}
}

public void OnMapStart() {

public void OnMapStart()
{
reloadAdmins(true);
}


public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNative("GB_BanClient", Native_GB_BanClient);

LateLoaded = late;

return APLRes_Success;
}
71 changes: 35 additions & 36 deletions roles/sourcemod/files/addons/sourcemod/scripting/gbans/auth.sp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void checkPlayer(int clientId)
char clientAuth[64];
GetClientAuthId(clientId, AuthId_SteamID64, clientAuth, sizeof(clientAuth));


JSONObject obj = new JSONObject();
obj.SetString("steam_id", clientAuth);
obj.SetInt("client_id", clientId);
Expand All @@ -61,44 +60,44 @@ void checkPlayer(int clientId)
}


void onCheckResp(HTTPResponse response, any value)
{
void onCheckResp(HTTPResponse response, any value) {
gbLog("--- onCheckResp");
if (response.Status != HTTPStatus_OK) {
LogError("Invalid check response code: %d", response.Status);

return;
}

JSONObject data = view_as<JSONObject>(response.Data);

char msg[256];
data.GetString("msg", msg, sizeof msg);
int clientId = data.GetInt("client_id");
int banType = data.GetInt("ban_type");

switch(banType)
{
case BSNoComm: {
if(!BaseComm_IsClientMuted(clientId)) {
BaseComm_SetClientMute(clientId, true);
switch (response.Status) {
case HTTPStatus_OK:
// good boi
return;
case HTTPStatus_Forbidden: {
JSONObject data = view_as<JSONObject>(response.Data);

char msg[256];
data.GetString("msg", msg, sizeof msg);
int clientId = data.GetInt("client_id");
int banType = data.GetInt("ban_type");

switch(banType) {
case BSNoComm: {
if(!BaseComm_IsClientMuted(clientId)) {
BaseComm_SetClientMute(clientId, true);
}
if(!BaseComm_IsClientGagged(clientId)){
BaseComm_SetClientGag(clientId, true);
}
ReplyToCommand(clientId, "You are currently muted/gag, it will expire automatically");
gbLog("Muted \"%L\" for an unfinished mute punishment.", clientId);
}
if(!BaseComm_IsClientGagged(clientId)){
BaseComm_SetClientGag(clientId, true);
case BSNetwork: {
KickClient(clientId, msg);
LogAction(0, clientId, "Kicked \"%L\" for a network block.", clientId);
}
case BSBanned: {
KickClient(clientId, msg);
LogAction(0, clientId, "Kicked \"%L\" for an unfinished ban.", clientId);
}
ReplyToCommand(clientId, "You are currently muted/gag, it will expire automatically");
gbLog("Muted \"%L\" for an unfinished mute punishment.", clientId);
}
case BSNetwork:
{
KickClient(clientId, msg);
LogAction(0, clientId, "Kicked \"%L\" for a network block.", clientId);
}
case BSBanned:
{
KickClient(clientId, msg);
LogAction(0, clientId, "Kicked \"%L\" for an unfinished ban.", clientId);
}
}

default: {
LogError("Invalid check response code: %d", response.Status);
}
}
}

43 changes: 40 additions & 3 deletions roles/sourcemod/files/addons/sourcemod/scripting/gbans/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public Action onCmdMod(int clientId, int argc)
return Plugin_Handled;
}


void onPingModRespReceived(HTTPResponse response, any clientId)
{
void onPingModRespReceived(HTTPResponse response, any clientId) {
if (response.Status != HTTPStatus_OK) {
LogError("Invalid report response code: %d", response.Status);

Expand All @@ -75,6 +73,45 @@ void onPingModRespReceived(HTTPResponse response, any clientId)
ReplyToCommand(clientId, "Mods have been alerted, thanks!");
}

public Action onCmdSeed(int clientId, int argc) {

ReplyToCommand(clientId, "Computering...");
char auth_id[50];
if(!GetClientAuthId(clientId, AuthId_Steam3, auth_id, sizeof auth_id, true))
{
ReplyToCommand(clientId, "Failed to get auth_id of user: %d", clientId);
return Plugin_Continue;
}

char url[1024];
makeURL("/api/sm/seed", url, sizeof url);
StrCat(url, sizeof url, "?steam_id=");
StrCat(url, sizeof url, auth_id);


HTTPRequest request = new HTTPRequest(url);
addAuthHeader(request);
request.Get(onCmdSeedReceived, clientId);

return Plugin_Handled;
}

void onCmdSeedReceived(HTTPResponse response, any clientId) {
switch (response.Status) {
case HTTPStatus_TooManyRequests: {
ReplyToCommand(clientId, "Please wait before making new seed requests (5min cooldown)");
return;
}
case HTTPStatus_OK: {
ReplyToCommand(clientId, "Mods have been alerted, thanks!");
return;
}
default: {
ReplyToCommand(clientId, "Got invalid response code :(");
return;
}
}
}

public Action onCmdHelp(int clientId, int argc)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma tabsize 4
#pragma newdecls required

#define PLUGIN_VERSION "0.7.33"
#define PLUGIN_VERSION "0.7.36"

#define MAX_SCORES 256

Expand Down
Loading
Loading