Open Bluscream opened 7 years ago
I'm probably stupid but i can't seem to get this to work:
string response = String.Empty; try { using (var webClient = new System.Net.WebClient()) { response = webClient.DownloadString("http://ip-api.com/json/"+player.NetConnection.RemoteEndPoint.Address); } } catch (Exception e) { Console.WriteLine("Could not contact IP API."); } if (!string.IsNullOrWhiteSpace(response)) { IPInfo dejson = JsonConvert.DeserializeObject<IPInfo>(response); if (dejson.list != null) { if (dejson.status.Equals("success")) { string country = dejson.countryCode; Console.WriteLine("Country Code: "+country); }else { Console.WriteLine("Could not query IP infos from API."); } } }
It always throws a System.NullReferenceException: Object reference not set to an instance of an object. somewhere around that code.
System.NullReferenceException: Object reference not set to an instance of an object.
I'm probably stupid but i can't seem to get this to work:
It always throws a
System.NullReferenceException: Object reference not set to an instance of an object.
somewhere around that code.