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

                string newTimeStr = args.NextString();

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

                if (!int.TryParse(newTimeStr, out int newTime) || newTime < 0)
                {
                    return(false);
                }

                //Global.WorldMgr.SetRecordDiffInterval(newTime);
                //printf("Record diff every %i ms\n", newTime);

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

                uint id = args.NextUInt32();

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

                Player player = handler.GetPlayer();

                uint spawntime = args.NextUInt32();
                uint spawntm   = 300;

                if (spawntime != 0)
                {
                    spawntm = spawntime;
                }

                Quaternion rotation = Quaternion.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f);

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

                player.SummonGameObject(id, player, rotation, spawntm);

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

            string accountName = args.NextString("");

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

            uint accountId = Global.AccountMgr.GetId(accountName);

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

            return(HandleBanInfoHelper(accountId, accountName, handler));
        }
Пример #4
0
        static bool HandleGoTicketCommand <T>(StringArguments args, CommandHandler handler) where T : Ticket
        {
            if (args.Empty())
            {
                return(false);
            }

            uint ticketId = args.NextUInt32();

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

            T ticket = Global.SupportMgr.GetTicket <T>(ticketId);

            if (ticket == null)
            {
                handler.SendSysMessage(CypherStrings.CommandTicketnotexist);
                return(true);
            }

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

            // stop flight if need
            if (player.IsInFlight())
            {
                player.FinishTaxiFlight();
            }
            else
            {
                player.SaveRecallPosition(); // save only in non-flight case
            }
            ticket.TeleportTo(player);
            return(true);
        }
Пример #5
0
        static bool HandleGameObjectActivateCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            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);
            }

            uint autoCloseTime = obj.GetGoInfo().GetAutoCloseTime() != 0 ? 10000u : 0u;

            // Activate
            obj.SetLootState(LootState.Ready);
            obj.UseDoorOrButton(autoCloseTime, false, handler.GetSession().GetPlayer());

            handler.SendSysMessage("Object activated!");
            return(true);
        }
Пример #6
0
        static bool HandlePlaySceneCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            uint   sceneId = args.NextUInt32();
            Player target  = handler.GetSelectedPlayerOrSelf();

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

            if (Global.ObjectMgr.GetSceneTemplate(sceneId) == null)
            {
                return(false);
            }

            target.GetSceneMgr().PlayScene(sceneId);
            return(true);
        }
Пример #7
0
        static bool HandleGoZoneXYCommand(StringArguments args, CommandHandler handler)
        {
            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);
            }

            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.GetMotionMaster().MovementExpired();
                player.CleanupAfterTaxiFlight();
            }
            // save only in non-flight case
            else
            {
                player.SaveRecallPosition();
            }

            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);
        }
Пример #8
0
        static bool HandleGoQuestCommand(StringArguments args, CommandHandler handler)
        {
            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 = 0;
            uint  mapId = 0;

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

            if (poiData != null)
            {
                var data = poiData[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.GetMotionMaster().MovementExpired();
                player.CleanupAfterTaxiFlight();
            }
            // save only in non-flight case
            else
            {
                player.SaveRecallPosition();
            }

            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);
        }
