Ejemplo n.º 1
0
        static bool HandleInstanceGetBossState(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string param1      = args.NextString();
            string param2      = args.NextString();
            uint   encounterId = 0;
            Player player      = null;

            // Character name must be provided when using this from console.
            if (string.IsNullOrEmpty(param1) || (string.IsNullOrEmpty(param2) && handler.GetSession() == null))
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);
                return(false);
            }

            if (string.IsNullOrEmpty(param2))
            {
                player = handler.GetSession().GetPlayer();
            }
            else
            {
                if (ObjectManager.NormalizePlayerName(ref param2))
                {
                    player = Global.ObjAccessor.FindPlayerByName(param2);
                }
            }

            if (!player)
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            InstanceMap map = player.GetMap().ToInstanceMap();

            if (map == null)
            {
                handler.SendSysMessage(CypherStrings.NotDungeon);
                return(false);
            }

            if (map.GetInstanceScript() == null)
            {
                handler.SendSysMessage(CypherStrings.NoInstanceData);
                return(false);
            }

            encounterId = uint.Parse(param1);

            if (encounterId > map.GetInstanceScript().GetEncounterCount())
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            EncounterState state = map.GetInstanceScript().GetBossState(encounterId);

            handler.SendSysMessage(CypherStrings.CommandInstGetBossState, encounterId, state);
            return(true);
        }
Ejemplo n.º 2
0
 static bool HandleServerForceRestartCommand(StringArguments args, CommandHandler handler)
 {
     return(ShutdownServer(args, handler, ShutdownMask.Force | ShutdownMask.Restart, ShutdownExitCode.Restart));
 }
Ejemplo n.º 3
0
 static bool HandleServerForceShutDownCommand(StringArguments args, CommandHandler handler)
 {
     return(ShutdownServer(args, handler, ShutdownMask.Force, ShutdownExitCode.Shutdown));
 }
Ejemplo n.º 4
0
            static bool HandleGameObjectSetStateCommand(StringArguments args, CommandHandler handler)
            {
                // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
                string id = handler.ExtractKeyFromLink(args, "Hgameobject");

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

                if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0)
                {
                    return(false);
                }

                GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow);

                if (!obj)
                {
                    handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow);
                    return(false);
                }

                string type = args.NextString();

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

                if (!int.TryParse(type, out int objectType))
                {
                    return(false);
                }

                if (objectType < 0)
                {
                    if (objectType == -1)
                    {
                        obj.SendGameObjectDespawn();
                    }
                    else if (objectType == -2)
                    {
                        return(false);
                    }
                    return(true);
                }

                string state = args.NextString();

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

                if (!uint.TryParse(state, out uint objectState))
                {
                    return(false);
                }

                switch (objectType)
                {
                case 0:
                    obj.SetGoState((GameObjectState)objectState);
                    break;

                case 1:
                    obj.SetGoType((GameObjectTypes)objectState);
                    break;

                case 2:
                    obj.SetGoArtKit((byte)objectState);
                    break;

                case 3:
                    obj.SetGoAnimProgress(objectState);
                    break;

                case 4:
                    obj.SendCustomAnim(objectState);
                    break;

                case 5:
                    if (objectState < 0 || objectState > (uint)GameObjectDestructibleState.Rebuilding)
                    {
                        return(false);
                    }

                    obj.SetDestructibleState((GameObjectDestructibleState)objectState);
                    break;

                default:
                    break;
                }

                handler.SendSysMessage("Set gobject type {0} state {1}", objectType, objectState);
                return(true);
            }
Ejemplo n.º 5
0
 static bool Corpses(StringArguments args, CommandHandler handler)
 {
     Global.WorldMgr.RemoveOldCorpses();
     return(true);
 }
Ejemplo n.º 6
0
        static bool HandleGameObjectTargetCommand(StringArguments args, CommandHandler handler)
        {
            Player    player = handler.GetSession().GetPlayer();
            SQLResult result;
            var       activeEventsList = Global.GameEventMgr.GetActiveEventList();

            if (!args.Empty())
            {
                // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
                string idStr = handler.ExtractKeyFromLink(args, "Hgameobject_entry");
                if (string.IsNullOrEmpty(idStr))
                {
                    return(false);
                }

                if (!uint.TryParse(idStr, out uint objectId) || objectId != 0)
                {
                    result = DB.World.Query("SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - '{0}', 2) + POW(position_y - '{1}', 2) + POW(position_z - '{2}', 2)) AS order_ FROM gameobject WHERE map = '{3}' AND id = '{4}' ORDER BY order_ ASC LIMIT 1",
                                            player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId);
                }
                else
                {
                    result = DB.World.Query(
                        "SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ " +
                        "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {3} AND name LIKE CONCAT('%%', '{4}', '%%') ORDER BY order_ ASC LIMIT 1",
                        player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), player.GetMapId(), objectId);
                }
            }
            else
            {
                StringBuilder eventFilter = new StringBuilder();
                eventFilter.Append(" AND (eventEntry IS NULL ");
                bool initString = true;

                foreach (var entry in activeEventsList)
                {
                    if (initString)
                    {
                        eventFilter.Append("OR eventEntry IN (" + entry);
                        initString = false;
                    }
                    else
                    {
                        eventFilter.Append(',' + entry);
                    }
                }

                if (!initString)
                {
                    eventFilter.Append("))");
                }
                else
                {
                    eventFilter.Append(')');
                }

                result = DB.World.Query("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, " +
                                        "(POW(position_x - {0}, 2) + POW(position_y - {1}, 2) + POW(position_z - {2}, 2)) AS order_ FROM gameobject " +
                                        "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{3}' {4} ORDER BY order_ ASC LIMIT 10",
                                        handler.GetSession().GetPlayer().GetPositionX(), handler.GetSession().GetPlayer().GetPositionY(), handler.GetSession().GetPlayer().GetPositionZ(),
                                        handler.GetSession().GetPlayer().GetMapId(), eventFilter.ToString());
            }

            if (result.IsEmpty())
            {
                handler.SendSysMessage(CypherStrings.CommandTargetobjnotfound);
                return(true);
            }

            bool   found = false;
            float  x, y, z, o;
            ulong  guidLow;
            uint   id, phaseId, phaseGroup;
            ushort mapId;
            uint   poolId;

            do
            {
                guidLow    = result.Read <ulong>(0);
                id         = result.Read <uint>(1);
                x          = result.Read <float>(2);
                y          = result.Read <float>(3);
                z          = result.Read <float>(4);
                o          = result.Read <float>(5);
                mapId      = result.Read <ushort>(6);
                phaseId    = result.Read <uint>(7);
                phaseGroup = result.Read <uint>(8);
                poolId     = Global.PoolMgr.IsPartOfAPool <GameObject>(guidLow);
                if (poolId == 0 || Global.PoolMgr.IsSpawnedObject <GameObject>(guidLow))
                {
                    found = true;
                }
            } while (result.NextRow() && !found);

            if (!found)
            {
                handler.SendSysMessage(CypherStrings.GameobjectNotExist, id);
                return(false);
            }

            GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(id);

            if (objectInfo == null)
            {
                handler.SendSysMessage(CypherStrings.GameobjectNotExist, id);
                return(false);
            }

            GameObject target             = handler.GetObjectFromPlayerMapByDbGuid(guidLow);

            handler.SendSysMessage(CypherStrings.GameobjectDetail, guidLow, objectInfo.name, guidLow, id, x, y, z, mapId, o, phaseId, phaseGroup);

            if (target)
            {
                int curRespawnDelay = (int)(target.GetRespawnTimeEx() - Time.UnixTime);
                if (curRespawnDelay < 0)
                {
                    curRespawnDelay = 0;
                }

                string curRespawnDelayStr = Time.secsToTimeString((uint)curRespawnDelay, true);
                string defRespawnDelayStr = Time.secsToTimeString(target.GetRespawnDelay(), true);

                handler.SendSysMessage(CypherStrings.CommandRawpawntimes, defRespawnDelayStr, curRespawnDelayStr);
            }
            return(true);
        }
Ejemplo n.º 7
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            uint            entry     = 0;
            GameObjectTypes type      = 0;
            uint            displayId = 0;
            uint            lootId    = 0;

            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.ExtractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            if (param1.Equals("guid"))
            {
                string cValue = handler.ExtractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out ulong guidLow))
                {
                    return(false);
                }

                GameObjectData data = Global.ObjectMgr.GetGOData(guidLow);
                if (data == null)
                {
                    return(false);
                }
                entry = data.id;
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                return(false);
            }

            type      = gameObjectInfo.type;
            displayId = gameObjectInfo.displayId;
            string name = gameObjectInfo.name;

            lootId = gameObjectInfo.GetLootId();

            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            if (addon != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags);
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }
Ejemplo n.º 8
0
 static bool HandleModifyTalentCommand(StringArguments args, CommandHandler handler)
 {
     return(false);
 }
Ejemplo n.º 9
0
        static bool HandleModifyMoneyCommand(StringArguments args, CommandHandler handler)
        {
            Player target = handler.GetSelectedPlayerOrSelf();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.NoCharSelected);
                return(false);
            }

            // check online security
            if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
            {
                return(false);
            }

            long  moneyToAdd  = args.NextInt64();
            ulong targetMoney = target.GetMoney();

            if (moneyToAdd < 0)
            {
                long newmoney = (long)targetMoney + moneyToAdd;

                Log.outDebug(LogFilter.ChatSystem, Global.ObjectMgr.GetCypherString(CypherStrings.CurrentMoney), targetMoney, moneyToAdd, newmoney);
                if (newmoney <= 0)
                {
                    handler.SendSysMessage(CypherStrings.YouTakeAllMoney, handler.GetNameLink(target));
                    if (handler.NeedReportToTarget(target))
                    {
                        target.SendSysMessage(CypherStrings.YoursAllMoneyGone, handler.GetNameLink());
                    }

                    target.SetMoney(0);
                }
                else
                {
                    ulong moneyToAddMsg = (ulong)(moneyToAdd * -1);
                    if (newmoney > (long)PlayerConst.MaxMoneyAmount)
                    {
                        newmoney = (long)PlayerConst.MaxMoneyAmount;
                    }

                    handler.SendSysMessage(CypherStrings.YouTakeMoney, moneyToAddMsg, handler.GetNameLink(target));
                    if (handler.NeedReportToTarget(target))
                    {
                        target.SendSysMessage(CypherStrings.YoursMoneyTaken, handler.GetNameLink(), moneyToAddMsg);
                    }
                    target.SetMoney((ulong)newmoney);
                }
            }
            else
            {
                handler.SendSysMessage(CypherStrings.YouGiveMoney, moneyToAdd, handler.GetNameLink(target));
                if (handler.NeedReportToTarget(target))
                {
                    target.SendSysMessage(CypherStrings.YoursMoneyGiven, handler.GetNameLink(), moneyToAdd);
                }

                if ((ulong)moneyToAdd >= PlayerConst.MaxMoneyAmount)
                {
                    moneyToAdd = Convert.ToInt64(PlayerConst.MaxMoneyAmount);
                }

                moneyToAdd = (long)Math.Min((ulong)moneyToAdd, (PlayerConst.MaxMoneyAmount - targetMoney));

                target.ModifyMoney(moneyToAdd);
            }

            Log.outDebug(LogFilter.ChatSystem, Global.ObjectMgr.GetCypherString(CypherStrings.NewMoney), targetMoney, moneyToAdd, target.GetMoney());
            return(true);
        }
Ejemplo n.º 10
0
        static bool HandleAccountCreateCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // Parse the command line arguments
            string accountName = args.NextString();
            string password    = args.NextString();

            if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            if (!accountName.Contains('@'))
            {
                handler.SendSysMessage(CypherStrings.AccountInvalidBnetName);
                return(false);
            }

            if (!bool.TryParse(args.NextString(), out bool createGameAccount))
            {
                createGameAccount = true;
            }

            string gameAccountName;

            switch (Global.BNetAccountMgr.CreateBattlenetAccount(accountName, password, createGameAccount, out gameAccountName))
            {
            case AccountOpResult.Ok:
                if (createGameAccount)
                {
                    handler.SendSysMessage(CypherStrings.AccountCreatedBnetWithGame, accountName, gameAccountName);
                }
                else
                {
                    handler.SendSysMessage(CypherStrings.AccountCreated, accountName);
                }

                if (handler.GetSession() != null)
                {
                    Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] ({3}) created Battle.net account {4}{5}{6}",
                                handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(), handler.GetSession().GetPlayer().GetName(),
                                handler.GetSession().GetPlayer().GetGUID().ToString(), accountName, createGameAccount ? " with game account " : "", createGameAccount ? gameAccountName : "");
                }
                break;

            case AccountOpResult.NameTooLong:
                handler.SendSysMessage(CypherStrings.AccountNameTooLong);
                return(false);

            case AccountOpResult.PassTooLong:
                handler.SendSysMessage(CypherStrings.AccountPassTooLong);
                return(false);

            case AccountOpResult.NameAlreadyExist:
                handler.SendSysMessage(CypherStrings.AccountAlreadyExist);
                return(false);

            default:
                break;
            }

            return(true);
        }
Ejemplo n.º 11
0
        static bool HandleModifySpellCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            byte spellflatid = args.NextByte();

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

            byte op = args.NextByte();

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

            ushort val = args.NextUInt16();

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

            if (!ushort.TryParse(args.NextString(), out ushort mark))
            {
                mark = 65535;
            }

            Player target = handler.GetSelectedPlayerOrSelf();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.NoCharSelected);
                return(false);
            }

            // check online security
            if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
            {
                return(false);
            }

            handler.SendSysMessage(CypherStrings.YouChangeSpellflatid, spellflatid, val, mark, handler.GetNameLink(target));
            if (handler.NeedReportToTarget(target))
            {
                target.SendSysMessage(CypherStrings.YoursSpellflatidChanged, handler.GetNameLink(), spellflatid, val, mark);
            }

            SetSpellModifier  packet   = new SetSpellModifier(ServerOpcodes.SetFlatSpellModifier);
            SpellModifierInfo spellMod = new SpellModifierInfo();

            spellMod.ModIndex = op;
            SpellModifierData modData;

            modData.ClassIndex    = spellflatid;
            modData.ModifierValue = val;
            spellMod.ModifierData.Add(modData);
            packet.Modifiers.Add(spellMod);
            target.SendPacket(packet);

            return(true);
        }
Ejemplo n.º 12
0
 static bool HandleLearnAllMyPetTalentsCommand(StringArguments args, CommandHandler handler)
 {
     return(true);
 }
Ejemplo n.º 13
0
 static bool HandleLearnAllMyClassCommand(StringArguments args, CommandHandler handler)
 {
     HandleLearnAllMySpellsCommand(args, handler);
     HandleLearnAllMyTalentsCommand(args, handler);
     return(true);
 }
Ejemplo n.º 14
0
            static bool HandleLearnAllRecipesCommand(StringArguments args, CommandHandler handler)
            {
                //  Learns all recipes of specified profession and sets skill to max
                //  Example: .learn all_recipes enchanting

                Player target = handler.GetSelectedPlayer();

                if (!target)
                {
                    handler.SendSysMessage(CypherStrings.PlayerNotFound);
                    return(false);
                }

                if (args.Empty())
                {
                    return(false);
                }

                // converting string that we try to find to lower case
                string namePart = args.NextString().ToLower();

                string name    = "";
                uint   skillId = 0;

                foreach (var skillInfo in CliDB.SkillLineStorage.Values)
                {
                    if ((skillInfo.CategoryID != SkillCategory.Profession &&
                         skillInfo.CategoryID != SkillCategory.Secondary) ||
                        skillInfo.CanLink == 0)                            // only prof with recipes have set
                    {
                        continue;
                    }

                    Locale locale = handler.GetSessionDbcLocale();
                    name = skillInfo.DisplayName[locale];
                    if (string.IsNullOrEmpty(name))
                    {
                        continue;
                    }

                    if (!name.Like(namePart))
                    {
                        locale = 0;
                        for (; locale < Locale.Total; ++locale)
                        {
                            if (locale == handler.GetSessionDbcLocale())
                            {
                                continue;
                            }

                            name = skillInfo.DisplayName[locale];
                            if (name.IsEmpty())
                            {
                                continue;
                            }

                            if (name.Like(namePart))
                            {
                                break;
                            }
                        }
                    }

                    if (locale < Locale.Total)
                    {
                        skillId = skillInfo.Id;
                        break;
                    }
                }

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

                HandleLearnSkillRecipesHelper(target, skillId);

                ushort maxLevel = target.GetPureMaxSkillValue((SkillType)skillId);

                target.SetSkill(skillId, target.GetSkillStep((SkillType)skillId), maxLevel, maxLevel);
                handler.SendSysMessage(CypherStrings.CommandLearnAllRecipes, name);
                return(true);
            }
