Skip to content

feat(comms): provide custom reason #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions game/addons/sourcemod/scripting/sbpp_comms.sp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ enum PeskyPanels
int g_iPeskyPanels[MAXPLAYERS + 1][PeskyPanels];

bool g_bPlayerStatus[MAXPLAYERS + 1]; // Player block check status

// Own Reason Section
bool g_bOwnReason[MAXPLAYERS + 1] = { false, ... };
int g_iTarget[MAXPLAYERS + 1] = { -1, ... };
int g_iLength[MAXPLAYERS + 1];
int g_iType[MAXPLAYERS + 1];

char g_sName[MAXPLAYERS + 1][MAX_NAME_LENGTH];

bType g_MuteType[MAXPLAYERS + 1];
Expand Down Expand Up @@ -192,12 +199,17 @@ public void OnPluginStart()
g_hServersWhiteList = new ArrayList();

CreateConVar("sourcecomms_version", PLUGIN_VERSION, _, FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY);

AddCommandListener(CommandCallback, "sm_gag");
AddCommandListener(CommandCallback, "sm_mute");
AddCommandListener(CommandCallback, "sm_silence");
AddCommandListener(CommandCallback, "sm_ungag");
AddCommandListener(CommandCallback, "sm_unmute");
AddCommandListener(CommandCallback, "sm_unsilence");

AddCommandListener(ReasonHook, "say");
AddCommandListener(ReasonHook, "say_team");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://sm.alliedmods.net/new-api/console/OnClientSayCommand
Absolute identically forward. Calls when client use say or say_team.


RegServerCmd("sc_fw_block", FWBlock, "Blocking player comms by command from sourceban web site");
RegServerCmd("sc_fw_ungag", FWUngag, "Ungagging player by command from sourceban web site");
RegServerCmd("sc_fw_unmute", FWUnmute, "Unmuting player by command from sourceban web site");
Expand Down Expand Up @@ -262,6 +274,8 @@ public void OnClientDisconnect(int client)

CloseMuteExpireTimer(client);
CloseGagExpireTimer(client);

g_bOwnReason[client] = false;
}

public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
Expand Down Expand Up @@ -680,7 +694,10 @@ public int Handle_MenuList(TopMenu menu, TopMenuAction action, TopMenuObject obj

void AdminMenu_Target(int client, int type)
{
g_bOwnReason[client] = false;

char Title[192], Option[32];

switch (type)
{
case TYPE_GAG:
Expand Down Expand Up @@ -914,6 +931,7 @@ public int MenuHandler_MenuReason(Menu menu, MenuAction action, int param1, int
int reasonIndex = StringToInt(sTemp[2]);
int lengthIndex = StringToInt(sTemp[3]);
int length;

if (lengthIndex >= 0 && lengthIndex <= iNumTimes)
length = g_iTimeMinutes[lengthIndex];
else
Expand All @@ -922,12 +940,49 @@ public int MenuHandler_MenuReason(Menu menu, MenuAction action, int param1, int
LogError("Wrong length index in menu - using default time");
}

if (StrEqual(g_sReasonKey[reasonIndex], "Other"))
{
g_bOwnReason[param1] = true;
g_iTarget[param1] = target;
g_iLength[param1] = length;
g_iType[param1] = type;

PrintToChat(param1, "%s%t", PREFIX, "Chat Reason");

return;
}

CreateBlock(param1, target, length, type, g_sReasonKey[reasonIndex]);
}
}
}
}

