Exemplo n.º 1
0
        public static bool Fly(string[] args, CommandGroup command)
        {
            if (args.Count() < 1)
            {
                return(false);
            }

            Player target = command.getSelectedPlayer();

            if (target == null)
            {
                target = command.GetSession().GetPlayer();
            }

            if (args[0].ToLower() == "on")
            {
                target.SendMovementSetCanFly(true);
            }
            else if (args[0].ToLower() == "off")
            {
                target.SendMovementSetCanFly(false);
            }
            else
            {
                return(command.SendSysMessage("Use [on|off]"));
            }

            command.SendSysMessage(CypherStrings.CommandFlymodeStatus, command.GetNameLink(target), args);
            return(true);
        }
Exemplo n.º 2
0
        public static bool HandleModifyMoneyCommand(string[] args, CommandGroup handler)
        {
            if (args.Count() < 1)
                return false;

            Player target = handler.getSelectedPlayer();
            if (target == null)
                return handler.SendErrorMessage(CypherStrings.NoCharSelected);

            // check online security
            if (handler.HasLowerSecurity(target, 0))
                return false;

            long addmoney;
            long.TryParse(args[0], out addmoney);

            long moneyuser = (long)target.GetMoney();

            if (addmoney < 0)
            {
                ulong newmoney = (ulong)(moneyuser + addmoney);

                Log.outDebug(ObjMgr.GetCypherString(CypherStrings.CurrentMoney), moneyuser, addmoney, newmoney);
                if (newmoney <= 0)
                {
                    handler.SendSysMessage(CypherStrings.YouTakeAllMoney, handler.GetNameLink(target));
                    if (handler.needReportToTarget(target))
                       ChatHandler.SendSysMessage(target, CypherStrings.YoursAllMoneyGone, handler.GetNameLink());

                    target.SetMoney(0);
                }
                else
                {
                    if (newmoney > PlayerConst.MaxMoneyAmount)
                        newmoney = PlayerConst.MaxMoneyAmount;

                    handler.SendSysMessage(CypherStrings.YouTakeMoney, Math.Abs(addmoney), handler.GetNameLink(target));
                    if (handler.needReportToTarget(target))
                        ChatHandler.SendSysMessage(target, CypherStrings.YoursMoneyTaken, handler.GetNameLink(), Math.Abs(addmoney));
                    target.SetMoney(newmoney);
                }
            }
            else
            {
                handler.SendSysMessage( CypherStrings.YouGiveMoney, addmoney, handler.GetNameLink(target));
                if (handler.needReportToTarget(target))
                    ChatHandler.SendSysMessage(target, CypherStrings.YoursMoneyGiven, handler.GetNameLink(), addmoney);

                if (addmoney >= PlayerConst.MaxMoneyAmount)
                    target.SetMoney(PlayerConst.MaxMoneyAmount);
                else
                    target.ModifyMoney(addmoney);
            }

            Log.outDebug(ObjMgr.GetCypherString(CypherStrings.NewMoney), moneyuser, addmoney, target.GetMoney());
            return true;
        }
Exemplo n.º 3
0
        public static bool HandleModifyLevelCommand(string[] args, CommandGroup cmd)
        {
            if (args.Count() < 1)
                return false;

            Player target;
            int level;

            if (!cmd.extractPlayerTarget(args[0], out target))
                return cmd.SendErrorMessage(CypherStrings.PlayerNotFound);

            int.TryParse(args[0] == "\"" ? args[1] : args[0], out level);

            int oldlevel = (int)(target != null ? target.getLevel() : 0);//Player::GetLevelFromDB(targetGuid);
            int newlevel = level != 0 ? level : oldlevel;

            if (newlevel < 1)
                return true;

            if (newlevel > 255)
                newlevel = 255;

            if (cmd.GetSession().GetPlayer() != target)
                target.SendNotification(CypherStrings.YouChangeLvl, cmd.GetNameLink(target), newlevel);

            if (target != null)
            {
                target.GiveLevel((uint)newlevel);
                //player->InitTalentForLevel();
                target.SetValue<uint>(PlayerFields.XP, 0);

                if (oldlevel == newlevel)
                    cmd.SendSysMessage(CypherStrings.YoursLevelProgressReset, cmd.GetNameLink(target));
                else if (oldlevel < newlevel)
                    cmd.SendSysMessage(CypherStrings.YoursLevelUp, cmd.GetNameLink(target), newlevel);
                else
                    cmd.SendSysMessage(CypherStrings.YoursLevelDown, cmd.GetNameLink(target), newlevel);
            }
            else
            {
                // Update level and reset XP, everything else will be updated at login
                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_UPD_LEVEL);
                stmt.AddValue(0, (byte)newlevel);
                stmt.AddValue(1, target.GetGUIDLow());
                DB.Characters.Execute(stmt);                
            }
            return true;
        }