Ejemplo n.º 15
0
        static bool HandleGoZoneXYCommand(CommandHandler handler, StringArguments args)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player player = handler.GetSession().GetPlayer();

            if (!float.TryParse(args.NextString(), out float x))
            {
                return(false);
            }

            if (!float.TryParse(args.NextString(), out float y))
            {
                return(false);
            }

            // prevent accept wrong numeric args
            if (x == 0.0f || y == 0.0f)
            {
                return(false);
            }

            string idStr = handler.ExtractKeyFromLink(args, "Harea");       // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r

            if (!uint.TryParse(idStr, out uint areaId))
            {
                areaId = player.GetZoneId();
            }

            AreaTableRecord areaEntry = CliDB.AreaTableStorage.LookupByKey(areaId);

            if (x < 0 || x > 100 || y < 0 || y > 100 || areaEntry == null)
            {
                handler.SendSysMessage(CypherStrings.InvalidZoneCoord, x, y, areaId);
                return(false);
            }

            // update to parent zone if exist (client map show only zones without parents)
            AreaTableRecord zoneEntry = areaEntry.ParentAreaID != 0 ? CliDB.AreaTableStorage.LookupByKey(areaEntry.ParentAreaID) : areaEntry;

            Cypher.Assert(zoneEntry != null);

            Map map = Global.MapMgr.CreateBaseMap(zoneEntry.ContinentID);

            if (map.Instanceable())
            {
                handler.SendSysMessage(CypherStrings.InvalidZoneMap, areaId, areaEntry.AreaName[handler.GetSessionDbcLocale()], map.GetId(), map.GetMapName());
                return(false);
            }

            x /= 100.0f;
            y /= 100.0f;

            Global.DB2Mgr.Zone2MapCoordinates(areaEntry.ParentAreaID != 0 ? areaEntry.ParentAreaID : areaId, ref x, ref y);

            if (!GridDefines.IsValidMapCoord(zoneEntry.ContinentID, x, y))
            {
                handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, zoneEntry.ContinentID);
                return(false);
            }

            // stop flight if need
            if (player.IsInFlight())
            {
                player.FinishTaxiFlight();
            }
            else
            {
                player.SaveRecallPosition(); // save only in non-flight case
            }
            float z = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));

            player.TeleportTo(zoneEntry.ContinentID, x, y, z, player.GetOrientation());
            return(true);
        }
Ejemplo n.º 16
0
        static bool HandleModifyRepCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player target = handler.GetSelectedPlayerOrSelf();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            // check online security
            if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
            {
                return(false);
            }

            string factionTxt = handler.ExtractKeyFromLink(args, "Hfaction");

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

            if (!uint.TryParse(factionTxt, out uint factionId))
            {
                return(false);
            }

            string rankTxt = args.NextString();

            if (factionId == 0 || !int.TryParse(rankTxt, out int amount))
            {
                return(false);
            }

            if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber())
            {
                string rankStr = rankTxt.ToLower();

                int r = 0;
                amount = -42000;
                for (; r < (int)ReputationRank.Max; ++r)
                {
                    string rank = handler.GetCypherString(ReputationMgr.ReputationRankStrIndex[r]);
                    if (string.IsNullOrEmpty(rank))
                    {
                        continue;
                    }

                    if (rank.Equals(rankStr))
                    {
                        string deltaTxt = args.NextString();
                        if (!string.IsNullOrEmpty(deltaTxt))
                        {
                            if (!int.TryParse(deltaTxt, out int delta) || delta < 0 || (delta > ReputationMgr.PointsInRank[r] - 1))
                            {
                                handler.SendSysMessage(CypherStrings.CommandFactionDelta, (ReputationMgr.PointsInRank[r] - 1));
                                return(false);
                            }
                            amount += delta;
                        }
                        break;
                    }
                    amount += ReputationMgr.PointsInRank[r];
                }
                if (r >= (int)ReputationRank.Max)
                {
                    handler.SendSysMessage(CypherStrings.CommandFactionInvparam, rankTxt);
                    return(false);
                }
            }

            FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId);

            if (factionEntry == null)
            {
                handler.SendSysMessage(CypherStrings.CommandFactionUnknown, factionId);
                return(false);
            }

            if (factionEntry.ReputationIndex < 0)
            {
                handler.SendSysMessage(CypherStrings.CommandFactionNorepError, factionEntry.Name[handler.GetSessionDbcLocale()], factionId);
                return(false);
            }

            target.GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false);
            target.GetReputationMgr().SendState(target.GetReputationMgr().GetState(factionEntry));
            handler.SendSysMessage(CypherStrings.CommandModifyRep, factionEntry.Name[handler.GetSessionDbcLocale()], factionId, handler.GetNameLink(target), target.GetReputationMgr().GetReputation(factionEntry));

            return(true);
        }
Ejemplo n.º 17
0
        static bool HandleGameObjectMoveCommand(StringArguments args, CommandHandler handler)
        {
            // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
            string id = handler.ExtractKeyFromLink(args, "Hgameobject");

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

            if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0)
            {
                return(false);
            }

            GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow);

            if (!obj)
            {
                handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow);
                return(false);
            }

            string toX = args.NextString();
            string toY = args.NextString();
            string toZ = args.NextString();

            float x, y, z;

            if (string.IsNullOrEmpty(toX))
            {
                Player player = handler.GetSession().GetPlayer();
                player.GetPosition(out x, out y, out z);
            }
            else
            {
                if (!float.TryParse(toX, out x))
                {
                    return(false);
                }

                if (!float.TryParse(toY, out y))
                {
                    return(false);
                }

                if (!float.TryParse(toZ, out z))
                {
                    return(false);
                }

                if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z))
                {
                    handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, obj.GetMapId());
                    return(false);
                }
            }

            Map map = obj.GetMap();

            obj.Relocate(x, y, z, obj.GetOrientation());
            obj.SaveToDB();

            // Generate a completely new spawn with new guid
            // client caches recently deleted objects and brings them back to life
            // when CreateObject block for this guid is received again
            // however it entirely skips parsing that block and only uses already known location
            obj.Delete();

            obj = GameObject.CreateGameObjectFromDB(guidLow, map);
            if (!obj)
            {
                return(false);
            }

            handler.SendSysMessage(CypherStrings.CommandMoveobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString());

            return(true);
        }
Ejemplo n.º 18
0
        static bool HandleModifyGenderCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player target = handler.GetSelectedPlayerOrSelf();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            PlayerInfo info = Global.ObjectMgr.GetPlayerInfo(target.GetRace(), target.GetClass());

            if (info == null)
            {
                return(false);
            }

            string gender_str = args.NextString();
            Gender gender;

            if (gender_str == "male")            // MALE
            {
                if (target.GetGender() == Gender.Male)
                {
                    return(true);
                }

                gender = Gender.Male;
            }
            else if (gender_str == "female")    // FEMALE
            {
                if (target.GetGender() == Gender.Female)
                {
                    return(true);
                }

                gender = Gender.Female;
            }
            else
            {
                handler.SendSysMessage(CypherStrings.MustMaleOrFemale);
                return(false);
            }

            // Set gender
            target.SetGender(gender);
            target.SetNativeSex(gender);

            // Change display ID
            target.InitDisplayIds();

            handler.SendSysMessage(CypherStrings.YouChangeGender, handler.GetNameLink(target), gender);

            if (handler.NeedReportToTarget(target))
            {
                target.SendSysMessage(CypherStrings.YourGenderChanged, gender, handler.GetNameLink());
            }

            return(true);
        }
Ejemplo n.º 19
0
        static bool HandleGameObjectTurnCommand(StringArguments args, CommandHandler handler)
        {
            // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
            string id = handler.ExtractKeyFromLink(args, "Hgameobject");

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

            if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0)
            {
                return(false);
            }

            GameObject obj = handler.GetObjectFromPlayerMapByDbGuid(guidLow);

            if (!obj)
            {
                handler.SendSysMessage(CypherStrings.CommandObjnotfound, guidLow);
                return(false);
            }

            string orientation = args.NextString();
            float  oz = 0.0f, oy = 0.0f, ox = 0.0f;

            if (!orientation.IsEmpty())
            {
                if (!float.TryParse(orientation, out oz))
                {
                    return(false);
                }

                orientation = args.NextString();
                if (!orientation.IsEmpty())
                {
                    if (!float.TryParse(orientation, out oy))
                    {
                        return(false);
                    }

                    orientation = args.NextString();
                    if (!orientation.IsEmpty())
                    {
                        if (!float.TryParse(orientation, out ox))
                        {
                            return(false);
                        }
                    }
                }
            }
            else
            {
                Player player = handler.GetPlayer();
                oz = player.GetOrientation();
            }

            Map map = obj.GetMap();

            obj.Relocate(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ());
            obj.SetWorldRotationAngles(oz, oy, ox);
            obj.SaveToDB();

            // Generate a completely new spawn with new guid
            // client caches recently deleted objects and brings them back to life
            // when CreateObject block for this guid is received again
            // however it entirely skips parsing that block and only uses already known location
            obj.Delete();

            obj = GameObject.CreateGameObjectFromDB(guidLow, map);
            if (!obj)
            {
                return(false);
            }

            handler.SendSysMessage(CypherStrings.CommandTurnobjmessage, obj.GetSpawnId(), obj.GetGoInfo().name, obj.GetGUID().ToString(), obj.GetOrientation());

            return(true);
        }
Ejemplo n.º 20
0
 static bool HandleModifySpeedCommand(StringArguments args, CommandHandler handler)
 {
     return(HandleModifyASpeedCommand(args, handler));
 }