Пример #9
0
        static bool HandleWpShowCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // first arg: on, off, first, last
            string show = args.NextString();

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

            // second arg: GUID (optional, if a creature is selected)
            string guid_str = args.NextString();

            uint     pathid;
            Creature target = handler.GetSelectedCreature();

            // Did player provide a PathID?

            if (string.IsNullOrEmpty(guid_str))
            {
                // No PathID provided
                // . Player must have selected a creature

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

                pathid = target.GetWaypointPath();
            }
            else
            {
                // PathID provided
                // Warn if player also selected a creature
                // . Creature selection is ignored <-
                if (target)
                {
                    handler.SendSysMessage(CypherStrings.WaypointCreatselected);
                }

                if (!uint.TryParse(guid_str, out pathid))
                {
                    return(false);
                }
            }

            // Show info for the selected waypoint
            if (show == "info")
            {
                // Check if the user did specify a visual waypoint
                if (!target || target.GetEntry() != 1)
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpSelect);
                    return(false);
                }

                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
                stmt.AddValue(0, target.GetSpawnId());
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotfounddbproblem, target.GetSpawnId());
                    return(true);
                }

                handler.SendSysMessage("|cff00ffffDEBUG: wp show info:|r");
                do
                {
                    pathid = result.Read <uint>(0);
                    uint point     = result.Read <uint>(1);
                    uint delay     = result.Read <uint>(2);
                    uint flag      = result.Read <uint>(3);
                    uint ev_id     = result.Read <uint>(4);
                    uint ev_chance = result.Read <uint>(5);

                    handler.SendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff{0}|r|cff00ff00, Path ID: |r|cff00ffff{1}|r", point, pathid);
                    handler.SendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff{0}|r", delay);
                    handler.SendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff{0}|r", flag);
                    handler.SendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff{0}|r", ev_id);
                    handler.SendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff{0}|r", ev_chance);
                }while (result.NextRow());

                return(true);
            }

            if (show == "on")
            {
                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_BY_ID);
                stmt.AddValue(0, pathid);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage("|cffff33ffPath no found.|r");
                    return(false);
                }

                handler.SendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff{0}|r", pathid);

                // Delete all visuals for this NPC
                stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_WPGUID_BY_ID);
                stmt.AddValue(0, pathid);
                SQLResult result2 = DB.World.Query(stmt);

                if (!result2.IsEmpty())
                {
                    bool hasError = false;
                    do
                    {
                        ulong wpguid = result2.Read <ulong>(0);

                        Creature creature = handler.GetCreatureFromPlayerMapByDbGuid(wpguid);
                        if (!creature)
                        {
                            handler.SendSysMessage(CypherStrings.WaypointNotremoved, wpguid);
                            hasError = true;

                            stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_CREATURE);
                            stmt.AddValue(0, wpguid);
                            DB.World.Execute(stmt);
                        }
                        else
                        {
                            creature.CombatStop();
                            creature.DeleteFromDB();
                            creature.AddObjectToRemoveList();
                        }
                    }while (result2.NextRow());

                    if (hasError)
                    {
                        handler.SendSysMessage(CypherStrings.WaypointToofar1);
                        handler.SendSysMessage(CypherStrings.WaypointToofar2);
                        handler.SendSysMessage(CypherStrings.WaypointToofar3);
                    }
                }

                do
                {
                    uint  point = result.Read <uint>(0);
                    float x     = result.Read <float>(1);
                    float y     = result.Read <float>(2);
                    float z     = result.Read <float>(3);

                    uint id = 1;

                    Player   chr = handler.GetSession().GetPlayer();
                    Map      map = chr.GetMap();
                    Position pos = new Position(x, y, z, chr.GetOrientation());

                    Creature creature = Creature.CreateCreature(id, map, pos);
                    if (!creature)
                    {
                        handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
                        return(false);
                    }

                    PhasingHandler.InheritPhaseShift(creature, chr);
                    creature.SaveToDB(map.GetId(), new List <Difficulty>()
                    {
                        map.GetDifficultyID()
                    });

                    ulong dbGuid = creature.GetSpawnId();

                    // current "wpCreature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
                    creature.CleanupsBeforeDelete();
                    creature.Dispose();

                    // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
                    creature = Creature.CreateCreatureFromDB(dbGuid, map);
                    if (!creature)
                    {
                        handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
                        return(false);
                    }

                    if (target)
                    {
                        creature.SetDisplayId(target.GetDisplayId());
                        creature.SetObjectScale(0.5f);
                        creature.SetLevel(Math.Min(point, SharedConst.StrongMaxLevel));
                    }

                    // Set "wpguid" column to the visual waypoint
                    stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_WPGUID);
                    stmt.AddValue(0, creature.GetSpawnId());
                    stmt.AddValue(1, pathid);
                    stmt.AddValue(2, point);
                    DB.World.Execute(stmt);
                }while (result.NextRow());

                handler.SendSysMessage("|cff00ff00Showing the current creature's path.|r");
                return(true);
            }

            if (show == "first")
            {
                handler.SendSysMessage("|cff00ff00DEBUG: wp first, pathid: {0}|r", pathid);

                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
                stmt.AddValue(0, pathid);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotfound, pathid);
                    return(false);
                }

                float x = result.Read <float>(0);
                float y = result.Read <float>(1);
                float z = result.Read <float>(2);

                Player   chr = handler.GetSession().GetPlayer();
                Map      map = chr.GetMap();
                Position pos = new Position(x, y, z, chr.GetOrientation());

                Creature creature = Creature.CreateCreature(1, map, pos);
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
                    return(false);
                }

                PhasingHandler.InheritPhaseShift(creature, chr);
                creature.SaveToDB(map.GetId(), new List <Difficulty>()
                {
                    map.GetDifficultyID()
                });

                ulong dbGuid = creature.GetSpawnId();

                // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
                creature.CleanupsBeforeDelete();
                creature.Dispose();

                creature = Creature.CreateCreatureFromDB(dbGuid, map);
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
                    return(false);
                }

                if (target)
                {
                    creature.SetDisplayId(target.GetDisplayId());
                    creature.SetObjectScale(0.5f);
                }

                return(true);
            }

            if (show == "last")
            {
                handler.SendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff{0}|r", pathid);

                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_LAST_BY_ID);
                stmt.AddValue(0, pathid);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotfoundlast, pathid);
                    return(false);
                }

                float x = result.Read <float>(0);
                float y = result.Read <float>(1);
                float z = result.Read <float>(2);
                float o = result.Read <float>(3);

                Player   chr = handler.GetSession().GetPlayer();
                Map      map = chr.GetMap();
                Position pos = new Position(x, y, z, o);

                Creature creature = Creature.CreateCreature(1, map, pos);
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotcreated, 1);
                    return(false);
                }

                PhasingHandler.InheritPhaseShift(creature, chr);
                creature.SaveToDB(map.GetId(), new List <Difficulty>()
                {
                    map.GetDifficultyID()
                });

                ulong dbGuid = creature.GetSpawnId();

                // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
                creature.CleanupsBeforeDelete();
                creature.Dispose();

                creature = Creature.CreateCreatureFromDB(dbGuid, map);
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotcreated, 1);
                    return(false);
                }

                if (target)
                {
                    creature.SetDisplayId(target.GetDisplayId());
                    creature.SetObjectScale(0.5f);
                }

                return(true);
            }

            if (show == "off")
            {
                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_BY_ID);
                stmt.AddValue(0, 1);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpNotfound);
                    return(false);
                }
                bool hasError = false;
                do
                {
                    ulong lowguid = result.Read <ulong>(0);

                    Creature creature = handler.GetCreatureFromPlayerMapByDbGuid(lowguid);
                    if (!creature)
                    {
                        handler.SendSysMessage(CypherStrings.WaypointNotremoved, lowguid);
                        hasError = true;

                        stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_CREATURE);
                        stmt.AddValue(0, lowguid);
                        DB.World.Execute(stmt);
                    }
                    else
                    {
                        creature.CombatStop();
                        creature.DeleteFromDB();
                        creature.AddObjectToRemoveList();
                    }
                }while (result.NextRow());
                // set "wpguid" column to "empty" - no visual waypoint spawned
                stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_ALL_WPGUID);

                DB.World.Execute(stmt);
                //DB.World.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");

                if (hasError)
                {
                    handler.SendSysMessage(CypherStrings.WaypointToofar1);
                    handler.SendSysMessage(CypherStrings.WaypointToofar2);
                    handler.SendSysMessage(CypherStrings.WaypointToofar3);
                }

                handler.SendSysMessage(CypherStrings.WaypointVpAllremoved);
                return(true);
            }

            handler.SendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r");
            return(true);
        }
Пример #10
0
        static bool HandleWpLoadCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // optional
            string path_number = args.NextString();

            uint     pathid;
            Creature target = handler.GetSelectedCreature();

            // Did player provide a path_id?
            if (string.IsNullOrEmpty(path_number))
            {
                return(false);
            }

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

            if (target.GetEntry() == 1)
            {
                handler.SendSysMessage("|cffff33ffYou want to load path to a waypoint? Aren't you?|r");
                return(false);
            }

            if (!uint.TryParse(path_number, out pathid) || pathid == 0)
            {
                handler.SendSysMessage("|cffff33ffNo valid path number provided.|r");
                return(true);
            }

            ulong guidLow = target.GetSpawnId();

            PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID);

            stmt.AddValue(0, guidLow);
            SQLResult result = DB.World.Query(stmt);

            if (!result.IsEmpty())
            {
                stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_ADDON_PATH);
                stmt.AddValue(0, pathid);
                stmt.AddValue(1, guidLow);
            }
            else
            {
                stmt = DB.World.GetPreparedStatement(WorldStatements.INS_CREATURE_ADDON);
                stmt.AddValue(0, guidLow);
                stmt.AddValue(1, pathid);
            }

            DB.World.Execute(stmt);

            stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_MOVEMENT_TYPE);
            stmt.AddValue(0, (byte)MovementGeneratorType.Waypoint);
            stmt.AddValue(1, guidLow);

            DB.World.Execute(stmt);

            target.LoadPath(pathid);
            target.SetDefaultMovementType(MovementGeneratorType.Waypoint);
            target.GetMotionMaster().Initialize();
            target.Say("Path loaded.", Language.Universal);

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

            string            show = args.NextString();
            PreparedStatement stmt;

            // Check
            if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid"))
            {
                return(false);
            }

            string arg_id = args.NextString();
            uint   id;

            if (show == "add")
            {
                if (!uint.TryParse(arg_id, out id))
                {
                    id = 0;
                }

                if (id != 0)
                {
                    stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
                    stmt.AddValue(0, id);
                    SQLResult result = DB.World.Query(stmt);

                    if (result.IsEmpty())
                    {
                        stmt = DB.World.GetPreparedStatement(WorldStatements.INS_WAYPOINT_SCRIPT);
                        stmt.AddValue(0, id);
                        DB.World.Execute(stmt);

                        handler.SendSysMessage("|cff00ff00Wp Event: New waypoint event added: {0}|r", "", id);
                    }
                    else
                    {
                        handler.SendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: {0}|r", id);
                    }
                }
                else
                {
                    stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_SCRIPTS_MAX_ID);
                    SQLResult result = DB.World.Query(stmt);
                    id = result.Read <uint>(0);

                    stmt = DB.World.GetPreparedStatement(WorldStatements.INS_WAYPOINT_SCRIPT);
                    stmt.AddValue(0, id + 1);
                    DB.World.Execute(stmt);

                    handler.SendSysMessage("|cff00ff00Wp Event: New waypoint event added: |r|cff00ffff{0}|r", id + 1);
                }

                return(true);
            }

            if (show == "listid")
            {
                if (string.IsNullOrEmpty(arg_id))
                {
                    handler.SendSysMessage("|cff33ffffWp Event: You must provide waypoint script id.|r");
                    return(true);
                }

                if (!uint.TryParse(arg_id, out id))
                {
                    return(false);
                }

                uint   a2, a3, a4, a5, a6;
                float  a8, a9, a10, a11;
                string a7;

                stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_BY_ID);
                stmt.AddValue(0, id);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage("|cff33ffffWp Event: No waypoint scripts found on id: {0}|r", id);
                    return(true);
                }

                do
                {
                    a2  = result.Read <uint>(0);
                    a3  = result.Read <uint>(1);
                    a4  = result.Read <uint>(2);
                    a5  = result.Read <uint>(3);
                    a6  = result.Read <uint>(4);
                    a7  = result.Read <string>(5);
                    a8  = result.Read <float>(6);
                    a9  = result.Read <float>(7);
                    a10 = result.Read <float>(8);
                    a11 = result.Read <float>(9);

                    handler.SendSysMessage("|cffff33ffid:|r|cff00ffff {0}|r|cff00ff00, guid: |r|cff00ffff{1}|r|cff00ff00, delay: |r|cff00ffff{2}|r|cff00ff00, command: |r|cff00ffff{3}|r|cff00ff00," +
                                           "datalong: |r|cff00ffff{4}|r|cff00ff00, datalong2: |r|cff00ffff{5}|r|cff00ff00, datatext: |r|cff00ffff{6}|r|cff00ff00, posx: |r|cff00ffff{7}|r|cff00ff00, " +
                                           "posy: |r|cff00ffff{8}|r|cff00ff00, posz: |r|cff00ffff{9}|r|cff00ff00, orientation: |r|cff00ffff{10}|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
                }while (result.NextRow());
            }

            if (show == "del")
            {
                if (arg_id.IsEmpty())
                {
                    handler.SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
                    return(true);
                }

                if (!uint.TryParse(arg_id, out id))
                {
                    return(false);
                }

                stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
                stmt.AddValue(0, id);
                SQLResult result = DB.World.Query(stmt);

                if (!result.IsEmpty())
                {
                    stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_WAYPOINT_SCRIPT);
                    stmt.AddValue(0, id);
                    DB.World.Execute(stmt);

                    handler.SendSysMessage("|cff00ff00{0}{1}|r", "Wp Event: Waypoint script removed: ", id);
                }
                else
                {
                    handler.SendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: {0}|r", id);
                }

                return(true);
            }

            if (show == "mod")
            {
                if (string.IsNullOrEmpty(arg_id))
                {
                    handler.SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
                    return(true);
                }

                if (!uint.TryParse(arg_id, out id) || id == 0)
                {
                    handler.SendSysMessage("|cffff33ffERROR: No valid waypoint script id not present.|r");
                    return(true);
                }

                string arg_string = args.NextString();
                if (string.IsNullOrEmpty(arg_string))
                {
                    handler.SendSysMessage("|cffff33ffERROR: No argument present.|r");
                    return(true);
                }

                if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command") &&
                    (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx") &&
                    (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation"))
                {
                    handler.SendSysMessage("|cffff33ffERROR: No valid argument present.|r");
                    return(true);
                }

                string arg_3 = args.NextString();
                if (string.IsNullOrEmpty(arg_3))
                {
                    handler.SendSysMessage("|cffff33ffERROR: No additional argument present.|r");
                    return(true);
                }

                if (arg_string == "setid")
                {
                    if (!uint.TryParse(arg_3, out uint newid))
                    {
                        return(false);
                    }
                    handler.SendSysMessage("|cff00ff00Wp Event: Waypoint script guid: {0}|r|cff00ffff id changed: |r|cff00ff00{1}|r", newid, id);

                    stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_ID);
                    stmt.AddValue(0, newid);
                    stmt.AddValue(1, id);

                    DB.World.Execute(stmt);

                    return(true);
                }
                else
                {
                    stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
                    stmt.AddValue(0, id);
                    SQLResult result = DB.World.Query(stmt);

                    if (result.IsEmpty())
                    {
                        handler.SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r");
                        return(true);
                    }

                    if (arg_string == "posx")
                    {
                        if (!float.TryParse(arg_3, out float arg3))
                        {
                            return(false);
                        }

                        stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_X);
                        stmt.AddValue(0, arg3);
                        stmt.AddValue(1, id);
                        DB.World.Execute(stmt);

                        handler.SendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff {0}|r|cff00ff00 position_x updated.|r", id);
                        return(true);
                    }
                    else if (arg_string == "posy")
                    {
                        if (!float.TryParse(arg_3, out float arg3))
                        {
                            return(false);
                        }

                        stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Y);
                        stmt.AddValue(0, arg3);
                        stmt.AddValue(1, id);
                        DB.World.Execute(stmt);

                        handler.SendSysMessage("|cff00ff00Waypoint script: {0} position_y updated.|r", id);
                        return(true);
                    }
                    else if (arg_string == "posz")
                    {
                        if (!float.TryParse(arg_3, out float arg3))
                        {
                            return(false);
                        }

                        stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Z);
                        stmt.AddValue(0, arg3);
                        stmt.AddValue(1, id);
                        DB.World.Execute(stmt);

                        handler.SendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{0}|r|cff00ff00 position_z updated.|r", id);
                        return(true);
                    }
                    else if (arg_string == "orientation")
                    {
                        if (!float.TryParse(arg_3, out float arg3))
                        {
                            return(false);
                        }

                        stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_O);
                        stmt.AddValue(0, arg3);
                        stmt.AddValue(1, id);
                        DB.World.Execute(stmt);

                        handler.SendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{0}|r|cff00ff00 orientation updated.|r", id);
                        return(true);
                    }
                    else if (arg_string == "dataint")
                    {
                        if (!uint.TryParse(arg_3, out uint arg3))
                        {
                            return(false);
                        }

                        DB.World.Execute("UPDATE waypoint_scripts SET {0}='{1}' WHERE guid='{2}'", arg_string, arg3, id); // Query can't be a prepared statement

                        handler.SendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{0}|r|cff00ff00 dataint updated.|r", id);
                        return(true);
                    }
                    else
                    {
                        DB.World.Execute("UPDATE waypoint_scripts SET {0}='{1}' WHERE guid='{2}'", arg_string, arg_string, id); // Query can't be a prepared statement
                    }
                }
                handler.SendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff{0}:|r|cff00ff00 {1} updated.|r", id, arg_string);
            }
            return(true);
        }
Пример #12
0
        static bool Rep(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);
            }

            uint factionId = uint.Parse(factionTxt);

            int    amount  = 0;
            string rankTxt = args.NextString();

            if (factionId == 0 || rankTxt.IsEmpty())
            {
                return(false);
            }

            amount = int.Parse(rankTxt);
            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))
                        {
                            int delta = int.Parse(deltaTxt);
                            if ((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);
        }
Пример #13
0
            static bool HandleSetAddonCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    return(false);
                }

                // Get the command line arguments
                string account = args.NextString();
                string exp     = args.NextString();

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

                string accountName;
                uint   accountId;

                if (string.IsNullOrEmpty(exp))
                {
                    Player player = handler.getSelectedPlayer();
                    if (!player)
                    {
                        return(false);
                    }

                    accountId = player.GetSession().GetAccountId();
                    Global.AccountMgr.GetName(accountId, out accountName);
                    exp = account;
                }
                else
                {
                    // Convert Account name to Upper Format
                    accountName = account.ToUpper();

                    accountId = Global.AccountMgr.GetId(accountName);
                    if (accountId == 0)
                    {
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);
                    }
                }

                // Let set addon state only for lesser (strong) security level
                // or to self account
                if (handler.GetSession() != null && handler.GetSession().GetAccountId() != accountId &&
                    handler.HasLowerSecurityAccount(null, accountId, true))
                {
                    return(false);
                }

                if (!byte.TryParse(exp, out byte expansion))
                {
                    return(false);
                }

                if (expansion > WorldConfig.GetIntValue(WorldCfg.Expansion))
                {
                    return(false);
                }

                PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPANSION);

                stmt.AddValue(0, expansion);
                stmt.AddValue(1, accountId);

                DB.Login.Execute(stmt);

                handler.SendSysMessage(CypherStrings.AccountSetaddon, accountName, accountId, expansion);
                return(true);
            }
Пример #14
0
            static bool HandleSetPasswordCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CmdSyntax);
                    return(false);
                }

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

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

                uint targetAccountId = Global.AccountMgr.GetId(accountName);

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

                // can set password only for target with less security
                // This also restricts setting handler's own password
                if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                {
                    return(false);
                }

                if (!password.Equals(passwordConfirmation))
                {
                    handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                    return(false);
                }

                AccountOpResult result = Global.AccountMgr.ChangePassword(targetAccountId, password);

                switch (result)
                {
                case AccountOpResult.Ok:
                    handler.SendSysMessage(CypherStrings.CommandPassword);
                    break;

                case AccountOpResult.NameNotExist:
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);

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

                default:
                    handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                    return(false);
                }
                return(true);
            }
Пример #15
0
        static bool HandleAccountPasswordCommand(StringArguments args, CommandHandler handler)
        {
            // If no args are given at all, we can return false right away.
            if (args.Empty())
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);
                return(false);
            }

            // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
            uint pwConfig = WorldConfig.GetUIntValue(WorldCfg.AccPasschangesec); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC

            // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
            string oldPassword          = args.NextString(); // This extracts [$oldpassword]
            string newPassword          = args.NextString(); // This extracts [$newpassword]
            string passwordConfirmation = args.NextString(); // This extracts [$newpasswordconfirmation]
            string emailConfirmation    = args.NextString(); // This defines the emailConfirmation variable, which is optional depending on sec type.

            //Is any of those variables missing for any reason ? We return false.
            if (string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword) ||
                string.IsNullOrEmpty(passwordConfirmation))
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);

                return(false);
            }

            // We compare the old, saved password to the entered old password - no chance for the unauthorized.
            if (!Global.AccountMgr.CheckPassword(handler.GetSession().GetAccountId(), oldPassword))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongoldpassword);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the provided old password is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }
            // This compares the old, current email to the entered email - however, only...
            if ((pwConfig == 1 || (pwConfig == 2 && handler.GetSession().HasPermission(RBACPermissions.EmailConfirmForPassChange))) && // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
                !Global.AccountMgr.CheckEmail(handler.GetSession().GetAccountId(), emailConfirmation))    // ... and returns false if the comparison fails.
            {
                handler.SendSysMessage(CypherStrings.CommandWrongemail);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the entered email [{4}] is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                            emailConfirmation);
                return(false);
            }

            // Making sure that newly entered password is correctly entered.
            if (newPassword != passwordConfirmation)
            {
                handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                return(false);
            }

            // Changes password and prints result.
            AccountOpResult result = Global.AccountMgr.ChangePassword(handler.GetSession().GetAccountId(), newPassword);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.CommandPassword);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Changed Password.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                break;

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

            default:
                handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                return(false);
            }

            return(true);
        }
Пример #16
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);
            }

            ushort mark;

            string pmark = args.NextString();

            if (string.IsNullOrEmpty(pmark))
            {
                mark = 65535;
            }
            else
            {
                mark = ushort.Parse(pmark);
            }

            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);
        }
