Created
March 11, 2017 18:39
-
-
Save rumblefrog/fb6117e30b167af1e35d83ccb094aa84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma semicolon 1 | |
#define DEBUG | |
#define PLUGIN_AUTHOR "Fishy" | |
#define PLUGIN_VERSION "1.00" | |
#include <sourcemod> | |
#include <sdktools> | |
#include <smjansson> | |
#pragma newdecls required | |
public Plugin myinfo = | |
{ | |
name = "FetchPData", | |
author = PLUGIN_AUTHOR, | |
description = "Fetch player data", | |
version = PLUGIN_VERSION, | |
url = "https://keybase.io/rumblefrog" | |
}; | |
public void OnPluginStart() | |
{ | |
RegAdminCmd("sm_pdata", PData, 0, "Fetch player data"); | |
} | |
public Action PData(int client, int args) | |
{ | |
Handle jObj = json_object(); | |
char sJson[4096]; | |
for (int i = 1; i <= MaxClients; i++) | |
{ | |
if (IsClientInGame(i) && !IsFakeClient(i)) | |
{ | |
char ID[64]; | |
char Player_Name[MAX_NAME_LENGTH]; | |
GetClientAuthId(i, AuthId_SteamID64, ID, sizeof(ID)); | |
GetClientName(i, Player_Name, sizeof(Player_Name)); | |
json_object_set_new(jObj, ID, json_string(Player_Name)); | |
} | |
} | |
json_dump(jObj, sJson, sizeof(sJson)); | |
PrintToConsole(client, "%s", sJson); | |
return Plugin_Handled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment