Skip to content

Commit

Permalink
Add round configuration handling to game info sync plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai committed Nov 4, 2024
1 parent 24b66ff commit f6dba7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Binary file modified addons/sourcemod/plugins/optional/l4d2_gameinfo_sync.smx
Binary file not shown.
27 changes: 22 additions & 5 deletions addons/sourcemod/scripting/l4d2_gameinfo_sync.sp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ ConVar
hConfigurationName;

JSONObject
ConfigurationCommand;
ConfigurationCommand,
RoundCommand;

HTTPRequest
ConfigurationRequest;
ConfigurationRequest,
RoundRequest;

char ConfigurationName[64];

Expand All @@ -41,10 +43,11 @@ void RoundStart_Event(Handle event, const char[] name, bool dontBroadcast)
}

Action RoundStart_Timer(Handle timer)
{
SendConfiguration();
{
SendConfiguration();
SendRound();

return Plugin_Continue;
return Plugin_Continue;
}

void SendConfiguration()
Expand All @@ -69,6 +72,20 @@ void SendConfiguration()
ConfigurationRequest.Put(ConfigurationCommand, DoNothing);
}

void SendRound()
{
if (RoundCommand == null)
RoundCommand = new JSONObject();

RoundCommand.SetInt("areTeamsFlipped", GameRules_GetProp("m_bAreTeamsFlipped"));
RoundCommand.SetInt("maxChapterProgressPoints", L4D_GetVersusMaxCompletionScore());

if (RoundRequest == null)
RoundRequest = BuildHTTPRequest("/api/game-info/round");

RoundRequest.Put(RoundCommand, DoNothing);
}

void DoNothing(HTTPResponse httpResponse, any value)
{
}
Expand Down

0 comments on commit f6dba7e

Please sign in to comment.