Ejemplo n.º 21
0
            static bool HandleGameObjectAddCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    return(false);
                }

                // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
                string idStr = handler.ExtractKeyFromLink(args, "Hgameobject_entry");

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

                if (!uint.TryParse(idStr, out uint objectId) || objectId == 0)
                {
                    return(false);
                }

                uint spawntimeSecs = args.NextUInt32();

                GameObjectTemplate objectInfo = Global.ObjectMgr.GetGameObjectTemplate(objectId);

                if (objectInfo == null)
                {
                    handler.SendSysMessage(CypherStrings.GameobjectNotExist, objectId);
                    return(false);
                }

                if (objectInfo.displayId != 0 && !CliDB.GameObjectDisplayInfoStorage.ContainsKey(objectInfo.displayId))
                {
                    // report to DB errors log as in loading case
                    Log.outError(LogFilter.Sql, "Gameobject (Entry {0} GoType: {1}) have invalid displayId ({2}), not spawned.", objectId, objectInfo.type, objectInfo.displayId);
                    handler.SendSysMessage(CypherStrings.GameobjectHaveInvalidData, objectId);
                    return(false);
                }

                Player player = handler.GetPlayer();
                Map    map    = player.GetMap();

                GameObject obj = GameObject.CreateGameObject(objectInfo.entry, map, player, Quaternion.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f), 255, GameObjectState.Ready);

                if (!obj)
                {
                    return(false);
                }

                PhasingHandler.InheritPhaseShift(obj, player);

                if (spawntimeSecs != 0)
                {
                    obj.SetRespawnTime((int)spawntimeSecs);
                }

                // fill the gameobject data and save to the db
                obj.SaveToDB(map.GetId(), new List <Difficulty>()
                {
                    map.GetDifficultyID()
                });
                ulong spawnId = obj.GetSpawnId();

                // this will generate a new guid if the object is in an instance
                obj = GameObject.CreateGameObjectFromDB(spawnId, map);
                if (!obj)
                {
                    return(false);
                }

                // TODO: is it really necessary to add both the real and DB table guid here ?
                Global.ObjectMgr.AddGameObjectToGrid(spawnId, Global.ObjectMgr.GetGOData(spawnId));
                handler.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, spawnId, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ());
                return(true);
            }
Ejemplo n.º 22
0
        static bool HandleGroupListCommand(StringArguments args, CommandHandler handler)
        {
            // Get ALL the variables!
            Player     playerTarget;
            ObjectGuid guidTarget;
            string     nameTarget;
            string     zoneName    = "";
            string     onlineState = "";

            // Parse the guid to uint32...
            ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64());

            // ... and try to extract a player out of it.
            if (ObjectManager.GetPlayerNameByGUID(parseGUID, out nameTarget))
            {
                playerTarget = Global.ObjAccessor.FindPlayer(parseGUID);
                guidTarget   = parseGUID;
            }
            // If not, we return false and end right away.
            else if (!handler.extractPlayerTarget(args, out playerTarget, out guidTarget, out nameTarget))
            {
                return(false);
            }

            // Next, we need a group. So we define a group variable.
            Group groupTarget = null;

            // We try to extract a group from an online player.
            if (playerTarget)
            {
                groupTarget = playerTarget.GetGroup();
            }

            // If not, we extract it from the SQL.
            if (!groupTarget)
            {
                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GROUP_MEMBER);
                stmt.AddValue(0, guidTarget.GetCounter());
                SQLResult resultGroup = DB.Characters.Query(stmt);
                if (!resultGroup.IsEmpty())
                {
                    groupTarget = Global.GroupMgr.GetGroupByDbStoreId(resultGroup.Read <uint>(0));
                }
            }

            // If both fails, players simply has no party. Return false.
            if (!groupTarget)
            {
                handler.SendSysMessage(CypherStrings.GroupNotInGroup, nameTarget);
                return(false);
            }

            // We get the group members after successfully detecting a group.
            var members = groupTarget.GetMemberSlots();

            // To avoid a cluster f**k, namely trying multiple queries to simply get a group member count...
            handler.SendSysMessage(CypherStrings.GroupType, (groupTarget.isRaidGroup() ? "raid" : "party"), members.Count);
            // ... we simply move the group type and member count print after retrieving the slots and simply output it's size.

            // While rather dirty codestyle-wise, it saves space (if only a little). For each member, we look several informations up.
            foreach (var slot in members)
            {
                // Check for given flag and assign it to that iterator
                string flags = "";
                if (slot.flags.HasAnyFlag(GroupMemberFlags.Assistant))
                {
                    flags = "Assistant";
                }

                if (slot.flags.HasAnyFlag(GroupMemberFlags.MainTank))
                {
                    if (!string.IsNullOrEmpty(flags))
                    {
                        flags += ", ";
                    }
                    flags += "MainTank";
                }

                if (slot.flags.HasAnyFlag(GroupMemberFlags.MainAssist))
                {
                    if (!string.IsNullOrEmpty(flags))
                    {
                        flags += ", ";
                    }
                    flags += "MainAssist";
                }

                if (string.IsNullOrEmpty(flags))
                {
                    flags = "None";
                }

                // Check if iterator is online. If is...
                Player p      = Global.ObjAccessor.FindPlayer(slot.guid);
                string phases = "";
                if (p && p.IsInWorld)
                {
                    // ... than, it prints information like "is online", where he is, etc...
                    onlineState = "online";
                    phases      = PhasingHandler.FormatPhases(p.GetPhaseShift());

                    AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(p.GetAreaId());
                    if (area != null)
                    {
                        AreaTableRecord zone = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID);
                        if (zone != null)
                        {
                            zoneName = zone.AreaName[handler.GetSessionDbcLocale()];
                        }
                    }
                }
                else
                {
                    // ... else, everything is set to offline or neutral values.
                    zoneName    = "<ERROR>";
                    onlineState = "Offline";
                }

                // Now we can print those informations for every single member of each group!
                handler.SendSysMessage(CypherStrings.GroupPlayerNameGuid, slot.name, onlineState,
                                       zoneName, phases, slot.guid.ToString(), flags, LFGQueue.GetRolesString(slot.roles));
            }

            // And finish after every iterator is done.
            return(true);
        }