Пример #17
0
        static bool Mount(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            ushort mId   = 1147;
            float  speed = 15f;

            uint num = args.NextUInt32();

            switch (num)
            {
            case 1:
                mId = 14340;
                break;

            case 2:
                mId = 4806;
                break;

            case 3:
                mId = 6471;
                break;

            case 4:
                mId = 12345;
                break;

            case 5:
                mId = 6472;
                break;

            case 6:
                mId = 6473;
                break;

            case 7:
                mId = 10670;
                break;

            case 8:
                mId = 10719;
                break;

            case 9:
                mId = 10671;
                break;

            case 10:
                mId = 10672;
                break;

            case 11:
                mId = 10720;
                break;

            case 12:
                mId = 14349;
                break;

            case 13:
                mId = 11641;
                break;

            case 14:
                mId = 12244;
                break;

            case 15:
                mId = 12242;
                break;

            case 16:
                mId = 14578;
                break;

            case 17:
                mId = 14579;
                break;

            case 18:
                mId = 14349;
                break;

            case 19:
                mId = 12245;
                break;

            case 20:
                mId = 14335;
                break;

            case 21:
                mId = 207;
                break;

            case 22:
                mId = 2328;
                break;

            case 23:
                mId = 2327;
                break;

            case 24:
                mId = 2326;
                break;

            case 25:
                mId = 14573;
                break;

            case 26:
                mId = 14574;
                break;

            case 27:
                mId = 14575;
                break;

            case 28:
                mId = 604;
                break;

            case 29:
                mId = 1166;
                break;

            case 30:
                mId = 2402;
                break;

            case 31:
                mId = 2410;
                break;

            case 32:
                mId = 2409;
                break;

            case 33:
                mId = 2408;
                break;

            case 34:
                mId = 2405;
                break;

            case 35:
                mId = 14337;
                break;

            case 36:
                mId = 6569;
                break;

            case 37:
                mId = 10661;
                break;

            case 38:
                mId = 10666;
                break;

            case 39:
                mId = 9473;
                break;

            case 40:
                mId = 9476;
                break;

            case 41:
                mId = 9474;
                break;

            case 42:
                mId = 14374;
                break;

            case 43:
                mId = 14376;
                break;

            case 44:
                mId = 14377;
                break;

            case 45:
                mId = 2404;
                break;

            case 46:
                mId = 2784;
                break;

            case 47:
                mId = 2787;
                break;

            case 48:
                mId = 2785;
                break;

            case 49:
                mId = 2736;
                break;

            case 50:
                mId = 2786;
                break;

            case 51:
                mId = 14347;
                break;

            case 52:
                mId = 14346;
                break;

            case 53:
                mId = 14576;
                break;

            case 54:
                mId = 9695;
                break;

            case 55:
                mId = 9991;
                break;

            case 56:
                mId = 6448;
                break;

            case 57:
                mId = 6444;
                break;

            case 58:
                mId = 6080;
                break;

            case 59:
                mId = 6447;
                break;

            case 60:
                mId = 4805;
                break;

            case 61:
                mId = 9714;
                break;

            case 62:
                mId = 6448;
                break;

            case 63:
                mId = 6442;
                break;

            case 64:
                mId = 14632;
                break;

            case 65:
                mId = 14332;
                break;

            case 66:
                mId = 14331;
                break;

            case 67:
                mId = 8469;
                break;

            case 68:
                mId = 2830;
                break;

            case 69:
                mId = 2346;
                break;

            default:
                handler.SendSysMessage(CypherStrings.NoMount);
                return(false);
            }

            Player target = handler.getSelectedPlayerOrSelf();

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

                return(false);
            }

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

            NotifyModification(handler, target, CypherStrings.YouGiveMount, CypherStrings.MountGived);

            target.SetUInt32Value(UnitFields.Flags, (uint)UnitFlags.Pvp);
            target.Mount(mId);

            var packet = new MoveSetSpeed(ServerOpcodes.MoveSetRunSpeed);

            packet.MoverGUID     = target.GetGUID();
            packet.SequenceIndex = 0;
            packet.Speed         = speed;
            target.SendMessageToSet(packet, true);

            packet               = new MoveSetSpeed(ServerOpcodes.MoveSetSwimSpeed);
            packet.MoverGUID     = target.GetGUID();
            packet.SequenceIndex = 0;
            packet.Speed         = speed;
            target.SendMessageToSet(packet, true);

            return(true);
        }
Пример #18
0
            static bool HandleSetGmLevelCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CmdSyntax);
                    return(false);
                }

                string       targetAccountName = "";
                uint         targetAccountId   = 0;
                AccountTypes targetSecurity    = 0;
                uint         gm   = 0;
                string       arg1 = args.NextString();
                string       arg2 = args.NextString();
                string       arg3 = args.NextString();
                bool         isAccountNameGiven = true;

                if (string.IsNullOrEmpty(arg3))
                {
                    if (!handler.getSelectedPlayer())
                    {
                        return(false);
                    }
                    isAccountNameGiven = false;
                }

                if (!isAccountNameGiven && string.IsNullOrEmpty(arg2))
                {
                    return(false);
                }

                if (isAccountNameGiven)
                {
                    targetAccountName = arg1;
                    if (Global.AccountMgr.GetId(targetAccountName) == 0)
                    {
                        handler.SendSysMessage(CypherStrings.AccountNotExist, targetAccountName);
                        return(false);
                    }
                }

                // Check for invalid specified GM level.
                if (!uint.TryParse(isAccountNameGiven ? arg2 : arg1, out gm))
                {
                    return(false);
                }

                if (gm > (uint)AccountTypes.Console)
                {
                    handler.SendSysMessage(CypherStrings.BadValue);
                    return(false);
                }

                // command.getSession() == NULL only for console
                targetAccountId = (isAccountNameGiven) ? Global.AccountMgr.GetId(targetAccountName) : handler.getSelectedPlayer().GetSession().GetAccountId();
                if (!int.TryParse(isAccountNameGiven ? arg3 : arg2, out int gmRealmID))
                {
                    return(false);
                }

                AccountTypes playerSecurity;

                if (handler.GetSession() != null)
                {
                    playerSecurity = Global.AccountMgr.GetSecurity(handler.GetSession().GetAccountId(), gmRealmID);
                }
                else
                {
                    playerSecurity = AccountTypes.Console;
                }

                // can set security level only for target with less security and to less security that we have
                // This is also reject self apply in fact
                targetSecurity = Global.AccountMgr.GetSecurity(targetAccountId, gmRealmID);
                if (targetSecurity >= playerSecurity || (AccountTypes)gm >= playerSecurity)
                {
                    handler.SendSysMessage(CypherStrings.YoursSecurityIsLow);
                    return(false);
                }
                PreparedStatement stmt;

                // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
                if (gmRealmID == -1 && !Global.AccountMgr.IsConsoleAccount(playerSecurity))
                {
                    stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
                    stmt.AddValue(0, targetAccountId);
                    stmt.AddValue(1, gm);

                    SQLResult result = DB.Login.Query(stmt);

                    if (!result.IsEmpty())
                    {
                        handler.SendSysMessage(CypherStrings.YoursSecurityIsLow);
                        return(false);
                    }
                }

                // Check if provided realmID has a negative value other than -1
                if (gmRealmID < -1)
                {
                    handler.SendSysMessage(CypherStrings.InvalidRealmid);
                    return(false);
                }

                RBACData rbac = isAccountNameGiven ? null : handler.getSelectedPlayer().GetSession().GetRBACData();

                Global.AccountMgr.UpdateAccountAccess(rbac, targetAccountId, (byte)gm, gmRealmID);
                handler.SendSysMessage(CypherStrings.YouChangeSecurity, targetAccountName, gm);
                return(true);
            }
Пример #19
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.SetByteValue(UnitFields.Bytes0, 3, (byte)gender);
            target.SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender, (byte)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);
        }
Пример #20
0
                static bool HandleSetRegEmailCommand(StringArguments args, CommandHandler handler)
                {
                    if (args.Empty())
                    {
                        return(false);
                    }

                    //- We do not want anything short of console to use this by default.
                    //- So we force that.
                    if (handler.GetSession())
                    {
                        return(false);
                    }

                    // Get the command line arguments
                    string accountName       = args.NextString();
                    string email             = args.NextString();
                    string emailConfirmation = args.NextString();

                    if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emailConfirmation))
                    {
                        handler.SendSysMessage(CypherStrings.CmdSyntax);
                        return(false);
                    }

                    uint targetAccountId = Global.AccountMgr.GetId(accountName);

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

                    // can set email only for target with less security
                    // This also restricts setting handler's own email.
                    if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                    {
                        return(false);
                    }

                    if (!email.Equals(emailConfirmation))
                    {
                        handler.SendSysMessage(CypherStrings.NewEmailsNotMatch);
                        return(false);
                    }

                    AccountOpResult result = Global.AccountMgr.ChangeRegEmail(targetAccountId, email);

                    switch (result)
                    {
                    case AccountOpResult.Ok:
                        handler.SendSysMessage(CypherStrings.CommandEmail);
                        Log.outInfo(LogFilter.Player, "ChangeRegEmail: Account {0} [Id: {1}] had it's Registration Email changed to {2}.", accountName, targetAccountId, email);
                        break;

                    case AccountOpResult.NameNotExist:
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);

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

                    default:
                        handler.SendSysMessage(CypherStrings.CommandNotchangeemail);
                        return(false);
                    }

                    return(true);
                }
Пример #21
0
        static bool HandleWpAddCommand(StringArguments args, CommandHandler handler)
        {
            // optional
            string path_number = null;
            uint   pathid;

            if (!args.Empty())
            {
                path_number = args.NextString();
            }

            uint     point  = 0;
            Creature target = handler.GetSelectedCreature();

            PreparedStatement stmt;

            if (string.IsNullOrEmpty(path_number))
            {
                if (target)
                {
                    pathid = target.GetWaypointPath();
                }
                else
                {
                    stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_ID);
                    SQLResult result1 = DB.World.Query(stmt);

                    uint maxpathid = result1.Read <uint>(0);
                    pathid = maxpathid + 1;
                    handler.SendSysMessage("|cff00ff00New path started.|r");
                }
            }
            else
            {
                if (!uint.TryParse(path_number, out pathid))
                {
                    return(false);
                }
            }

            // path_id . ID of the Path
            // point   . number of the waypoint (if not 0)

            if (pathid == 0)
            {
                handler.SendSysMessage("|cffff33ffCurrent creature haven't loaded path.|r");
                return(true);
            }

            stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_POINT);
            stmt.AddValue(0, pathid);
            SQLResult result = DB.World.Query(stmt);

            if (result.IsEmpty())
            {
                point = result.Read <uint>(0);
            }

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

            stmt = DB.World.GetPreparedStatement(WorldStatements.INS_WAYPOINT_DATA);
            stmt.AddValue(0, pathid);
            stmt.AddValue(1, point + 1);
            stmt.AddValue(2, player.GetPositionX());
            stmt.AddValue(3, player.GetPositionY());
            stmt.AddValue(4, player.GetPositionZ());

            DB.World.Execute(stmt);

            handler.SendSysMessage("|cff00ff00PathID: |r|cff00ffff{0} |r|cff00ff00: Waypoint |r|cff00ffff{1}|r|cff00ff00 created.|r", pathid, point + 1);
            return(true);
        }
Пример #22
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);
            }

            string createGameAccountParam = args.NextString();
            bool   createGameAccount      = true;

            if (!string.IsNullOrEmpty(createGameAccountParam))
            {
                createGameAccount = bool.Parse(createGameAccountParam);
            }

            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);
        }
Пример #23
0
        static bool HandleWpModifyCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // first arg: add del text emote spell waittime move
            string show = args.NextString();

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

            // Check
            // Remember: "show" must also be the name of a column!
            if ((show != "delay") && (show != "action") && (show != "action_chance") &&
                (show != "move_flag") && (show != "del") && (show != "move"))
            {
                return(false);
            }

            // Did user provide a GUID
            // or did the user select a creature?
            // . variable lowguid is filled with the GUID of the NPC
            uint     pathid;
            uint     point;
            Creature target = handler.GetSelectedCreature();

            // User did select a visual waypoint?
            if (!target || target.GetEntry() != 1)
            {
                handler.SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
                return(false);
            }

            // Check the creature
            PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_WPGUID);

            stmt.AddValue(0, target.GetSpawnId());
            SQLResult result = DB.World.Query(stmt);

            if (result.IsEmpty())
            {
                handler.SendSysMessage(CypherStrings.WaypointNotfoundsearch, target.GetGUID().ToString());
                // Select waypoint number from database
                // Since we compare float values, we have to deal with
                // some difficulties.
                // Here we search for all waypoints that only differ in one from 1 thousand
                // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
                string maxDiff = "0.01";

                stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_POS);
                stmt.AddValue(0, target.GetPositionX());
                stmt.AddValue(1, maxDiff);
                stmt.AddValue(2, target.GetPositionY());
                stmt.AddValue(3, maxDiff);
                stmt.AddValue(4, target.GetPositionZ());
                stmt.AddValue(5, maxDiff);
                result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage(CypherStrings.WaypointNotfounddbproblem, target.GetGUID().ToString());
                    return(true);
                }
            }

            do
            {
                pathid = result.Read <uint>(0);
                point  = result.Read <uint>(1);
            }while (result.NextRow());

            // We have the waypoint number and the GUID of the "master npc"
            // Text is enclosed in "<>", all other arguments not
            string arg_str = args.NextString();

            // Check for argument
            if (show != "del" && show != "move" && arg_str == null)
            {
                handler.SendSysMessage(CypherStrings.WaypointArgumentreq, show);
                return(false);
            }

            if (show == "del")
            {
                handler.SendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff{0}|r", pathid);

                target.DeleteFromDB();
                target.AddObjectToRemoveList();

                stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_WAYPOINT_DATA);
                stmt.AddValue(0, pathid);
                stmt.AddValue(1, point);
                DB.World.Execute(stmt);

                stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_POINT);
                stmt.AddValue(0, pathid);
                stmt.AddValue(1, point);
                DB.World.Execute(stmt);

                handler.SendSysMessage(CypherStrings.WaypointRemoved);
                return(true);
            }                                                       // del

            if (show == "move")
            {
                handler.SendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff{0}|r", pathid);

                Player chr = handler.GetSession().GetPlayer();
                Map    map = chr.GetMap();
                // What to do:
                // Move the visual spawnpoint
                // Respawn the owner of the waypoints
                target.DeleteFromDB();
                target.AddObjectToRemoveList();

                // re-create
                Creature creature = Creature.CreateCreature(1, map, chr.GetPosition());
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
                    return(false);
                }

                PhasingHandler.InheritPhaseShift(creature, chr);
                creature.SaveToDB(map.GetId(), new List <Difficulty>()
                {
                    map.GetDifficultyID()
                });

                ulong dbGuid = creature.GetSpawnId();

                // current "wpCreature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
                creature.CleanupsBeforeDelete();
                creature.Dispose();

                // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
                creature = Creature.CreateCreatureFromDB(dbGuid, map);
                if (!creature)
                {
                    handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
                    return(false);
                }

                stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION);
                stmt.AddValue(0, chr.GetPositionX());
                stmt.AddValue(1, chr.GetPositionY());
                stmt.AddValue(2, chr.GetPositionZ());
                stmt.AddValue(3, pathid);
                stmt.AddValue(4, point);
                DB.World.Execute(stmt);

                handler.SendSysMessage(CypherStrings.WaypointChanged);

                return(true);
            }                                                     // move

            if (string.IsNullOrEmpty(arg_str))
            {
                // show_str check for present in list of correct values, no sql injection possible
                DB.World.Execute("UPDATE waypoint_data SET {0}=null WHERE id='{1}' AND point='{2}'", show, pathid, point); // Query can't be a prepared statement
            }
            else
            {
                // show_str check for present in list of correct values, no sql injection possible
                DB.World.Execute("UPDATE waypoint_data SET {0}='{1}' WHERE id='{2}' AND point='{3}'", show, arg_str, pathid, point); // Query can't be a prepared statement
            }

            handler.SendSysMessage(CypherStrings.WaypointChangedNo, show);
            return(true);
        }