Exemplo n.º 4
0
            public static bool HandleNpcSetFlagCommand(string[] args, CommandGroup cmd)
            {
                if (args.Count() < 1)
                {
                    return(false);
                }

                uint npcFlags;

                uint.TryParse(args[0], out npcFlags);

                Creature creature = cmd.GetSession().GetPlayer().GetSelection <Creature>();

                if (creature == null)
                {
                    return(cmd.SendErrorMessage(CypherStrings.SelectCreature));
                }

                creature.SetValue <uint>(UnitFields.NpcFlags, npcFlags);

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

                stmt.AddValue(0, npcFlags);
                stmt.AddValue(1, creature.GetEntry());
                DB.World.Execute(stmt);

                return(cmd.SendSysMessage(CypherStrings.ValueSavedRejoin));
            }
Exemplo n.º 5
0
        public static bool HandleModifyASpeedCommand(string[] args, CommandGroup cmd)
        {
            if (args.Count() < 1)
                return false;

            float ASpeed;
            float.TryParse(args[0], out ASpeed);

            if (ASpeed > 50.0f || ASpeed < 0.1f)
                return cmd.SendErrorMessage(CypherStrings.BadValue);

            Player target = cmd.GetSession().GetPlayer().GetSelection<Player>();
            if (target == null)
                return cmd.SendErrorMessage(CypherStrings.NoCharSelected);

            string targetNameLink = cmd.GetNameLink(target);

            //if (target.isInFlight())
            {
                //chat.PSendSysMessage(LANG_CHAR_IN_FLIGHT, targetNameLink.c_str());
                //return false;
            }

            if (target != cmd.GetSession().GetPlayer())
                target.SendNotification(CypherStrings.YoursAspeedChanged, cmd.GetNameLink(target), ASpeed);

            target.SetSpeed(UnitMoveType.Walk,    ASpeed, true);
            target.SetSpeed(UnitMoveType.Run,     ASpeed, true);
            target.SetSpeed(UnitMoveType.Swim,    ASpeed, true);
            target.SetSpeed(UnitMoveType.Flight,     ASpeed, true);
            return cmd.SendSysMessage(CypherStrings.YouChangeAspeed, ASpeed, target.GetName());
        }
