Skip to content

Commit

Permalink
feat: add better debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Mar 15, 2023
1 parent 0bdd512 commit 242472f
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions scripting/SurfTimer-discord.sp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ char g_szProfileUrl[256];

bool g_bIsSurfTimerEnabled = false;
bool g_bIsChallengeEnabled = false;
bool g_bDebugging = false;

enum WaitingFor
{
Expand Down Expand Up @@ -390,12 +389,11 @@ public void SendBugReport(int iClient, char[] szText)

hook.AddEmbed(embed);
hook.Execute(webhook, OnWebHookExecuted, iClient);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
delete hook;

CPrintToChat(iClient, "{blue}[SurfTimer-Discord] %t", "BugReport Sent");
Expand Down Expand Up @@ -470,12 +468,11 @@ public void SendCallAdmin(int iClient, char[] szText)
}

hook.AddEmbed(embed);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
hook.Execute(webhook, OnWebHookExecuted, iClient);
delete hook;

Expand Down Expand Up @@ -585,12 +582,11 @@ public void mapchallenge_OnNewChallenge(int client, char szMapName[32], int styl

hook.AddEmbed(embed);
hook.Execute(webhook, OnWebHookExecuted, client);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
delete hook;
}

Expand Down Expand Up @@ -719,12 +715,11 @@ public void mapchallenge_OnChallengeEnd(int client, char szMapName[32], int styl

hook.AddEmbed(embed);
hook.Execute(webhook, OnWebHookExecuted , client);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
delete hook;
}

Expand Down Expand Up @@ -863,12 +858,11 @@ stock void sendDiscordAnnouncement(int client, int style, char[] szTime, char[]

hook.AddEmbed(embed);
hook.Execute(webhook, OnWebHookExecuted, client);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
delete hook;
}
else
Expand Down Expand Up @@ -898,12 +892,11 @@ stock void sendDiscordAnnouncement(int client, int style, char[] szTime, char[]
}
hook.SetContent(szMessage);
hook.Execute(webhook, OnWebHookExecuted, client);
if (g_bDebugging)
{
#if defined DEBUG
char szDebugOutput[10000];
hook.ToString(szDebugOutput, sizeof szDebugOutput);
PrintToServer(szDebugOutput);
}
#endif
delete hook;
}
}
Expand Down Expand Up @@ -995,14 +988,13 @@ stock bool IsValidClient(int iClient, bool bNoBots = true)

public void OnWebHookExecuted(HTTPResponse response, int client)
{
if (g_bDebugging)
{
#if defined DEBUG
PrintToServer("Processed client n°%d's webhook, status %d", client, response.Status);
if (response.Status != HTTPStatus_NoContent)
{
PrintToServer("An error has occured while sending the webhook.");
return;
}
PrintToServer("The webhook has been sent successfuly.");
}
#endif
}

0 comments on commit 242472f

Please sign in to comment.