Пример #24
0
        static bool HandleBanHelper(BanMode mode, StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string nameOrIP = args.NextString();

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

            string durationStr = args.NextString();

            if (!uint.TryParse(durationStr, out uint duration))
            {
                return(false);
            }

            string reasonStr = args.NextString("");

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

            switch (mode)
            {
            case BanMode.Character:
                if (!ObjectManager.NormalizePlayerName(ref nameOrIP))
                {
                    handler.SendSysMessage(CypherStrings.PlayerNotFound);
                    return(false);
                }
                break;

            case BanMode.IP:
                IPAddress address;
                if (!IPAddress.TryParse(nameOrIP, out address))
                {
                    return(false);
                }
                break;
            }

            string author = handler.GetSession() ? handler.GetSession().GetPlayerName() : "Server";

            switch (Global.WorldMgr.BanAccount(mode, nameOrIP, durationStr, reasonStr, author))
            {
            case BanReturn.Success:
                if (!uint.TryParse(durationStr, out uint tempValue) || tempValue > 0)
                {
                    if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
                    {
                        Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoubannedmessageWorld, author, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr)), reasonStr);
                    }
                    else
                    {
                        handler.SendSysMessage(CypherStrings.BanYoubanned, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr), true), reasonStr);
                    }
                }
                else
                {
                    if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
                    {
                        Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoupermbannedmessageWorld, author, nameOrIP, reasonStr);
                    }
                    else
                    {
                        handler.SendSysMessage(CypherStrings.BanYoupermbanned, nameOrIP, reasonStr);
                    }
                }
                break;

            case BanReturn.SyntaxError:
                return(false);

            case BanReturn.Notfound:
                switch (mode)
                {
                default:
                    handler.SendSysMessage(CypherStrings.BanNotfound, "account", nameOrIP);
                    break;

                case BanMode.Character:
                    handler.SendSysMessage(CypherStrings.BanNotfound, "character", nameOrIP);
                    break;

                case BanMode.IP:
                    handler.SendSysMessage(CypherStrings.BanNotfound, "ip", nameOrIP);
                    break;
                }
                return(false);

            case BanReturn.Exists:
                handler.SendSysMessage(CypherStrings.BanExists);
                break;
            }

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

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

            // 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);
            }

            float x, y, z, o;
            uint  mapId;

            // by DB guid
            GameObjectData goData = Global.ObjectMgr.GetGOData(guidLow);

            if (goData != null)
            {
                x     = goData.posX;
                y     = goData.posY;
                z     = goData.posZ;
                o     = goData.orientation;
                mapId = goData.mapid;
            }
            else
            {
                handler.SendSysMessage(CypherStrings.CommandGoobjnotfound);
                return(false);
            }

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

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

            player.TeleportTo(mapId, x, y, z, o);
            return(true);
        }
