[TC] Gaming Forums
Getting specific user's location via API - Printable Version

+- [TC] Gaming Forums (https://forum.city-driving.co.uk)
+-- Forum: General Information (/forumdisplay.php?fid=1)
+--- Forum: General Discussions (/forumdisplay.php?fid=4)
+---- Forum: Developer Forum (/forumdisplay.php?fid=221)
+---- Thread: Getting specific user's location via API (/showthread.php?tid=29175)



Getting specific user's location via API - Kyle - 2018-05-16 17:44

SOLUTION: See post #10 Smile

Hi,
I'm struggling to get the location of a specific user atm. I realise that I can get the location of users, but that is for everyone in that server. Example:

Quote:GET https://api.tc-gaming.co.uk/citydriving/stats/online?key=YOUR_KEY&server=all

returns something like this:

Quote:[
{
"id": 11969,
"countryCode": "GB",
"username": "Garypants",
"nickname": "^1[TC]^7\u203aCarl\u2039",
"money": 259473,
"distance": 156889746,
"trip": 34846,
"bonus": 22,
"lastCar": "XRT",
"lastPosition": "^3Medical Centre^8",
"server": "^7One"
},
...
]

But is there a way to lookup one person, like you can with profile lookup, and get the location? If not, is there a way to use the global JSON file to get a specific user?

I am coding in C#. Hope this made sense Smile

Any help would be greatly appreciated Biggrin


RE: Getting specific user's location via API - Dan - 2018-05-16 18:29

Location as in... where they are on the server? Or physical location in which they're playing from?


RE: Getting specific user's location via API - Kyle - 2018-05-16 18:30

Sorry, I should've made this clear - the location in-game (so 'lastPosition') Smile


RE: Getting specific user's location via API - Chuck - 2018-05-17 05:17

There are some ways, but I would need to know what you intent to do with it.
i.e do you need info from players being online or even when they gone offline.


RE: Getting specific user's location via API - Zoltri - 2018-05-17 06:12

What needs done is for the local insim program to know what road name they are on so it can then be displayed on the screen


RE: Getting specific user's location via API - Adorable - 2018-05-17 08:48

(2018-05-16 18:30)Jack Wrote:  Sorry, I should've made this clear - the location in-game (so 'lastPosition') Smile

https://apidocs.tc-gaming.co.uk/citydriving-statistics-api/statistics-api.html#users-online

lastPosition field does it for everyone online, I don't think you can for someone offline


RE: Getting specific user's location via API - Kyle - 2018-05-17 16:26

(2018-05-17 05:17)Chuck Wrote:  There are some ways, but I would need to know what you intent to do with it.
i.e do you need info from players being online or even when they gone offline.

For everyone online.

(2018-05-17 08:48)Adorable Wrote:  
(2018-05-16 18:30)Jack Wrote:  Sorry, I should've made this clear - the location in-game (so 'lastPosition') Smile

https://apidocs.tc-gaming.co.uk/citydriving-statistics-api/statistics-api.html#users-online

lastPosition field does it for everyone online, I don't think you can for someone offline

I did see this, but wasn't sure if you could do it for only a single person like you can with the profile lookup. If you can't, I can probably do it other ways (e.g. jump down lines)


RE: Getting specific user's location via API - Chuck - 2018-05-17 17:23

I am wondering why you are specifically asking for the location of just one user.


RE: Getting specific user's location via API - Zoltri - 2018-05-18 07:55

Like I stated it is to display the location of the drivers location in real time. I’m aware that this can be done


RE: Getting specific user's location via API - Chuck - 2018-05-18 08:03

If it's really just about one particular user you can do it this way:
https://api.tc-gaming.co.uk/json/<lowercase username>.json


RE: Getting specific user's location via API - rip - 2018-05-18 10:03

(2018-05-18 07:55)J.Walsh Wrote:  Like I stated it is to display the location of the drivers location in real time. I’m aware that this can be done
Could be done, except the API limits you to 720 queries per hour, which would cause problems if you wan't to see the location in real time.


RE: Getting specific user's location via API - Chuck - 2018-05-18 14:12

Things u need in realtime should be provided by your own Insim anyway. I still dont know what u need the location for, as it's also very imprecise. "Autobahn North" on Kyoto covers pretty much half of the map. On a side note, why don't u simply buy a locator? It does exactly what you want Wink


RE: Getting specific user's location via API - Kyle - 2018-05-18 15:00

(2018-05-18 08:03)Chuck Wrote:  If it's really just about one particular user you can do it this way:
https://api.tc-gaming.co.uk/json/<lowercase username>.json

I completely forgot about this page. Thanks Chuck!