Exemplo n.º 6
0
        public static bool HandleNpcInfoCommand(string[] args, CommandGroup cmd)
        {
            Creature target = cmd.GetSession().GetPlayer().GetSelection <Creature>();

            if (target == null)
            {
                return(cmd.SendErrorMessage(CypherStrings.SelectCreature));
            }

            uint     faction   = target.GetCreatureTemplate().FactionA;
            NPCFlags npcflags  = (NPCFlags)target.GetValue <uint>((int)UnitFields.NpcFlags);
            uint     displayid = target.GetCreatureTemplate().ModelId[0];
            uint     nativeid  = target.GetCreatureTemplate().ModelId[0];
            uint     Entry     = target.GetEntry();

            //CreatureTemplate const* cInfo = target->GetCreatureTemplate();

            //ulong curRespawnDelay = target.->GetRespawnTimeEx()-time(NULL);
            //if (curRespawnDelay < 0)
            //curRespawnDelay = 0;
            //std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
            //std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);

            cmd.SendSysMessage(CypherStrings.NpcinfoChar, target.GetGUIDLow(), target.GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid);
            cmd.SendSysMessage(CypherStrings.NpcinfoLevel, target.GetCreatureTemplate().Maxlevel);
            //cmd.SendSysMessage(CypherStrings.NPCINFO_HEALTH, target.CurHealth);
            //cmd.SendSysMessage(CypherStrings.NPCINFO_FLAGS, target.GetValue<uint>((int)UnitFields.Flags), target.GetValue<uint>((int)UnitFields.DynamicFlags), target.Template.FactionA);
            //cmd.SendSysMessage(CypherStrings.COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
            //cmd.SendSysMessage(CypherStrings.NPCINFO_LOOT,  cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
            //cmd.SendSysMessage(CypherStrings.NPCINFO_DUNGEON_ID, target->GetInstanceId());
            //cmd.SendSysMessage(CypherStrings.NPCINFO_PHASEMASK, target->GetPhaseMask());
            //cmd.SendSysMessage(CypherStrings.NPCINFO_ARMOR, target->GetArmor());
            cmd.SendSysMessage(CypherStrings.NpcinfoPosition, target.Position.X, target.Position.Y, target.Position.Z);
            //cmd.SendSysMessage(CypherStrings.NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());

            if (Convert.ToBoolean(npcflags & NPCFlags.Vendor))
            {
                cmd.SendSysMessage(CypherStrings.NpcinfoVendor);
            }

            if (Convert.ToBoolean(npcflags & NPCFlags.Trainer))
            {
                cmd.SendSysMessage(CypherStrings.NpcinfoTrainer);
            }

            return(true);
        }
Exemplo n.º 7
0
        public static bool Create(string[] args, CommandGroup command)
        {
            if (args.Length < 2)
            {
                return(false);
            }

            var accountName = args[0].ToUpper();
            var password    = args[1];

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

            if (!accountName.Contains("@"))
            {
                return(command.SendErrorMessage("Account name requires an email address"));
            }

            if (accountName.Length > 16)
            {
                return(command.SendErrorMessage(CypherStrings.TooLongName));
            }

            PreparedStatement stmt = DB.Auth.GetPreparedStatement(LoginStatements.Get_AccountIDByUsername);

            stmt.AddValue(0, accountName);
            SQLResult result = DB.Auth.Select(stmt);

            if (result.Count != 0)
            {
                return(command.SendSysMessage(CypherStrings.AccountAlreadyExist, accountName));
            }

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Ins_Account);
            stmt.AddValue(0, accountName);
            stmt.AddValue(1, SRP6.GenerateCredentialsHash(accountName, password).ToHexString());
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Ins_RealmCharactersInit);
            DB.Auth.Execute(stmt);

            return(command.SendSysMessage(CypherStrings.AccountCreated, accountName));
        }
Exemplo n.º 8
0
        public static bool Delete(string[] args, CommandGroup command)
        {
            if (args.Length < 1)
            {
                return(false);
            }

            string account = args[0];

            if (account == string.Empty)
            {
                return(false);
            }

            if (!account.Contains("@"))
            {
                return(command.SendSysMessage("Account name requires an email address"));
            }

            PreparedStatement stmt = DB.Auth.GetPreparedStatement(LoginStatements.Get_AccountIDByUsername);

            stmt.AddValue(0, account);
            SQLResult result = DB.Auth.Select(stmt);


            if (result.Count == 0)
            {
                command.SendErrorMessage(CypherStrings.AccountNotExist, account);
            }

            uint accountId = result.Read <uint>(0, 0);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_SEL_CHARS_BY_ACCOUNT_ID);
            stmt.AddValue(0, accountId);
            result = DB.Characters.Select(stmt);

            if (result.Count != 0)
            {
                for (var i = 0; i < result.Count; i++)
                {
                    uint guidLow = result.Read <uint>(i, 0);

                    // Kick if player is online
                    Player pl = ObjMgr.FindPlayer(guidLow);
                    if (pl != null)
                    {
                        WorldSession s = pl.GetSession();
                        s.KickPlayer();                            // mark session to remove at next session list update
                        //s.LogoutPlayer(false);                     // logout player without waiting next session list update
                    }

                    //Player::DeleteFromDB(guid, accountId, false);       // no need to update realm characters todo fixme
                }
            }

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_TUTORIALS);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_ACCOUNT_DATA);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_CHARACTER_BAN);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_Account);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_account_access);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_RealmCharacters);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_AccountBanned);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            return(command.SendSysMessage(CypherStrings.AccountDeleted, account));
        }
