AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Get JSON response in Chat /Help/CS:GO (https://forums.alliedmods.net/showthread.php?t=314922)

iskenderkebab33 03-13-2019 18:58

Get JSON response in Chat /Help/CS:GO
 
Hello, i am want to get JSON response in CS:GO Chat with *REST in Pawn - Communicate with JSON REST APIs* (i don't know how i can do this)

url = https://api.steampowered.com/ISteamU...XX&format=json

example respone: {"response":{"players":[{"steamid":"000","communityvisibilitystate":0 ,"profilestate":0,"personaname":"Name","lastl ogoff":000,"profileurl":"URL","avatar":"URL", "avatarmedium":"URL","avatarfull":"URL","pers onastate":0,"primaryclanid":"000","timecreate d":000,"personastateflags":0}]}}

i want to get user "steamid" after Connect and !me in Chat / PrintToChat.

Can someone help me pls, thanks.

DarkDeviL 03-14-2019 11:56

Re: Get JSON response in Chat /Help/CS:GO
 
Quote:

Originally Posted by iskenderkebab33 (Post 2643179)
i want to get user "steamid" after Connect and !me in Chat / PrintToChat.

You're complicating things much more than necessary, by using the Steam API for that.

Just use GetClientAuthId:

PHP Code:

char SteamID[32];
if (
GetClientAuthId(clientAuthId_Steam64SteamIDsizeof(SteamID))) {
  
PrintToChat(client"Hi %N (%s)"clientSteamID);


Which would print something like "Hi John (765611......)", for your player John.

iskenderkebab33 03-14-2019 13:54

Re: Get JSON response in Chat /Help/CS:GO
 
thx, but i need to get a API JSON response the steamid was a example, i know i can do it with Sourcemod but need it through the Steam API.

Kailo 03-14-2019 14:59

Re: Get JSON response in Chat /Help/CS:GO
 
Need to test.
PHP Code:

JSONObject object_root JSONObject.FromString(str);
JSONObject object_response view_as<JSONObject>(object_root.Get("response"));
JSONArray array_players view_as<JSONArray>(object_response.Get("players"));
JSONObject object_player view_as<JSONObject>(array_players.Get(0));
object_player.GetString("steamid"steamidsizeof(steamid));
delete object_player;
delete array_players;
delete object_response;
delete object_root


Mathias. 03-15-2019 17:13

Re: Get JSON response in Chat /Help/CS:GO
 
Quote:

Originally Posted by Kailo (Post 2643313)
Need to test.
PHP Code:

JSONObject object_root JSONObject.FromString(str);
JSONObject object_response view_as<JSONObject>(object_root.Get("response"));
JSONArray array_players view_as<JSONArray>(object_response.Get("players"));
JSONObject object_player view_as<JSONObject>(array_players.Get(0));
object_player.GetString("steamid"steamidsizeof(steamid));
delete object_player;
delete array_players;
delete object_response;
delete object_root


this will required the extension https://forums.alliedmods.net/showthread.php?t=184604 if I recall.
the include file will give you an error, you have to replace all "in" parameters with something else.

Also you might want to look into something more modern https://forums.alliedmods.net/showthread.php?t=298024, I haven't tested it yet but it looks pretty good.

Kailo 03-17-2019 07:55

Re: Get JSON response in Chat /Help/CS:GO
 
Quote:

Originally Posted by Mathias. (Post 2643499)
this will required the extension https://forums.alliedmods.net/showthread.php?t=184604 if I recall.
the include file will give you an error, you have to replace all "in" parameters with something else.

Also you might want to look into something more modern https://forums.alliedmods.net/showthread.php?t=298024, I haven't tested it yet but it looks pretty good.

Mathias, you are worng. I used JSON implementation linked in first post of this thread - "REST in Pawn". Page have link to "JSON natives". I used them.

Mathias. 03-17-2019 14:47

Re: Get JSON response in Chat /Help/CS:GO
 
Quote:

Originally Posted by Kailo (Post 2643752)
Mathias, you are worng. I used JSON implementation linked in first post of this thread - "REST in Pawn". Page have link to "JSON natives". I used them.

Oh sorry I didn't even notice it.


All times are GMT -4. The time now is 14:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.