[Requested] /getcountry, /getinfo - gets country, city, st.
Posted: 21 May 2014, 08:09
Command requested by Leeizazombie Enjoy! I made this real fast for ya thanks!
/getcountry [player] - gets the country back to the player.
/getinfo [player] - gets the country, city, and state back to the player
Enjoy!
/getcountry [player] - gets the country back to the player.
/getinfo [player] - gets the country, city, and state back to the player
Enjoy!
- Code: Select all
//coded by tommyz_
using System;
using System.Collections.Generic;
using System.Net;
namespace MCDzienny
{
public class CmdGetCountry : Command
{
public override string name { get { return "getcountry"; } }
public override string shortcut { get { return "country"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public CmdGetCountry() { }
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
Player who = Player.Find(message);
if (who != null)
{
if (who.ip == "127.0.0.1")
{ Player.SendMessage(p, "&aThis command doesn't work with the host of the server " + GetCountry(who)); return; }
if (who == p)
{
Player.SendMessage(p, "&aYour Country is " + GetCountry(p)); return;
}
else { Player.SendMessage(p, p.PublicName + "'s &aCountry is " + GetCountry(who)); return; }
}
else { Player.SendMessage(p, message + " was not found on the server"); return; }
}
//gets the city, state and country of a user
static public string GetInfo(Player who)
{
return new WebClient().DownloadString("http://api.hostip.info/get_json.php?ip=" + who.ip);
}
//gets just the country of the user in proper string format
static public string GetCountry(Player who)
{
return new WebClient().DownloadString("http://api.hostip.info/country.php?ip=" + who.ip);
}
public override void Help(Player p)
{
Player.SendMessage(p, "/getcountry [player] - Gets the country of a player.");
}
}
public class CmdGetInfo : Command
{
public override string name { get { return "getinfo"; } }
public override string shortcut { get { return "info"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public CmdGetInfo() { }
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
Player who = Player.Find(message);
if (who != null)
{
if (who.ip == "127.0.0.1")
{ Player.SendMessage(p, "&aThis command doesn't work with the host of the server " + GetInfo(who)); return; }
if (who == p)
{
Player.SendMessage(p, "&aYour Info is " + GetInfo(p)); return;
}
else { Player.SendMessage(p, p.PublicName + "'s &aCountry is " + GetInfo(who)); return; }
}
else { Player.SendMessage(p, message + " was not found on the server"); return; }
}
//gets the city, state and country of a user
static public string GetInfo(Player who)
{
return new WebClient().DownloadString("http://api.hostip.info/get_json.php?ip=" + who.ip);
}
//gets just the country of the user in proper string format
static public string GetCountry(Player who)
{
return new WebClient().DownloadString("http://api.hostip.info/country.php?ip=" + who.ip);
}
public override void Help(Player p)
{
Player.SendMessage(p, "/getinfo [player] - Gets the country, city, and state of a player.");
Player.SendMessage(p, "Caution a little messy output due to not formatting the info, maybe in another version.");
}
}
}