Skip to content

Commit

Permalink
Update l4d2_playstats_sync.sp to clear cache after syncing file
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai committed Jul 18, 2024
1 parent 177edd6 commit 2dfb948
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Binary file modified addons/sourcemod/plugins/optional/l4d2_playstats_sync.smx
Binary file not shown.
20 changes: 20 additions & 0 deletions addons/sourcemod/scripting/l4d2_playstats_sync.sp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ void SyncFileResponse(HTTPResponse httpResponse, any value)
if (httpResponse.Status != HTTPStatus_OK)
return;

ClearCache();

JSONObject response = view_as<JSONObject>(httpResponse.Data);

bool mustBeDeleted = response.GetBool("mustBeDeleted");
Expand All @@ -162,6 +164,24 @@ void SyncFileResponse(HTTPResponse httpResponse, any value)
DeleteFile(filePath);
}

public void ClearCache()
{
new String:web_url[100];
GetConVarString(cvar_playstats_web_url, web_url, sizeof(web_url));

char endpoint[128];
FormatEx(endpoint, sizeof(endpoint), "%s/api/cache/clear", web_url);

HTTPRequest request = new HTTPRequest(endpoint);
JSONObject command = new JSONObject();

request.Post(command, ClearCacheResponse);
}

void ClearCacheResponse(HTTPResponse httpResponse, any value)
{
}

public void ShowRanking(int client)
{
new String:web_url[100];
Expand Down

0 comments on commit 2dfb948

Please sign in to comment.