Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
added bonus record announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo H committed Mar 19, 2019
1 parent 7b63b14 commit a30fb69
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addons/sourcemod/scripting/surftimer/convars.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
35 changes: 34 additions & 1 deletion addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a30fb69

Please sign in to comment.