Пример #26
0
        static bool HandleBanCharacterCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string name = args.NextString();

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

            string durationStr = args.NextString();

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

            if (!uint.TryParse(durationStr, out uint duration))
            {
                return(false);
            }

            string reasonStr = args.NextString("");

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

            if (!ObjectManager.NormalizePlayerName(ref name))
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            string author = handler.GetSession() != null?handler.GetSession().GetPlayerName() : "Server";

            switch (Global.WorldMgr.BanCharacter(name, durationStr, reasonStr, author))
            {
            case BanReturn.Success:
            {
                if (duration > 0)
                {
                    if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
                    {
                        Global.WorldMgr.SendWorldText(CypherStrings.BanCharacterYoubannedmessageWorld, author, name, Time.secsToTimeString(Time.TimeStringToSecs(durationStr), true), reasonStr);
                    }
                    else
                    {
                        handler.SendSysMessage(CypherStrings.BanYoubanned, name, Time.secsToTimeString(Time.TimeStringToSecs(durationStr), true), reasonStr);
                    }
                }
                else
                {
                    if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
                    {
                        Global.WorldMgr.SendWorldText(CypherStrings.BanCharacterYoupermbannedmessageWorld, author, name, reasonStr);
                    }
                    else
                    {
                        handler.SendSysMessage(CypherStrings.BanYoupermbanned, name, reasonStr);
                    }
                }
                break;
            }

            case BanReturn.Notfound:
            {
                handler.SendSysMessage(CypherStrings.BanNotfound, "character", name);
                return(false);
            }

            default:
                break;
            }

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

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

            // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
            string param1 = handler.extractKeyFromLink(args, "Hcreature", "Hcreature_entry");

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

            string whereClause = "";

            // User wants to teleport to the NPC's template entry
            if (param1.IsNumber())
            {
                if (!int.TryParse(param1, out int entry) || entry == 0)
                {
                    if (!ulong.TryParse(param1, out ulong guidLow) || guidLow == 0)
                    {
                        return(false);
                    }

                    whereClause += "WHERE guid = '" + guidLow + '\'';
                }
                else
                {
                    whereClause += "WHERE id = '" + entry + '\'';
                }
            }
            else
            {
                // param1 is not a number, must be mob's name
                whereClause += ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name LIKE '" + param1 + '\'';
            }

            SQLResult result = DB.World.Query("SELECT position_x, position_y, position_z, orientation, map FROM creature {0}", whereClause);

            if (result.IsEmpty())
            {
                handler.SendSysMessage(CypherStrings.CommandGocreatnotfound);
                return(false);
            }

            float x     = result.Read <float>(0);
            float y     = result.Read <float>(1);
            float z     = result.Read <float>(2);
            float o     = result.Read <float>(3);
            uint  mapId = result.Read <ushort>(4);

            if (result.NextRow())
            {
                handler.SendSysMessage(CypherStrings.CommandGocreatmultiple);
            }

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

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

            player.TeleportTo(mapId, x, y, z, o);

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

            string filter = args.NextString();

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

            PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUID_BY_NAME_FILTER);

            stmt.AddValue(0, filter);
            SQLResult result = DB.Characters.Query(stmt);

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

            handler.SendSysMessage(CypherStrings.BanlistMatchingcharacter);

            // Chat short output
            if (handler.GetSession())
            {
                do
                {
                    PreparedStatement stmt2 = DB.Characters.GetPreparedStatement(CharStatements.SEL_BANNED_NAME);
                    stmt2.AddValue(0, result.Read <ulong>(0));
                    SQLResult banResult = DB.Characters.Query(stmt2);
                    if (!banResult.IsEmpty())
                    {
                        handler.SendSysMessage(banResult.Read <string>(0));
                    }
                }while (result.NextRow());
            }
            // Console wide output
            else
            {
                handler.SendSysMessage(CypherStrings.BanlistCharacters);
                handler.SendSysMessage(" =============================================================================== ");
                handler.SendSysMessage(CypherStrings.BanlistCharactersHeader);
                do
                {
                    handler.SendSysMessage("-------------------------------------------------------------------------------");

                    string char_name = result.Read <string>(1);

                    PreparedStatement stmt2 = DB.Characters.GetPreparedStatement(CharStatements.SEL_BANINFO_LIST);
                    stmt2.AddValue(0, result.Read <ulong>(0));
                    SQLResult banInfo = DB.Characters.Query(stmt2);
                    if (!banInfo.IsEmpty())
                    {
                        do
                        {
                            long     timeBan   = banInfo.Read <uint>(0);
                            DateTime tmBan     = Time.UnixTimeToDateTime(timeBan);
                            string   bannedby  = banInfo.Read <string>(2).Substring(0, 15);
                            string   banreason = banInfo.Read <string>(3).Substring(0, 15);

                            if (banInfo.Read <uint>(0) == banInfo.Read <uint>(1))
                            {
                                handler.SendSysMessage("|{0}|{1:D2}-{2:D2}-{3:D2} {4:D2}:{5:D2}|   permanent  |{6}|{7}|",
                                                       char_name, tmBan.Year % 100, tmBan.Month + 1, tmBan.Day, tmBan.Hour, tmBan.Minute,
                                                       bannedby, banreason);
                            }
                            else
                            {
                                long     timeUnban = banInfo.Read <uint>(1);
                                DateTime tmUnban   = Time.UnixTimeToDateTime(timeUnban);
                                handler.SendSysMessage("|{0}|{1:D2}-{2:D2}-{3:D2} {4:D2}:{5:D2}|{6:D2}-{7:D2}-{8:D2} {9:D2}:{10:D2}|{11}|{12}|",
                                                       char_name, tmBan.Year % 100, tmBan.Month + 1, tmBan.Day, tmBan.Hour, tmBan.Minute,
                                                       tmUnban.Year % 100, tmUnban.Month + 1, tmUnban.Day, tmUnban.Hour, tmUnban.Minute,
                                                       bannedby, banreason);
                            }
                        }while (banInfo.NextRow());
                    }
                }while (result.NextRow());
                handler.SendSysMessage(" =============================================================================== ");
            }

            return(true);
        }
Пример #29
0
        static bool HandleGoXYZCommand(StringArguments args, CommandHandler handler)
        {
            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);
            }

            string goZ = args.NextString();

            if (!uint.TryParse(args.NextString(), out uint mapId))
            {
                mapId = player.GetMapId();
            }

            if (!float.TryParse(args.NextString(), out float ort))
            {
                ort = player.GetOrientation();
            }

            float z;

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

                if (!GridDefines.IsValidMapCoord(mapId, x, y, z))
                {
                    handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, mapId);
                    return(false);
                }
            }
            else
            {
                if (!GridDefines.IsValidMapCoord(mapId, x, y))
                {
                    handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, mapId);
                    return(false);
                }
                Map map = Global.MapMgr.CreateBaseMap(mapId);
                z = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));
            }

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

            player.TeleportTo(mapId, x, y, z, ort);
            return(true);
        }
Пример #30
0
        static bool Faction(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string pfactionid = handler.extractKeyFromLink(args, "Hfaction");

            Creature target = handler.getSelectedCreature();

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

            if (string.IsNullOrEmpty(pfactionid))
            {
                uint  _factionid = target.getFaction();
                uint  _flag      = target.GetUInt32Value(UnitFields.Flags);
                ulong _npcflag   = target.GetUInt64Value(UnitFields.NpcFlags);
                uint  _dyflag    = target.GetUInt32Value(ObjectFields.DynamicFlags);
                handler.SendSysMessage(CypherStrings.CurrentFaction, target.GetGUID().ToString(), _factionid, _flag, _npcflag, _dyflag);
                return(true);
            }

            uint factionid = uint.Parse(pfactionid);
            uint flag;

            string pflag = args.NextString();

            if (string.IsNullOrEmpty(pflag))
            {
                flag = target.GetUInt32Value(UnitFields.Flags);
            }
            else
            {
                flag = uint.Parse(pflag);
            }

            string pnpcflag = args.NextString();

            ulong npcflag;

            if (string.IsNullOrEmpty(pnpcflag))
            {
                npcflag = target.GetUInt64Value(UnitFields.NpcFlags);
            }
            else
            {
                npcflag = ulong.Parse(pnpcflag);
            }

            string pdyflag = args.NextString();

            uint dyflag;

            if (string.IsNullOrEmpty(pdyflag))
            {
                dyflag = target.GetUInt32Value(ObjectFields.DynamicFlags);
            }
            else
            {
                dyflag = uint.Parse(pdyflag);
            }

            if (!CliDB.FactionTemplateStorage.ContainsKey(factionid))
            {
                handler.SendSysMessage(CypherStrings.WrongFaction, factionid);

                return(false);
            }

            handler.SendSysMessage(CypherStrings.YouChangeFaction, target.GetGUID().ToString(), factionid, flag, npcflag, dyflag);

            target.SetFaction(factionid);
            target.SetUInt32Value(UnitFields.Flags, flag);
            target.SetUInt64Value(UnitFields.NpcFlags, npcflag);
            target.SetUInt32Value(ObjectFields.DynamicFlags, dyflag);

            return(true);
        }