public Action ReasonHook(int iClient, const char[] sCommand, int iArgC)
{
if (g_bOwnReason[iClient])
{
g_bOwnReason[iClient] = false;

char sReason[512];

GetCmdArgString(sReason, sizeof sReason);

if (StrEqual(sReason, "!noreason"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On TF2, result of execution say command is located in quotation marks, so you receive string like "!noreason" (with quotes, yes)

{
PrintToChat(iClient, "%s%t", PREFIX, "Chat Reason Aborted");

return Plugin_Handled;
}

CreateBlock(iClient, g_iTarget[iClient], g_iLength[iClient], g_iType[iClient], sReason);

return Plugin_Handled;
}

return Plugin_Continue;
}

void AdminMenu_List(int client, int index)
{
char sTitle[192], sOption[32];
Expand Down
6 changes: 3 additions & 3 deletions game/addons/sourcemod/scripting/sbpp_main.sp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ bool
, requireSiteLogin = false /* Require a lastvisited from SB site */
, backupConfig = true
, enableAdmins = true
, PlayerStatus[MAXPLAYERS + 1]; /* Player ban check status */
, PlayerStatus[MAXPLAYERS + 1] /* Player ban check status */
, g_ownReasons[MAXPLAYERS + 1] = { false, ... }; /* Own Chat Reason */

int
g_BanTarget[MAXPLAYERS + 1] = { -1, ... }
, g_BanTime[MAXPLAYERS + 1] = { -1, ... }
, curLoading
, serverID = -1
, ProcessQueueTime = 5
, g_ownReasons[MAXPLAYERS + 1] = { false, ... } /* Own Chat Reason */
, CommandDisable; /* Disable of addban and unban */


Expand Down Expand Up @@ -383,7 +383,7 @@ public Action ChatHook(int client, int args)

g_ownReasons[client] = false;

if (StrEqual(reason[0], "!noreason"))
if (StrEqual(reason, "!noreason"))
{
PrintToChat(client, "%c[%cSourceBans%c]%c %t", GREEN, NAMECOLOR, GREEN, NAMECOLOR, "Chat Reason Aborted");
return Plugin_Handled;
Expand Down
31 changes: 31 additions & 0 deletions game/addons/sourcemod/translations/sbpp_comms.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1336,4 +1336,35 @@
"chi" "你不能指定惩罚时长."
"tr" "Belirtilen yasaklama süresi için yetkiniz bulunmamaktadır."
}
//---------------------------------------------------------------------------------
"Chat Reason"
{
"en" "Please type the reason for ban in chat and press enter. Type '!noreason' to abort."
"nl" "Typ alstublieft de reden voor de ban in chat and druk op enter. Typ '!noreason' om the annuleren."
"fr" "Merci d'écrire la raison du ban dans le chat. Tapez '!noreason' pour annuler."
"pl" "Proszę wpisać powód bana w czacie oraz potwierdzić przyciskiem Enter. Wpisz !noreason by anulować."
"pt" "Por favor, digite no chat o motivo para o banimento e pressione enter. Digite '!noreason' para cancelar."
"de" "Bitte schreiben Sie den Grund für den Ban in den Chat. Schreiben Sie '!noreason' um abzubrechen."
"ru" "Введите причину бана и нажмите Ввод. Введите '!noreason' для отмены бана."
"da" "Skriv venligst din grund for udelukkelsen ind i chatten og tryk enter. Skriv '!noreason' for at annullere."
"no" "Vennligst skriv din grunn for utestengelse i chaten og trykk enter. Skriv 'noreason' for og annulere."
"hu" "Írd be a chatre az indokot, majd nyomj entert. Írd '!noreason' a megszakításhoz."
"chi" "请在聊天框中填写封禁理由并提交或输入 '!noreason' 放弃操作."
"tr" "Lütfen bir sebep belirtiniz. İptal etmek için '!noreason' yazınız."
}
"Chat Reason Aborted"
{
"en" "The ban procedure has been stopped successfully."
"nl" "De ban procedure is succesvol gestopt."
"fr" "La procédure de ban a été arrêté avec succès."
"pl" "Procedura banowania została pomyślnie zatrzymana."
"pt" "O procedimento de banimento foi interrompido com sucesso."
"de" "Der Banvorgang wurde erfolgreich angehalten."
"ru" "Бан отменён."
"da" "Udelukkelses proceduren blev stoppet med success"
"no" "Utestengelses prossedyren ble stoppet vellykket."
"hu" "A ban eljárás sikeresen leállítva."
"chi" "封禁操作已成功取消."
"tr" "Yasaklama işlemi iptal edildi."
}
}