MCLawl.PlayerBot.ValidName C# (CSharp) Method

ValidName() public static method

public static ValidName ( string name ) : bool
name string
return bool
        public static bool ValidName(string name)
        {
            string allowedchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_";
            foreach (char ch in name) { if (allowedchars.IndexOf(ch) == -1) { return false; } } return true;
        }

Usage Example

Beispiel #1
0
 public override void Use(Player p, string message)
 {
     if (message == "")
     {
         Help(p); return;
     }
     if (!PlayerBot.ValidName(message))
     {
         Player.SendMessage(p, "bot name " + message + " not valid!"); return;
     }
     PlayerBot.playerbots.Add(new PlayerBot(message, p.level, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0));
     //who.SendMessage("You were summoned by " + p.color + p.name + "&e.");
 }