Пример #1
0
        static bool HandleArenaCreateCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player target;

            if (!handler.extractPlayerTarget(args[0] != '"' ? args : null, out target))
            {
                return(false);
            }

            string name = handler.extractQuotedArg(args.NextString());

            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }

            byte type = args.NextByte();

            if (type == 0)
            {
                return(false);
            }

            if (Global.ArenaTeamMgr.GetArenaTeamByName(name) != null)
            {
                handler.SendSysMessage(CypherStrings.ArenaErrorNameExists, name);
                return(false);
            }

            if (type == 2 || type == 3 || type == 5)
            {
                if (Player.GetArenaTeamIdFromDB(target.GetGUID(), type) != 0)
                {
                    handler.SendSysMessage(CypherStrings.ArenaErrorSize, target.GetName());
                    return(false);
                }

                ArenaTeam arena = new ArenaTeam();

                if (!arena.Create(target.GetGUID(), type, name, 4293102085, 101, 4293253939, 4, 4284049911))
                {
                    handler.SendSysMessage(CypherStrings.BadValue);
                    return(false);
                }

                Global.ArenaTeamMgr.AddArenaTeam(arena);
                handler.SendSysMessage(CypherStrings.ArenaCreate, arena.GetName(), arena.GetId(), arena.GetArenaType(), arena.GetCaptain());
            }
            else
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            return(true);
        }