IsOnline() public static method

Determines if the user is online
public static IsOnline ( string name ) : bool
name string The player's name
return bool
Exemplo n.º 1
0
        /// <summary>
        /// Changes the given players rank
        /// </summary>
        /// <param name="name">The name of the player</param>
        /// <param name="g">The players new rank</param>
        public static void ChangeRank(string name, GroupEnum g)
        {
            if (Server.operators.Contains(name))
            {
                Server.operators.Remove(name);
            }
            if (Server.moderators.Contains(name))
            {
                Server.moderators.Remove(name);
            }
            if (Server.advbuilders.Contains(name))
            {
                Server.advbuilders.Remove(name);
            }
            if (Server.builders.Contains(name))
            {
                Server.builders.Remove(name);
            }

            // Debug Message

            switch (g)
            {
            case GroupEnum.Banned:
                Server.banned.Add(name);
                break;

            case GroupEnum.Guest:
                break;

            case GroupEnum.Builder:
                Server.builders.Add(name);
                break;

            case GroupEnum.AdvBuilder:
                Server.advbuilders.Add(name);
                break;

            case GroupEnum.Moderator:
                Server.moderators.Add(name);
                break;

            case GroupEnum.Operator:
                Server.operators.Add(name);
                break;
            }

            if (Player.IsOnline(name))
            {
                Player target = Player.Find(name);
                Player.GlobalDie(target, false);
                Player.GlobalSpawn(target, target.pos[0], target.pos[1], target.pos[2], target.rot[0], target.rot[1], false);
            }
        }
Exemplo n.º 2
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p);
            }
            else
            {
                bool stealth = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Logger.Log("Stealth Ban Atempted");
                }

                // Ensure the name is valid
                if (Player.ValidName(message))
                {
                    // Ensure the player isn't banned already
                    if (Player.GetRank(message) != GroupEnum.Banned)
                    {
                        if (p.Rank > Player.GetRank(message))
                        {
                            // Check to see if the player is online
                            // Send appropriate message based on status and stealth option
                            if (Player.IsOnline(message))
                            {
                                if (stealth)
                                {
                                }
                                else
                                {
                                    Player.GlobalMessage("[Server]:" + p.color + p.name + "&e has banned " + message);
                                }
                            }
                            else
                            {
                                Player.GlobalMessage("[Server]:" + p.color + p.name + "&e has banned " + message + "(offline)");
                            }

                            // Actually get around to banning the player
                            Player.Ban(message);

                            IRCBot.Say(message + " was banned");
                        }
                        else
                        {
                            p.SendMessage("You can't ban someone of equal or higher rank!");
                        }
                    }
                    else
                    {
                        p.SendMessage(message + " is already banned.");
                    }
                }
                else
                {
                    p.SendMessage("Invalid name \"" + message + "\".");
                }
            }
        }