From 9f2c866a1f444a4f41e72160d252b45d8f506384 Mon Sep 17 00:00:00 2001 From: rumblefrog Date: Wed, 25 Sep 2019 00:51:18 -0400 Subject: [PATCH 1/4] refactor majority of the front facing messages to translations --- game/addons/sourcemod/scripting/sbpp_main.sp | 109 +++++++++--------- .../translations/sbpp_main.phrases.txt | 58 ++++++++++ 2 files changed, 113 insertions(+), 54 deletions(-) diff --git a/game/addons/sourcemod/scripting/sbpp_main.sp b/game/addons/sourcemod/scripting/sbpp_main.sp index 7b5b3f905..487ca6b65 100644 --- a/game/addons/sourcemod/scripting/sbpp_main.sp +++ b/game/addons/sourcemod/scripting/sbpp_main.sp @@ -1105,7 +1105,8 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D { if (dataPack == INVALID_HANDLE) { - LogToFile(logFile, "Ban Failed: %s", error); + LogToFile(logFile, "%t: %s", "Ban Fail", error); + return; } @@ -1161,20 +1162,20 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D { if (Reason[0] == '\0') { - ShowActivityEx(admin, Prefix, "%t", "Permabanned player", Name); + ShowActivityEx(admin, Prefix, "%t", "Permabanned Player", Name); } else { - ShowActivityEx(admin, Prefix, "%t", "Permabanned player reason", Name, Reason); + ShowActivityEx(admin, Prefix, "%t", "Permabanned Player Reason", Name, Reason); } } else { if (Reason[0] == '\0') { - ShowActivityEx(admin, Prefix, "%t", "Banned player", Name, time); + ShowActivityEx(admin, Prefix, "%t", "Banned Player", Name, time); } else { - ShowActivityEx(admin, Prefix, "%t", "Banned player reason", Name, time, Reason); + ShowActivityEx(admin, Prefix, "%t", "Banned Player Reason", Name, time, Reason); } } - LogAction(admin, client, "\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", admin, client, time, Reason); + LogAction(admin, client, "%t", "Ban Log", admin, client, time, Reason); if (PlayerDataPack[admin] != INVALID_HANDLE) { @@ -1187,7 +1188,7 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D { char length[32]; if(time == 0) - FormatEx(length, sizeof(length), "permament"); + FormatEx(length, sizeof(length), "%t", "Permanent"); else FormatEx(length, sizeof(length), "%d %s", time, time == 1 ? "minute" : "minutes"); KickClient(client, "%t\n\n%t", "Banned Check Site", WebsiteAddress, "Kick Reason", admin, Reason, length); @@ -1213,17 +1214,19 @@ public void SelectBanIpCallback(Database db, DBResultSet results, const char[] e { LogToFile(logFile, "Ban IP Select Query Failed: %s", error); if (admin && IsClientInGame(admin)) - PrintToChat(admin, "%sFailed to ban %s.", Prefix, ip); + PrintToChat(admin, "%s%t", Prefix, "Ban Fail"); else - PrintToServer("%sFailed to ban %s.", Prefix, ip); + PrintToServer("%s%t", Prefix, "Ban Fail"); + return; } if (results.RowCount) { if (admin && IsClientInGame(admin)) - PrintToChat(admin, "%s%s is already banned.", Prefix, ip); + PrintToChat(admin, "%s%t", Prefix, "Already Banned", ip); else - PrintToServer("%s%s is already banned.", Prefix, ip); + PrintToServer("%s%t", Prefix, "Already Banned", ip); + return; } if (serverID == -1) @@ -1271,17 +1274,12 @@ public void InsertBanIpCallback(Database db, DBResultSet results, const char[] e return; } - LogAction(admin, - -1, - "\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", - admin, - minutes, - arg, - reason); + LogAction(admin, -1, "%t", "Ban Added", admin, minutes, arg, reason); + if (admin && IsClientInGame(admin)) - PrintToChat(admin, "%s%s successfully banned", Prefix, arg); + PrintToChat(admin, "%s%t", Prefix, "Ban Success Name", arg); else - PrintToServer("%s%s successfully banned", Prefix, arg); + PrintToServer("%s%t", Prefix, "Ban Success Name", arg); } public void SelectUnbanCallback(Database db, DBResultSet results, const char[] error, DataPack dataPack) @@ -1314,12 +1312,12 @@ public void SelectUnbanCallback(Database db, DBResultSet results, const char[] e if (!results.RowCount) { if (admin && IsClientInGame(admin)) - { - PrintToChat(admin, "%sNo active bans found for that filter", Prefix); - } else { - PrintToServer("%sNo active bans found for that filter", Prefix); - } + PrintToChat(admin, "%s%t", Prefix, "No Active Ban"); + else + PrintToServer("%s%t", Prefix, "No Active Ban"); + delete dataPack; + return; } @@ -1368,13 +1366,12 @@ public void InsertUnbanCallback(Database db, DBResultSet results, const char[] e return; } - LogAction(admin, -1, "\"%L\" removed ban (filter \"%s\") (reason \"%s\")", admin, arg, reason); + LogAction(admin, -1, "%t", "Ban Removed", admin, arg, reason); + if (admin && IsClientInGame(admin)) - { - PrintToChat(admin, "%s%s successfully unbanned", Prefix, arg); - } else { - PrintToServer("%s%s successfully unbanned", Prefix, arg); - } + PrintToChat(admin, "%s%t", Prefix, "Unban Success Name", arg); + else + PrintToServer("%s%t", Prefix, "Unban Success Name", arg); } public void SelectAddbanCallback(Database db, DBResultSet results, const char[] error, DataPack dataPack) @@ -1395,18 +1392,21 @@ public void SelectAddbanCallback(Database db, DBResultSet results, const char[] if (results == null) { LogToFile(logFile, "Add Ban Select Query Failed: %s", error); + if (admin && IsClientInGame(admin)) - PrintToChat(admin, "%sFailed to ban %s.", Prefix, authid); + PrintToChat(admin, "%s%t", Prefix, "Ban Fail"); else - PrintToServer("%sFailed to ban %s.", Prefix, authid); + PrintToServer("%s%t", Prefix, "Ban Fail"); + return; } if (results.RowCount) { if (admin && IsClientInGame(admin)) - PrintToChat(admin, "%s%s is already banned.", Prefix, authid); + PrintToChat(admin, "%s%t", Prefix, "Already Banned", authid); else - PrintToServer("%s%s is already banned.", Prefix, authid); + PrintToServer("%s%t", Prefix, "Already Banned", authid); + return; } if (serverID == -1) @@ -1449,19 +1449,12 @@ public void InsertAddbanCallback(Database db, DBResultSet results, const char[] return; } - LogAction(admin, - -1, - "\"%L\" added ban (minutes \"%i\") (id \"%s\") (reason \"%s\")", - admin, - minutes, - authid, - reason); + LogAction(admin, -1, "%t", "Ban Added", admin, minutes, authid, reason); + if (admin && IsClientInGame(admin)) - { - PrintToChat(admin, "%s%s successfully banned", Prefix, authid); - } else { - PrintToServer("%s%s successfully banned", Prefix, authid); - } + PrintToChat(admin, "%s%t", Prefix, "Ban Success Name", authid); + else + PrintToServer("%s%t", Prefix, "Ban Success Name", authid); } // ProcessQueueCallback is called as the result of selecting all the rows from the queue table @@ -2625,13 +2618,16 @@ stock void PrepareBan(int client, int target, int time, char[] reason, int size) #if defined DEBUG LogToFile(logFile, "PrepareBan()"); #endif + if (!target || !IsClientInGame(target)) return; + char authid[64], name[32], bannedSite[512]; + if (!GetClientAuthId(target, AuthId_Steam2, authid, sizeof(authid))) return; - GetClientName(target, name, sizeof(name)); + GetClientName(target, name, sizeof(name)); if (CreateBan(client, target, time, reason)) { @@ -2639,26 +2635,31 @@ stock void PrepareBan(int client, int target, int time, char[] reason, int size) { if (reason[0] == '\0') { - ShowActivity(client, "%t", "Permabanned player", name); + ShowActivity(client, "%t", "Permabanned Player", name); } else { - ShowActivity(client, "%t", "Permabanned player reason", name, reason); + ShowActivity(client, "%t", "Permabanned Player Reason", name, reason); } } else { if (reason[0] == '\0') { - ShowActivity(client, "%t", "Banned player", name, time); + ShowActivity(client, "%t", "Banned Player", name, time); } else { - ShowActivity(client, "%t", "Banned player reason", name, time, reason); + ShowActivity(client, "%t", "Banned Player Reason", name, time, reason); } } - LogAction(client, target, "\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, target, time, reason); + + LogAction(client, target, "%t", "Ban Log", client, target, time, reason); + char length[32]; + if(time == 0) - FormatEx(length, sizeof(length), "permament"); + FormatEx(length, sizeof(length), "%t", "Permanent"); else FormatEx(length, sizeof(length), "%d %s", time, time == 1 ? "minute" : "minutes"); + if (time > 5 || time == 0) time = 5; + Format(bannedSite, sizeof(bannedSite), "%t\n\n%t", "Banned Check Site", WebsiteAddress, "Kick Reason", client, reason, length);//temp BanClient(target, time, BANFLAG_AUTO, bannedSite, bannedSite, "sm_ban", client); } diff --git a/game/addons/sourcemod/translations/sbpp_main.phrases.txt b/game/addons/sourcemod/translations/sbpp_main.phrases.txt index e91a1f0f9..82ea96b8b 100644 --- a/game/addons/sourcemod/translations/sbpp_main.phrases.txt +++ b/game/addons/sourcemod/translations/sbpp_main.phrases.txt @@ -178,4 +178,62 @@ "de" "Administrator: {1}\nGrund: {2}\nDauer: {3}" "tr" "Yönetici: {1}\nSebep: {2}\nSüre: {3}" } + "Permabanned Player" + { + "#format" "{1:s}" + "en" "Permanently banned {1}" + } + "Permabanned Player Reason" + { + "#format" "{1:s},{2:s}" + "en" "Permanently banned {1}. Reason: {2}" + } + "Banned Player" + { + "#format" "{1:s},{2:d}" + "en" "Banned {1} for {2} minutes" + } + "Banned Player Reason" + { + "#format" "{1:s},{2:d},{3:s}" + "en" "Banned {1} for {2} minutes. Reason: {3}" + } + "Permanent" + { + "en" "Permanent" + } + "Ban Log" + { + "#format" "{1:L},{2:L},{3:d},{4:s}" + "en" "\"{1}\" banned \"{2}\" (minutes: {3}) (reason: {4}) + } + "Ban Added" + { + "#format" "{1:L},{2:d},{3:s},{4:s}" + "en" "\"{1}\" added ban (minutes: {2}) (id/ip: {3}) (reason: {4})" + } + "Ban Success Name" + { + "#format" "{1:s}" + "en" "Successfully banned {1}" + } + "Unban Success Name" + { + "#format" "{1:s}" + "en" "Successfully unbanned {1}" + } + "Already Banned" + { + "#format" "{1:s}" + "en" "{1} is already banned" + } + "Ban Removed" + { + "#format" "{1:L},{2:s},{3:s}" + "en" "\"{1}\" removed ban (filter: {2}) (reason: {3})" + } + "No Active Ban" + { + "en" "No active ban found" + } } From c67de00ff5211e93329a5eb0459a5aa6556d8621 Mon Sep 17 00:00:00 2001 From: rumblefrog Date: Wed, 25 Sep 2019 00:59:56 -0400 Subject: [PATCH 2/4] chore(ignore): add vscode to gitignore --- .gitignore | 56 +++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index db32e00a4..4f684c5d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,33 @@ -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + .DS_Store .AppleDouble .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -48,6 +49,9 @@ Temporary Items # SourceBans++ /web/config.php /web/cache/*.php -/web/cache/*.tmp -/web/cache/sessions/sess_* +/web/cache/*.tmp +/web/cache/sessions/sess_* *.smx + +# VSCode +.vscode From 743810c417ef8c6427d00afbbffe29d0096645d0 Mon Sep 17 00:00:00 2001 From: rumblefrog Date: Wed, 25 Sep 2019 08:29:11 -0400 Subject: [PATCH 3/4] translations: time units --- game/addons/sourcemod/scripting/sbpp_main.sp | 9 +++++---- .../sourcemod/translations/sbpp_main.phrases.txt | 12 ++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/game/addons/sourcemod/scripting/sbpp_main.sp b/game/addons/sourcemod/scripting/sbpp_main.sp index 487ca6b65..f3e4f4243 100644 --- a/game/addons/sourcemod/scripting/sbpp_main.sp +++ b/game/addons/sourcemod/scripting/sbpp_main.sp @@ -1188,9 +1188,10 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D { char length[32]; if(time == 0) - FormatEx(length, sizeof(length), "%t", "Permanent"); + FormatEx(length, sizeof(length), "%t", "permanent"); else - FormatEx(length, sizeof(length), "%d %s", time, time == 1 ? "minute" : "minutes"); + FormatEx(length, sizeof(length), "%d %t", time, time == 1 ? "minute" : "minutes"); + KickClient(client, "%t\n\n%t", "Banned Check Site", WebsiteAddress, "Kick Reason", admin, Reason, length); } } @@ -2653,9 +2654,9 @@ stock void PrepareBan(int client, int target, int time, char[] reason, int size) char length[32]; if(time == 0) - FormatEx(length, sizeof(length), "%t", "Permanent"); + FormatEx(length, sizeof(length), "%t", "permanent"); else - FormatEx(length, sizeof(length), "%d %s", time, time == 1 ? "minute" : "minutes"); + FormatEx(length, sizeof(length), "%d %t", time, time == 1 ? "minute" : "minutes"); if (time > 5 || time == 0) time = 5; diff --git a/game/addons/sourcemod/translations/sbpp_main.phrases.txt b/game/addons/sourcemod/translations/sbpp_main.phrases.txt index 82ea96b8b..3a29e196c 100644 --- a/game/addons/sourcemod/translations/sbpp_main.phrases.txt +++ b/game/addons/sourcemod/translations/sbpp_main.phrases.txt @@ -198,9 +198,17 @@ "#format" "{1:s},{2:d},{3:s}" "en" "Banned {1} for {2} minutes. Reason: {3}" } - "Permanent" + "permanent" { - "en" "Permanent" + "en" "permanent" + } + "minute" + { + "en" "minute" + } + "minutes" + { + "en" "minutes" } "Ban Log" { From 60d103513a2ba536501c6029f98a02310ade0d56 Mon Sep 17 00:00:00 2001 From: rumblefrog Date: Wed, 25 Sep 2019 12:47:12 -0400 Subject: [PATCH 4/4] pass client to T format specifier --- game/addons/sourcemod/scripting/sbpp_main.sp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/game/addons/sourcemod/scripting/sbpp_main.sp b/game/addons/sourcemod/scripting/sbpp_main.sp index f3e4f4243..63ea88e35 100644 --- a/game/addons/sourcemod/scripting/sbpp_main.sp +++ b/game/addons/sourcemod/scripting/sbpp_main.sp @@ -1188,9 +1188,9 @@ public void VerifyInsert(Database db, DBResultSet results, const char[] error, D { char length[32]; if(time == 0) - FormatEx(length, sizeof(length), "%t", "permanent"); + FormatEx(length, sizeof(length), "%T", "permanent", client); else - FormatEx(length, sizeof(length), "%d %t", time, time == 1 ? "minute" : "minutes"); + FormatEx(length, sizeof(length), "%d %T", time, time == 1 ? "minute" : "minutes", client); KickClient(client, "%t\n\n%t", "Banned Check Site", WebsiteAddress, "Kick Reason", admin, Reason, length); } @@ -2654,9 +2654,9 @@ stock void PrepareBan(int client, int target, int time, char[] reason, int size) char length[32]; if(time == 0) - FormatEx(length, sizeof(length), "%t", "permanent"); + FormatEx(length, sizeof(length), "%T", "permanent", client); else - FormatEx(length, sizeof(length), "%d %t", time, time == 1 ? "minute" : "minutes"); + FormatEx(length, sizeof(length), "%d %t", time, time == 1 ? "minute" : "minutes", client); if (time > 5 || time == 0) time = 5;