mirror of
https://github.com/FAUSheppy/skillbird-sourcemod
synced 2025-12-07 15:41:36 +01:00
2020 rewrite
This commit is contained in:
44
scripting/IngameMessages.sp
Normal file
44
scripting/IngameMessages.sp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <system2>
|
||||
|
||||
#define DEFAULT_LEN 64
|
||||
#define SNAME_LEN 256
|
||||
|
||||
#define VAR_TARGET_PORT "skillbird_target_port"
|
||||
|
||||
|
||||
public void PrintHttpResponse(bool success, const char[] error, System2HTTPRequest request, System2HTTPResponse response, HTTPRequestMethod method) {
|
||||
if (success) {
|
||||
if(response.StatusCode == 204 || response.StatusCode == 200){
|
||||
char[] content = new char[response.ContentLength + 1];
|
||||
response.GetContent(content, response.ContentLength + 1);
|
||||
PrintToChatAll("%s", content);
|
||||
}else if(response.StatusCode == 404){
|
||||
PrintToChatAll("skillbird:error:player_not_in_db");
|
||||
}else{
|
||||
PrintToChatAll("skillbird:error:scheduled_downtime:database_backup");
|
||||
}
|
||||
} else {
|
||||
PrintToChatAll("skillbird:error: backend unavailiable");
|
||||
}
|
||||
}
|
||||
|
||||
public void DisplayRating(int client){
|
||||
new String:url[SNAME_LEN];
|
||||
new String:clientId[DEFAULT_LEN];
|
||||
GetClientAuthId(client, AuthId_SteamID64, clientId, DEFAULT_LEN);
|
||||
Format(url, sizeof(url), "http://localhost:%d/get-player-rating-msg?id=%s", GetConVarInt(FindConVar(VAR_TARGET_PORT)), clientId);
|
||||
System2HTTPRequest httpRequest = new System2HTTPRequest(PrintHttpResponse, url);
|
||||
httpRequest.GET();
|
||||
}
|
||||
|
||||
public Action Timer_ConnectMessage(Handle timer, int client){
|
||||
DisplayRating(client);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action CommandRating(int client, int args){
|
||||
DisplayRating(client);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
Reference in New Issue
Block a user