[Requested] /getcountry, /getinfo - gets country, city, st.

[Requested] /getcountry, /getinfo - gets country, city, st.

Postby tommyz_ » 21 May 2014, 08:09

Command requested by Leeizazombie Enjoy! I made this real fast for ya thanks! :D
/getcountry [player] - gets the country back to the player.
/getinfo [player] - gets the country, city, and state back to the player :o :twisted:
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.");
        }
    }
}
tommyz_
 
Posts: 12
Joined: 17 May 2014, 02:46

Re: [Requested] /getcountry, /getinfo - gets country, city,

Postby Leeizazombie » 23 May 2014, 16:39

Looks fairly similar to something I've already made :lol:, I got better after making requests, but thanks for helping <ok>

My command:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.Xml;

namespace MCDzienny
{
    public class CmdIPlocation : Command
    {
        public override string name { get { return "country"; } }
        public override string shortcut { get { return "area"; } }
        public override string type { get { return "info"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }
            string two = message.Split(' ')[0];
            Player who = Player.Find(two);
            if (who == null)
            {
                Player.SendMessage(p, "Player is not online.");
                return;
            }
            string userIP = who.ip;
            string apiKey = "5d3d0cdbc95df34b9db4a7b4fb754e738bce4ac914ca8909ace8d3ece39cee3b";
            string url = "http://api.ipinfodb.com/v3/ip-country/?key=" + apiKey + "&ip=" + userIP;
            WebRequest request = WebRequest.Create(url);
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                Encoding encoding = response.CharacterSet != null ? Encoding.GetEncoding(response.CharacterSet) : null;

                using (var sr = encoding != null ? new StreamReader(response.GetResponseStream(), encoding) :
                                                   new StreamReader(response.GetResponseStream(), true))
                {
                    var response2 = sr.ReadToEnd();
                    var parts = response2.Split(';');

                    if (parts.Length != 5)
                    {
                        throw new Exception();
                    }

                    string okError = parts[0];
                    string message_ = parts[1];
                    string ip = parts[2];
                    string code = parts[3];
                    string country = parts[4];
                    if (country == "-" || country == null || country == "")
                    {
                        return;
                    }
                    if (who.PublicName == "LeeIzaZombie" || who.PublicName == "LeeIzaZombie+" || who.PublicName == "Leebyrne115@")
                    {
                        Player.SendMessage(p, "LeeIzaZombie lives in: %bThe Moon.");
                        return;
                    }
                    else
                    {
                        if (code == "AD") { country = "Andorra"; }
                        if (code == "AE") { country = "United Arab Emirates"; }
                        if (code == "AF") { country = "Afghanistan"; }
                        if (code == "AG") { country = "Antigua and Barbuda"; }
                        if (code == "AI") { country = "Anguilla"; }
                        if (code == "AL") { country = "Albania"; }
                        if (code == "AM") { country = "Armenia"; }
                        if (code == "AN") { country = "Netherlands Antilles"; }
                        if (code == "AO") { country = "Angola"; }
                        if (code == "AQ") { country = "Antartica"; }
                        if (code == "AR") { country = "Argentina"; }
                        if (code == "AS") { country = "American Samoa"; }
                        if (code == "AT") { country = "Austria"; }
                        if (code == "AU") { country = "Austrailia"; }
                        if (code == "AW") { country = "Aruba"; }
                        if (code == "AX") { country = "Aland"; }
                        if (code == "AZ") { country = "Azerbaijan"; }
                        if (code == "BA") { country = "Bosnia and Herzegovina"; }
                        if (code == "BB") { country = "Barbados"; }
                        if (code == "BD") { country = "Bangladesh"; }
                        if (code == "BE") { country = "Belgium"; }
                        if (code == "BF") { country = "Burkina Faso"; }
                        if (code == "BG") { country = "Bulgaria"; }
                        if (code == "BH") { country = "Bahrain"; }
                        if (code == "BI") { country = "Burundi"; }
                        if (code == "BJ") { country = "Benin"; }
                        if (code == "BM") { country = "Bermuda"; }
                        if (code == "BN") { country = "Brunei Darussalam"; }
                        if (code == "BO") { country = "Bolivia"; }
                        if (code == "BR") { country = "Brazil"; }
                        if (code == "BS") { country = "Bahamas"; }
                        if (code == "BT") { country = "Bhutan"; }
                        if (code == "BV") { country = "Bouvet Island"; }
                        if (code == "BW") { country = "Botswana"; }
                        if (code == "BY") { country = "Belarus"; }
                        if (code == "BZ") { country = "Belize"; }
                        if (code == "CA") { country = "Canada"; }
                        if (code == "CC") { country = "Cocos"; }
                        if (code == "CD") { country = "Congo"; }
                        if (code == "CF") { country = "Central African Republic"; }
                        if (code == "CH") { country = "Switzerland"; }
                        if (code == "CI") { country = "Cote D'ivoire"; }
                        if (code == "CK") { country = "Cook Islands"; }
                        if (code == "CL") { country = "Chile"; }
                        if (code == "CM") { country = "Cameroon"; }
                        if (code == "CN") { country = "China"; }
                        if (code == "CO") { country = "Colombia"; }
                        if (code == "CR") { country = "Costa Rica"; }
                        if (code == "CU") { country = "Cuba"; }
                        if (code == "CV") { country = "Cape Verde"; }
                        if (code == "CW") { country = "Curacao"; }
                        if (code == "CX") { country = "Christmas Island"; }
                        if (code == "CY") { country = "Cyprus"; }
                        if (code == "CZ") { country = "Czech Republic"; }
                        if (code == "DE") { country = "Germany"; }
                        if (code == "DJ") { country = "Djibouti"; }
                        if (code == "DK") { country = "Denmark"; }
                        if (code == "DM") { country = "Dominica"; }
                        if (code == "DO") { country = "Dominican Republic"; }
                        if (code == "DZ") { country = "Algeria"; }
                        if (code == "EC") { country = "Ecuador"; }
                        if (code == "EE") { country = "Estonia"; }
                        if (code == "EG") { country = "Egypt"; }
                        if (code == "EH") { country = "Western Sahara"; }
                        if (code == "ER") { country = "Eritrea"; }
                        if (code == "ES") { country = "Spain"; }
                        if (code == "ET") { country = "Ethiopia"; }
                        if (code == "FI") { country = "Finland"; }
                        if (code == "FJ") { country = "Fiji"; }
                        if (code == "FK") { country = "Falkland Islands"; }
                        if (code == "FM") { country = "Micronesia"; }
                        if (code == "FO") { country = "Faroe Islands"; }
                        if (code == "FR") { country = "France"; }
                        if (code == "GA") { country = "Gabon"; }
                        if (code == "GB") { country = "United Kingdom"; }
                        if (code == "GD") { country = "Grenada"; }
                        if (code == "GE") { country = "Georgia"; }
                        if (code == "GF") { country = "French Guiana"; }
                        if (code == "GG") { country = "Guernsey"; }
                        if (code == "GH") { country = "Ghana"; }
                        if (code == "GI") { country = "Gibraltar"; }
                        if (code == "GL") { country = "Greenland"; }
                        if (code == "GM") { country = "Gambia"; }
                        if (code == "GN") { country = "Guinea"; }
                        if (code == "GP") { country = "Guadeloupe"; }
                        if (code == "GQ") { country = "Equatorial Guinea"; }
                        if (code == "GR") { country = "Greece"; }
                        if (code == "GS") { country = "South Georgie and the South Sandwich Islands"; }
                        if (code == "GT") { country = "Guatemala"; }
                        if (code == "GU") { country = "Guam"; }
                        if (code == "GW") { country = "Guinea-Bissau"; }
                        if (code == "GY") { country = "Guyana"; }
                        if (code == "HK") { country = "Hong Kong"; }
                        if (code == "HM") { country = "Heard Island and McDonald Islands"; }
                        if (code == "HN") { country = "Honduras"; }
                        if (code == "HR") { country = "Croatia"; }
                        if (code == "HT") { country = "Haiti"; }
                        if (code == "HU") { country = "Hungary"; }
                        if (code == "ID") { country = "Indonesia"; }
                        if (code == "IE") { country = "Ireland"; }
                        if (code == "IL") { country = "Israel"; }
                        if (code == "IM") { country = "Isle of Man"; }
                        if (code == "IN") { country = "India"; }
                        if (code == "IO") { country = "British India Ocean Territory"; }
                        if (code == "IQ") { country = "Iraq"; }
                        if (code == "IR") { country = "Iran"; }
                        if (code == "IS") { country = "Iceland"; }
                        if (code == "IT") { country = "Italy"; }
                        if (code == "JE") { country = "Jersey"; }
                        if (code == "JM") { country = "Jamaica"; }
                        if (code == "JO") { country = "Jordan"; }
                        if (code == "JP") { country = "Japan"; }
                        if (code == "KE") { country = "Kenya"; }
                        if (code == "KG") { country = "Kyrgyzstan"; }
                        if (code == "KH") { country = "Cambodia"; }
                        if (code == "KI") { country = "Kiribati"; }
                        if (code == "KM") { country = "Comoros"; }
                        if (code == "KN") { country = "Saint Kitts and Nevis"; }
                        if (code == "KP") { country = "Korea"; }
                        if (code == "KR") { country = "Korea"; }
                        if (code == "KW") { country = "Kuwait"; }
                        if (code == "KY") { country = "Cayman Islands"; }
                        if (code == "KZ") { country = "Kazakhstan"; }
                        if (code == "LA") { country = "Lao"; }
                        if (code == "LB") { country = "Lebanon"; }
                        if (code == "LC") { country = "Saint Lucia"; }
                        if (code == "LI") { country = "Liechtenstein"; }
                        if (code == "LK") { country = "Sri Lanka"; }
                        if (code == "LR") { country = "Liberia"; }
                        if (code == "LS") { country = "Lesotho"; }
                        if (code == "LT") { country = "Lithuania"; }
                        if (code == "LU") { country = "Luxembourg"; }
                        if (code == "LV") { country = "Latvia"; }
                        if (code == "LY") { country = "Libya"; }
                        if (code == "MA") { country = "Morocco"; }
                        if (code == "MC") { country = "Monaco"; }
                        if (code == "MD") { country = "Moldova"; }
                        if (code == "ME") { country = "Montenegro"; }
                        if (code == "MF") { country = "Saint Martin"; }
                        if (code == "MG") { country = "Madagascar"; }
                        if (code == "MH") { country = "Marshall Islands"; }
                        if (code == "MK") { country = "Macedonia"; }
                        if (code == "ML") { country = "Mali"; }
                        if (code == "MM") { country = "Myanmar"; }
                        if (code == "MN") { country = "Mongolia"; }
                        if (code == "MO") { country = "Macoa"; }
                        if (code == "MP") { country = "Nothern Mariana Islands"; }
                        if (code == "MQ") { country = "Martinique"; }
                        if (code == "MR") { country = "Maurintania"; }
                        if (code == "MS") { country = "Montserrat"; }
                        if (code == "MT") { country = "Malta"; }
                        if (code == "MU") { country = "Mauritius"; }
                        if (code == "MV") { country = "Maldives"; }
                        if (code == "MW") { country = "Malawi"; }
                        if (code == "MX") { country = "Mexico"; }
                        if (code == "MY") { country = "Malaysia"; }
                        if (code == "MZ") { country = "Mozambique"; }
                        if (code == "NA") { country = "Namibia"; }
                        if (code == "NC") { country = "New Caledonia"; }
                        if (code == "NE") { country = "Niger"; }
                        if (code == "NF") { country = "Norfolk Island"; }
                        if (code == "NG") { country = "Nigeria"; }
                        if (code == "NI") { country = "Nicaragua"; }
                        if (code == "NL") { country = "Netherlands"; }
                        if (code == "NO") { country = "Norway"; }
                        if (code == "NP") { country = "Nepal"; }
                        if (code == "NR") { country = "Nauru"; }
                        if (code == "NU") { country = "Niue"; }
                        if (code == "NZ") { country = "New Zealand"; }
                        if (code == "OM") { country = "Oman"; }
                        if (code == "PA") { country = "Panama"; }
                        if (code == "PE") { country = "Peru"; }
                        if (code == "PF") { country = "French Polynesia"; }
                        if (code == "PG") { country = "Papua New Guinea"; }
                        if (code == "PH") { country = "Philippines"; }
                        if (code == "PK") { country = "Pakistan"; }
                        if (code == "PL") { country = "Poland"; }
                        if (code == "PM") { country = "Saint Pierre and Miquelon"; }
                        if (code == "PN") { country = "Pitcairn"; }
                        if (code == "PR") { country = "Puerto Rico"; }
                        if (code == "PS") { country = "Palestine"; }
                        if (code == "PT") { country = "Portugal"; }
                        if (code == "PW") { country = "Palau"; }
                        if (code == "PY") { country = "Paraguay"; }
                        if (code == "QA") { country = "Qatar"; }
                        if (code == "RE") { country = "Reunion"; }
                        if (code == "RO") { country = "Romania"; }
                        if (code == "RS") { country = "Serbia"; }
                        if (code == "RU") { country = "Russian Federation"; }
                        if (code == "RW") { country = "Rwanda"; }
                        if (code == "SA") { country = "Saudi Arabia"; }
                        if (code == "SB") { country = "Solomon Islands"; }
                        if (code == "SC") { country = "Seychelles"; }
                        if (code == "SD") { country = "Sudan"; }
                        if (code == "SE") { country = "Sweden"; }
                        if (code == "SG") { country = "Singapore"; }
                        if (code == "SH") { country = "Saint Helena"; }
                        if (code == "SI") { country = "Slovenia"; }
                        if (code == "SJ") { country = "Svalbard"; }
                        if (code == "SK") { country = "Slovakia"; }
                        if (code == "SL") { country = "Sierra Leone"; }
                        if (code == "SM") { country = "San Marino"; }
                        if (code == "SN") { country = "Senegal"; }
                        if (code == "SO") { country = "Somalia"; }
                        if (code == "SR") { country = "Suriname"; }
                        if (code == "SS") { country = "South Sudan"; }
                        if (code == "ST") { country = "Sao Tome and Principe"; }
                        if (code == "SV") { country = "El Salvador"; }
                        if (code == "SX") { country = "Sint Maarten"; }
                        if (code == "SY") { country = "Syrian Arab Republic"; }
                        if (code == "SZ") { country = "Swaziland"; }
                        if (code == "TC") { country = "Turks and Caicos Islands"; }
                        if (code == "TD") { country = "Chad"; }
                        if (code == "TF") { country = "French Southern Territories"; }
                        if (code == "TG") { country = "Togo"; }
                        if (code == "TH") { country = "Thailand"; }
                        if (code == "TJ") { country = "Tajikistan"; }
                        if (code == "TK") { country = "Tokelau"; }
                        if (code == "TL") { country = "Timor-Leste"; }
                        if (code == "TM") { country = "Turkmenistan"; }
                        if (code == "TN") { country = "Tunisia"; }
                        if (code == "TO") { country = "Tonga"; }
                        if (code == "TR") { country = "Turkey"; }
                        if (code == "TT") { country = "Trinidad and Tobago"; }
                        if (code == "TV") { country = "Tuvalu"; }
                        if (code == "TW") { country = "Taiwan"; }
                        if (code == "TZ") { country = "Tanzania"; }
                        if (code == "UA") { country = "Ukraine"; }
                        if (code == "UG") { country = "Uganda"; }
                        if (code == "UM") { country = "Inited States Minor Outlying Islands"; }
                        if (code == "US") { country = "United States"; }
                        if (code == "UY") { country = "Uruguay"; }
                        if (code == "UZ") { country = "Uzbekistan"; }
                        if (code == "VA") { country = "Holy See"; }
                        if (code == "VC") { country = "Saint Vincent and the Grenadines"; }
                        if (code == "VE") { country = "Venezuela"; }
                        if (code == "VG") { country = "Virgin Islands, British"; }
                        if (code == "VI") { country = "Virgin Islands, U.S."; }
                        if (code == "VN") { country = "Viet Nam"; }
                        if (code == "VU") { country = "Vanuatu"; }
                        if (code == "WF") { country = "Wallis and Futuna"; }
                        if (code == "WS") { country = "Samoa"; }
                        if (code == "YE") { country = "Yemen"; }
                        if (code == "YT") { country = "Mayotte"; }
                        if (code == "ZA") { country = "South Africa"; }
                        if (code == "") { country = "Zambia"; }
                        if (code == "") { country = "Zimbabwe"; }


                        Player.SendMessage(p, who.color + who.PublicName + Server.DefaultColor + " lives in:%a " + country);
                    }
                }
            }
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/country (player) -- Show the players country.");
        }
    }
}

Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: [Requested] /getcountry, /getinfo - gets country, city,

Postby tommyz_ » 27 May 2014, 02:12

Welcome! and Nice job!
tommyz_
 
Posts: 12
Joined: 17 May 2014, 02:46


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 3 guests

cron