Exemplo n.º 9
0
            public static bool SetGMLevel(string[] args, CommandGroup command)
            {
                if (args.Length < 3)
                {
                    return(false);
                }

                string targetAccountName = "";
                uint   targetAccountId   = 0;
                uint   targetSecurity    = 0;
                uint   gm   = 0;
                string arg1 = args[0];
                string arg2 = args[1];
                string arg3 = args[2];
                bool   isAccountNameGiven = true;

                if (!string.IsNullOrEmpty(arg1) && string.IsNullOrEmpty(arg3))
                {
                    if (command.getSelectedPlayer() == null)
                    {
                        return(false);
                    }
                    isAccountNameGiven = false;
                }

                // Check for second parameter
                if (!isAccountNameGiven && !string.IsNullOrEmpty(arg2))
                {
                    return(false);
                }

                // Check for account
                if (isAccountNameGiven)
                {
                    targetAccountName = arg1;
                    if (!targetAccountName.IsNormalized())//need checked
                    {
                        command.SendErrorMessage(CypherStrings.AccountNotExist, targetAccountName);
                        return(false);
                    }
                }

                // Check for invalid specified GM level.
                gm = isAccountNameGiven ? uint.Parse(arg2) : uint.Parse(arg1);
                if (gm > (uint)AccountTypes.Console)
                {
                    command.SendErrorMessage(CypherStrings.BadValue);
                    return(false);
                }

                // handler->getSession() == NULL only for console
                targetAccountId = (isAccountNameGiven) ? AcctMgr.GetId(targetAccountName) : command.getSelectedPlayer().GetSession().GetAccountId();
                int  gmRealmID = (isAccountNameGiven) ? int.Parse(arg3) : int.Parse(arg2);
                uint playerSecurity;

                if (command.GetSession() != null)
                {
                    playerSecurity = AcctMgr.GetSecurity(command.GetSession().GetAccountId(), gmRealmID);
                }
                else
                {
                    playerSecurity = (uint)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 = AcctMgr.GetSecurity(targetAccountId, gmRealmID);
                if (targetSecurity >= playerSecurity || gm >= playerSecurity)
                {
                    command.SendErrorMessage(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 && !AcctMgr.IsConsoleAccount((AccountTypes)playerSecurity))
                {
                    stmt = DB.Auth.GetPreparedStatement(LoginStatements.Sel_account_accessGMLevelTest);
                    stmt.AddValue(0, targetAccountId);
                    stmt.AddValue(1, gm);

                    SQLResult result = DB.Auth.Select(stmt);

                    if (result.Count > 0)
                    {
                        command.SendErrorMessage(CypherStrings.YoursSecurityIsLow);
                        return(false);
                    }
                }

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

                // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
                if (gmRealmID == -1)
                {
                    stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_account_access);
                    stmt.AddValue(0, targetAccountId);
                }
                else
                {
                    stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_account_accessByRealm);

                    stmt.AddValue(0, targetAccountId);
                    stmt.AddValue(1, WorldConfig.RealmId);
                }
                DB.Auth.Execute(stmt);

                if (gm != 0)
                {
                    stmt = DB.Auth.GetPreparedStatement(LoginStatements.Ins_account_access);

                    stmt.AddValue(0, targetAccountId);
                    stmt.AddValue(1, gm);
                    stmt.AddValue(2, gmRealmID);

                    DB.Auth.Execute(stmt);
                }
                command.SendSysMessage(CypherStrings.YouChangeSecurity, targetAccountName, gm);
                return(true);
            }