From a30fb691121ace576134c27e26fd5ddb70171f60 Mon Sep 17 00:00:00 2001 From: Riccardo H Date: Tue, 19 Mar 2019 22:47:43 +0100 Subject: [PATCH] added bonus record announcements --- .../sourcemod/scripting/surftimer/convars.sp | 5 ++- addons/sourcemod/scripting/surftimer/misc.sp | 35 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/surftimer/convars.sp b/addons/sourcemod/scripting/surftimer/convars.sp index 6cd5377..e703579 100644 --- a/addons/sourcemod/scripting/surftimer/convars.sp +++ b/addons/sourcemod/scripting/surftimer/convars.sp @@ -90,7 +90,8 @@ ConVar g_hServerType = null; // Set server to surf or bhop mode ConVar g_hOneJumpLimit = null; // Only allows players to jump once inside a start or stage zone ConVar g_hServerID = null; // Sets the servers id for cross-server announcements ConVar g_hRecordAnnounce = null; // Enable/Disable cross-server announcements -ConVar g_hRecordAnnounceDiscord = null; // Web hook link to announce records to discord +ConVar g_hRecordAnnounceDiscord = null; // Web hook link to announce records to +ConVar g_hBonusRecordAnnounceDiscord = null; // Web hook link to announce bonus records to discord ConVar g_hReportBugsDiscord = null; // Web hook link to report bugs to discord ConVar g_hCalladminDiscord = null; // Web hook link to allow players to call admin to discord ConVar g_hSidewaysBlockKeys = null; @@ -324,6 +325,8 @@ void CreateConVars() // Discord g_hRecordAnnounceDiscord = CreateConVar("ck_announce_records_discord", "", "Web hook link to announce records to discord, keep empty to disable"); + g_hBonusRecordAnnounceDiscord = CreateConVar("ck_announce_bonus_records_discord", "", "Web hook link to announce bonus records to discord, keep empty to disable"); + g_hReportBugsDiscord = CreateConVar("ck_report_discord", "", "Web hook link to report bugs to discord, keep empty to disable"); g_hCalladminDiscord = CreateConVar("ck_calladmin_discord", "", "Web hook link to allow players to call admin to discord, keep empty to disable"); diff --git a/addons/sourcemod/scripting/surftimer/misc.sp b/addons/sourcemod/scripting/surftimer/misc.sp index b091cf7..e5da558 100644 --- a/addons/sourcemod/scripting/surftimer/misc.sp +++ b/addons/sourcemod/scripting/surftimer/misc.sp @@ -2081,6 +2081,15 @@ stock void PrintChatBonus (int client, int zGroup, int rank = 0) } + // Send Announcements + if (g_bBonusSRVRecord[client]) + { + char buffer[1024]; + GetConVarString(g_hBonusRecordAnnounceDiscord, buffer, 1024); + if (!StrEqual(buffer, "")) + sendDiscordAnnouncementBonus(szName, g_szMapName, g_szFinalTime[client], zGroup); + } + /* Start function call */ Call_StartForward(g_BonusFinishForward); @@ -4415,7 +4424,30 @@ public void sendDiscordAnnouncement(char szName[32], char szMapName[128], char s // Format The Message char szMessage[256]; - Format(szMessage, sizeof(szMessage), "```md\n# New Server Record on %s #\n\n[%s] beat the server record on < %s > with time of < %s > ]:```", g_sServerName, szName, szMapName, szTime); + Format(szMessage, sizeof(szMessage), "```md\n# New Server Record on %s #\n\n[%s] beat the server record on < %s > with a time of < %s > ]:```", g_sServerName, szName, szMapName, szTime); + + hook.SetContent(szMessage); + hook.Send(); + delete hook; +} + +public void sendDiscordAnnouncementBonus(char szName[32], char szMapName[128], char szTime[32], int zGroup) +{ + char webhook[1024]; + GetConVarString(g_hBonusRecordAnnounceDiscord, webhook, 1024); + if (StrEqual(webhook, "")) + return; + + // Send Discord Announcement + DiscordWebHook hook = new DiscordWebHook(webhook); + hook.SlackMode = true; + + hook.SetUsername("z4lab Surf Records"); + + // Format The Message + char szMessage[256]; + + Format(szMessage, sizeof(szMessage), "```md\n# New Bonus Server Record on %s #\n\n[%s] beat the bonus %i server record on < %s > with a time of < %s > ]:```", g_sServerName, szName, zGroup, szMapName, szTime); hook.SetContent(szMessage); hook.Send(); @@ -4443,6 +4475,7 @@ bool IsPlayerVip(int client, bool admin = true, bool reply = true) return true; } + public float GetStrafeSync(int client, bool sync) { // Strafe sync taken from shavit's bhop timer