Raised This Month: $90 Target: $400
 22% 

Get JSON response in Chat /Help/CS:GO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 03-13-2019 , 18:58   Get JSON response in Chat /Help/CS:GO
Reply With Quote #1

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.

Last edited by iskenderkebab33; 03-13-2019 at 18:59.
iskenderkebab33 is offline
DarkDeviL
SourceMod Moderator
Previously known as:
arne1288
Join Date: Apr 2012
Old 03-14-2019 , 11:56   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #2

Quote:
Originally Posted by iskenderkebab33 View Post
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.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread]

Last edited by DarkDeviL; 03-14-2019 at 11:57.
DarkDeviL is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 03-14-2019 , 13:54   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #3

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.
iskenderkebab33 is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 03-14-2019 , 14:59   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #4

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

Last edited by Kailo; 03-14-2019 at 14:59.
Kailo is offline
Mathias.
Veteran Member
Previously known as:
Mathias The Vegan
Join Date: Aug 2010
Location: Canada is my city
Old 03-15-2019 , 17:13   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #5

Quote:
Originally Posted by Kailo View Post
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.

Last edited by Mathias.; 03-15-2019 at 17:14.
Mathias. is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 03-17-2019 , 07:55   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #6

Quote:
Originally Posted by Mathias. View Post
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.
Kailo is offline
Mathias.
Veteran Member
Previously known as:
Mathias The Vegan
Join Date: Aug 2010
Location: Canada is my city
Old 03-17-2019 , 14:47   Re: Get JSON response in Chat /Help/CS:GO
Reply With Quote #7

Quote:
Originally Posted by Kailo View Post
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.
Mathias. is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:57.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode