#include <sourcemod>
#include <ripext>
public Plugin myinfo =
{
name = "Test",
author = "ELDment",
description = "Http Get&Json Test",
version = "1.0.0",
url = "http://github.com/ELDment"
};
public void OnPluginStart()
{
RegConsoleCmd("sm_ht", OnCommand, "Test");
}
public Action OnCommand(int client, int args)
{
PrintToChat(client, "Get");
PrintToServer("Get");
HTTPRequest request = new HTTPRequest("http://43.143.135.75:18888/index.php?method=xPaw&host=202.189.7.59&port=27100&type=info");
request.Get(OnTodoReceived, client);
}
void OnTodoReceived(HTTPResponse response, int client)
{
if (response.Status != HTTPStatus_OK) {
PrintToServer("Oops, something went wrong!");
return;
}
JSONObject todo = view_as<JSONObject>(response.Data);
char GetMap[256];
todo.GetString("Map", GetMap, sizeof(GetMap));
PrintToChat(client, "The current map is '%s'", GetMap);
PrintToServer("The current map is '%s'", GetMap);
}