Ejemplo n.º 23
0
        static bool ShutdownServer(StringArguments args, CommandHandler handler, ShutdownMask shutdownMask, ShutdownExitCode defaultExitCode)
        {
            if (args.Empty())
            {
                return(false);
            }

            string delayStr = args.NextString();

            if (delayStr.IsEmpty())
            {
                return(false);
            }

            int delay;

            if (int.TryParse(delayStr, out delay))
            {
                //  Prevent interpret wrong arg value as 0 secs shutdown time
                if ((delay == 0 && (delayStr[0] != '0' || delayStr.Length > 1 && delayStr[1] != '\0')) || delay < 0)
                {
                    return(false);
                }
            }
            else
            {
                delay = (int)Time.TimeStringToSecs(delayStr);

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

            string reason      = "";
            string exitCodeStr = "";
            string nextToken;

            while (!(nextToken = args.NextString()).IsEmpty())
            {
                if (nextToken.IsNumber())
                {
                    exitCodeStr = nextToken;
                }
                else
                {
                    reason  = nextToken;
                    reason += args.NextString("\0");
                    break;
                }
            }

            int exitCode = (int)defaultExitCode;

            if (!exitCodeStr.IsEmpty())
            {
                if (!ParseExitCode(exitCodeStr, out exitCode))
                {
                    return(false);
                }
            }

            // Override parameter "delay" with the configuration value if there are still players connected and "force" parameter was not specified
            if (delay < WorldConfig.GetIntValue(WorldCfg.ForceShutdownThreshold) && !shutdownMask.HasAnyFlag(ShutdownMask.Force) && !IsOnlyUser(handler.GetSession()))
            {
                delay = WorldConfig.GetIntValue(WorldCfg.ForceShutdownThreshold);
                handler.SendSysMessage(CypherStrings.ShutdownDelayed, delay);
            }

            Global.WorldMgr.ShutdownServ((uint)delay, shutdownMask, (ShutdownExitCode)exitCode, reason);

            return(true);
        }
Ejemplo n.º 24
0
        static bool HandleGroupSummonCommand(StringArguments args, CommandHandler handler)
        {
            Player target;

            if (!handler.extractPlayerTarget(args, out target))
            {
                return(false);
            }

            // check online security
            if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
            {
                return(false);
            }

            Group group = target.GetGroup();

            string nameLink = handler.GetNameLink(target);

            if (!group)
            {
                handler.SendSysMessage(CypherStrings.NotInGroup, nameLink);
                return(false);
            }

            Player gmPlayer   = handler.GetSession().GetPlayer();
            Group  gmGroup    = gmPlayer.GetGroup();
            Map    gmMap      = gmPlayer.GetMap();
            bool   toInstance = gmMap.Instanceable();

            // we are in instance, and can summon only player in our group with us as lead
            if (toInstance && (
                    !gmGroup || group.GetLeaderGUID() != gmPlayer.GetGUID() ||
                    gmGroup.GetLeaderGUID() != gmPlayer.GetGUID()))
            // the last check is a bit excessive, but let it be, just in case
            {
                handler.SendSysMessage(CypherStrings.CannotSummonToInst);
                return(false);
            }

            for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
            {
                Player player = refe.GetSource();

                if (!player || player == gmPlayer || player.GetSession() == null)
                {
                    continue;
                }

                // check online security
                if (handler.HasLowerSecurity(player, ObjectGuid.Empty))
                {
                    return(false);
                }

                string plNameLink = handler.GetNameLink(player);

                if (player.IsBeingTeleported())
                {
                    handler.SendSysMessage(CypherStrings.IsTeleported, plNameLink);
                    return(false);
                }

                if (toInstance)
                {
                    Map playerMap = player.GetMap();

                    if (playerMap.Instanceable() && playerMap.GetInstanceId() != gmMap.GetInstanceId())
                    {
                        // cannot summon from instance to instance
                        handler.SendSysMessage(CypherStrings.CannotSummonToInst, plNameLink);
                        return(false);
                    }
                }

                handler.SendSysMessage(CypherStrings.Summoning, plNameLink, "");
                if (handler.needReportToTarget(player))
                {
                    player.SendSysMessage(CypherStrings.SummonedBy, handler.GetNameLink());
                }

                // stop flight if need
                if (player.IsInFlight())
                {
                    player.GetMotionMaster().MovementExpired();
                    player.CleanupAfterTaxiFlight();
                }
                // save only in non-flight case
                else
                {
                    player.SaveRecallPosition();
                }

                // before GM
                float x, y, z;
                gmPlayer.GetClosePoint(out x, out y, out z, player.GetObjectSize());
                player.TeleportTo(gmPlayer.GetMapId(), x, y, z, player.GetOrientation());
            }

            return(true);
        }
Ejemplo n.º 25
0
            static bool HandleServerRestartCancelCommand(StringArguments args, CommandHandler handler)
            {
                Global.WorldMgr.ShutdownCancel();

                return(true);
            }
Ejemplo n.º 26
0
        static RBACCommandData ReadParams(StringArguments args, CommandHandler handler, bool checkParams = true)
        {
            if (args.Empty())
            {
                return(null);
            }

            string param1 = args.NextString();
            string param2 = args.NextString();
            string param3 = args.NextString();

            int      realmId = -1;
            uint     accountId;
            string   accountName;
            uint     id                = 0;
            RBACData rdata             = null;
            bool     useSelectedPlayer = false;

            if (checkParams)
            {
                if (string.IsNullOrEmpty(param3))
                {
                    if (!int.TryParse(param2, out realmId))
                    {
                        return(null);
                    }

                    if (!uint.TryParse(param1, out id))
                    {
                        return(null);
                    }

                    useSelectedPlayer = true;
                }
                else
                {
                    if (!uint.TryParse(param2, out id))
                    {
                        return(null);
                    }

                    if (!int.TryParse(param3, out realmId))
                    {
                        return(null);
                    }
                }

                if (id == 0)
                {
                    handler.SendSysMessage(CypherStrings.RbacWrongParameterId, id);
                    return(null);
                }

                if (realmId < -1 || realmId == 0)
                {
                    handler.SendSysMessage(CypherStrings.RbacWrongParameterRealm, realmId);
                    return(null);
                }
            }
            else if (string.IsNullOrEmpty(param1))
            {
                useSelectedPlayer = true;
            }

            if (useSelectedPlayer)
            {
                Player player = handler.GetSelectedPlayer();
                if (!player)
                {
                    return(null);
                }

                rdata     = player.GetSession().GetRBACData();
                accountId = rdata.GetId();
                Global.AccountMgr.GetName(accountId, out accountName);
            }
            else
            {
                accountName = param1;
                accountId   = Global.AccountMgr.GetId(accountName);

                if (accountId == 0)
                {
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(null);
                }
            }

            if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true))
            {
                return(null);
            }

            RBACCommandData data = new();

            if (rdata == null)
            {
                data.rbac = new RBACData(accountId, accountName, (int)Global.WorldMgr.GetRealm().Id.Index, (byte)Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index));
                data.rbac.LoadFromDB();
                data.needDelete = true;
            }
            else
            {
                data.rbac = rdata;
            }

            data.id      = id;
            data.realmId = realmId;
            return(data);
        }
