示例#1
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());
        }
示例#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;
        }
示例#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;
        }
示例#4
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);
        }