Ejemplo n.º 27
0
 static bool Exit(StringArguments args, CommandHandler handler)
 {
     handler.SendSysMessage(CypherStrings.CommandExit);
     Global.WorldMgr.StopNow(ShutdownExitCode.Shutdown);
     return(true);
 }
Ejemplo n.º 28
0
        static bool HandleGoQuestCommand(CommandHandler handler, StringArguments args)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player player = handler.GetSession().GetPlayer();

            string id = handler.ExtractKeyFromLink(args, "Hquest");

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

            if (!uint.TryParse(id, out uint questID) || questID == 0)
            {
                return(false);
            }

            if (Global.ObjectMgr.GetQuestTemplate(questID) == null)
            {
                handler.SendSysMessage(CypherStrings.CommandQuestNotfound, questID);
                return(false);
            }

            float x, y, z;
            uint  mapId;

            var poiData = Global.ObjectMgr.GetQuestPOIData(questID);

            if (poiData != null)
            {
                var data = poiData.Blobs[0];

                mapId = (uint)data.MapID;

                x = data.Points[0].X;
                y = data.Points[0].Y;
            }
            else
            {
                handler.SendSysMessage(CypherStrings.CommandQuestNotfound, questID);
                return(false);
            }

            if (!GridDefines.IsValidMapCoord(mapId, x, y) || Global.ObjectMgr.IsTransportMap(mapId))
            {
                handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, mapId);
                return(false);
            }

            // stop flight if need
            if (player.IsInFlight())
            {
                player.FinishTaxiFlight();
            }
            else
            {
                player.SaveRecallPosition(); // save only in non-flight case
            }
            Map map = Global.MapMgr.CreateBaseMap(mapId);

            z = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));

            player.TeleportTo(mapId, x, y, z, 0.0f);
            return(true);
        }
Ejemplo n.º 29
0
 static bool SetMotd(StringArguments args, CommandHandler handler)
 {
     Global.WorldMgr.SetMotd(args.NextString(""));
     handler.SendSysMessage(CypherStrings.MotdNew, args.GetString());
     return(true);
 }
Ejemplo n.º 30
0
        static bool PLimit(StringArguments args, CommandHandler handler)
        {
            if (!args.Empty())
            {
                string paramStr = args.NextString();
                if (string.IsNullOrEmpty(paramStr))
                {
                    return(false);
                }

                switch (paramStr.ToLower())
                {
                case "player":
                    Global.WorldMgr.SetPlayerSecurityLimit(AccountTypes.Player);
                    break;

                case "moderator":
                    Global.WorldMgr.SetPlayerSecurityLimit(AccountTypes.Moderator);
                    break;

                case "gamemaster":
                    Global.WorldMgr.SetPlayerSecurityLimit(AccountTypes.GameMaster);
                    break;

                case "administrator":
                    Global.WorldMgr.SetPlayerSecurityLimit(AccountTypes.Administrator);
                    break;

                case "reset":
                    Global.WorldMgr.SetPlayerAmountLimit(ConfigMgr.GetDefaultValue <uint>("PlayerLimit", 100));
                    Global.WorldMgr.LoadDBAllowedSecurityLevel();
                    break;

                default:
                    if (!int.TryParse(paramStr, out int value))
                    {
                        return(false);
                    }

                    if (value < 0)
                    {
                        Global.WorldMgr.SetPlayerSecurityLimit((AccountTypes)(-value));
                    }
                    else
                    {
                        Global.WorldMgr.SetPlayerAmountLimit((uint)value);
                    }
                    break;
                }
            }

            uint         playerAmountLimit  = Global.WorldMgr.GetPlayerAmountLimit();
            AccountTypes allowedAccountType = Global.WorldMgr.GetPlayerSecurityLimit();
            string       secName;

            switch (allowedAccountType)
            {
            case AccountTypes.Player:
                secName = "Player";
                break;

            case AccountTypes.Moderator:
                secName = "Moderator";
                break;

            case AccountTypes.GameMaster:
                secName = "Gamemaster";
                break;

            case AccountTypes.Administrator:
                secName = "Administrator";
                break;

            default:
                secName = "<unknown>";
                break;
            }
            handler.SendSysMessage("Player limits: amount {0}, min. security level {1}.", playerAmountLimit, secName);

            return(true);
        }