Exemplo n.º 1
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            uint id = 0;

            if (client.Version >= GameClient.eClientVersion.Version1126)
            {
                id = packet.ReadIntLowEndian();
            }
            else
            {
                id = packet.ReadShort();
            }
            GameClient target = WorldMgr.GetClientFromID(id);

            if (target == null)
            {
                log.Warn($"Client {client.SessionID}:{client.TcpEndpointAddress} account {client.Account?.Name ?? "null"} requested invalid client {id} --- disconnecting");

                client.Disconnect();
                return;
            }

            // DOLConsole.WriteLine("player creation request "+target.Player.Name);
            if (target.IsPlaying && target.Player != null && target.Player.ObjectState == GameObject.eObjectState.Active)
            {
                client.Out.SendPlayerCreate(target.Player);
                client.Out.SendLivingEquipmentUpdate(target.Player);
            }
        }
Exemplo n.º 2
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            GameClient clientc = null;

            if (args[1].StartsWith("#"))
            {
                try
                {
                    int sessionID = Convert.ToInt32(args[1].Substring(1));
                    clientc = WorldMgr.GetClientFromID(sessionID);
                }
                catch
                {
                    DisplayMessage(client, "Invalid client ID");
                }
            }
            else
            {
                clientc = WorldMgr.GetClientByPlayerName(args[1], false, false);
            }

            if (clientc == null)
            {
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Kick.NoPlayerOnLine"));
                return;
            }

            if (client.Account.PrivLevel < clientc.Account.PrivLevel)
            {
                DisplayMessage(client, "Your privlevel is not high enough to kick this player.");
                return;
            }

            for (int i = 0; i < 8; i++)
            {
                string message;
                if (client != null && client.Player != null)
                {
                    message = LanguageMgr.GetTranslation(clientc, "GMCommands.Kick.RemovedFromServerByGM", client.Player.Name);
                }
                else
                {
                    message = LanguageMgr.GetTranslation(clientc, "GMCommands.Kick.RemovedFromServer");
                }

                clientc.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_SystemWindow);
                clientc.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_ChatWindow);
            }

            clientc.Out.SendPlayerQuit(true);
            clientc.Player.SaveIntoDatabase();
            clientc.Player.Quit(true);
        }
Exemplo n.º 3
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            ushort     id     = packet.ReadShort();
            GameClient target = WorldMgr.GetClientFromID(id);

            if (target == null)
            {
                if (Log.IsWarnEnabled)
                {
                    Log.Warn($"Client {client.SessionID}:{client.TcpEndpointAddress} account {(client.Account == null ? "null" : client.Account.Name)} requested invalid client {id} --- disconnecting");
                }

                client.Disconnect();
                return;
            }

            // DOLConsole.WriteLine("player creation request "+target.Player.Name);
            if (target.IsPlaying && target.Player != null && target.Player.ObjectState == GameObject.eObjectState.Active)
            {
                client.Out.SendPlayerCreate(target.Player);
                client.Out.SendLivingEquipmentUpdate(target.Player);
            }
        }
Exemplo n.º 4
0
        public void OnCommand(GameClient client, string[] args)
        {
            try
            {
                #region Refresh
                if (args.Length == 2 && args[1].ToLower() == "refresh")
                {
                    client.Player.LeaveHouse();
                    client.Player.RefreshWorld();
                    return;
                }
                #endregion Refresh
                #region Jump to GT
                if (args.Length == 3 && args[1].ToLower() == "to" && args[2].ToLower() == "gt")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, client.Player.GroundTarget.X, client.Player.GroundTarget.Y, client.Player.GroundTarget.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump to GT
                #region Jump to house
                else if (args.Length >= 3 && args[1].ToLower() == "to" && (args[2].ToLower() == "house" || args[2].ToLower() == "myhouse"))
                {
                    House house = null;
                    if (args[2] == "myhouse")
                    {
                        house = HouseMgr.GetHouseByPlayer(client.Player);
                    }
                    else
                    {
                        house = HouseMgr.GetHouse(Convert.ToInt32(args[3]));
                    }
                    if (house != null)
                    {
                        client.Player.MoveTo(house.OutdoorJumpPoint);
                    }
                    else
                    {
                        client.Out.SendMessage("This house number is not owned by anyone!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                    return;
                }
                #endregion Jump to house
                #region Jump t region #
                if (args.Length == 4 && args[1] == "to" && args[2] == "region")
                {
                    client.Player.MoveTo(Convert.ToUInt16(args[3]), client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump t region #
                #region Jump to PlayerName or ClientID
                if (args.Length == 3 && args[1] == "to")
                {
                    GameClient clientc = null;
                    if (args[2].StartsWith("#"))
                    {
                        try
                        {
                            var sessionID = Convert.ToUInt32(args[2].Substring(1));
                            clientc = WorldMgr.GetClientFromID(sessionID);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    }

                    if (clientc == null)
                    {
                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], eRealm.None);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            if (jumpTarget.InHouse && jumpTarget.CurrentHouse != null)
                            {
                                jumpTarget.CurrentHouse.Enter(client.Player);
                            }
                            else
                            {
                                client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            }
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFound", args[2]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }

                    client.Out.SendMessage("You don't have an expansion needed to jump to this location.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                    return;
                }
                #endregion Jump to PlayerName
                #region Jump to Name Realm
                else if (args.Length == 4 && args[1] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    if (clientc == null)
                    {
                        int realm = 0;
                        int.TryParse(args[3], out realm);

                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], (eRealm)realm);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFoundInRealm", args[2], realm), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        if (clientc.Player.InHouse)
                        {
                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotJumpToInsideHouse"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }
                    return;
                }
                #endregion Jump to Name Realm
                #region Jump to X Y Z
                else if (args.Length == 5 && args[1] == "to")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                    return;
                }
                #endregion Jump to X Y Z
                #region Jump rel +/-X +/-Y +/-Z
                else if (args.Length == 5 && args[1] == "rel")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID,
                                         client.Player.X + Convert.ToInt32(args[2]),
                                         client.Player.Y + Convert.ToInt32(args[3]),
                                         client.Player.Z + Convert.ToInt32(args[4]),
                                         client.Player.Heading);
                    return;
                }
                #endregion Jump rel +/-X +/-Y +/-Z
                #region Jump to X Y Z RegionID
                else if (args.Length == 6 && args[1] == "to")
                {
                    if (CheckExpansion(client, client, (ushort)Convert.ToUInt16(args[5])))
                    {
                        client.Player.MoveTo(Convert.ToUInt16(args[5]), Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump to X Y Z RegionID
                #region Jump PlayerName to X Y Z
                else if (args.Length == 6 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    clientc.Player.MoveTo(clientc.Player.CurrentRegionID, Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                    return;
                }
                #endregion Jump PlayerName to X Y Z
                #region Jump PlayerName to X Y Z RegionID
                else if (args.Length == 7 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(clientc, clientc, (ushort)Convert.ToUInt16(args[6])))
                    {
                        clientc.Player.MoveTo(Convert.ToUInt16(args[6]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump PlayerName to X Y Z RegionID
                #region Jump PlayerName to PlayerCible
                else if (args.Length == 4 && args[2] == "to")
                {
                    GameClient clientc;
                    GameClient clientto;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (args[3] == "me")
                    {
                        clientto = client;
                    }
                    else
                    {
                        clientto = WorldMgr.GetClientByPlayerName(args[3], false, false);
                    }

                    if (clientto == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[3]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    else
                    {
                        if (CheckExpansion(clientto, clientc, clientto.Player.CurrentRegionID))
                        {
                            if (clientto.Player.CurrentHouse != null && clientto.Player.InHouse)
                            {
                                clientto.Player.CurrentHouse.Enter(clientc.Player);
                            }
                            else
                            {
                                clientc.Player.MoveTo(clientto.Player.CurrentRegionID, clientto.Player.X, clientto.Player.Y, clientto.Player.Z, client.Player.Heading);
                            }
                            return;
                        }
                        return;
                    }
                }
                #endregion Jump PlayerName to PlayerCible
                #region push/pop
                else if (args.Length > 1 && args[1] == "push")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null)
                    {
                        locations = new Stack <GameLocation>(3);
                        client.Player.TempProperties.setProperty(TEMP_KEY_JUMP, locations);
                    }

                    locations.Push(new GameLocation("temploc", client.Player.CurrentRegionID, client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading));

                    string message = LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.Pushed");

                    if (locations.Count > 1)
                    {
                        message += " " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PushedTotal", locations.Count);
                    }

                    message += " - " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PopInstructions");

                    client.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else if (args.Length > 1 && args[1] == "pop")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null || locations.Count < 1)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.NothingPushed"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    GameLocation jumploc = locations.Pop();

                    // slight abuse of the stack principle, but convenient to always have your last popped loc jumpable
                    if (locations.Count < 1)
                    {
                        locations.Push(jumploc);
                    }

                    client.Player.MoveTo(jumploc.RegionID, jumploc.X, jumploc.Y, jumploc.Z, jumploc.Heading);
                }
                #endregion push/pop
                #region DisplaySyntax
                else
                {
                    DisplaySyntax(client);
                    return;
                }
                #endregion DisplaySyntax
            }

            catch (Exception ex)
            {
                DisplayMessage(client, ex.Message);
            }
        }
Exemplo n.º 5
0
            /// <summary>
            /// Called on every timer tick
            /// </summary>
            protected override void OnTick()
            {
                var player = (GamePlayer)m_actionSource;

                if (player == null)
                {
                    return;
                }

                // log.DebugFormat("Dialog - response: {0}, messageType: {1}, data1: {2}, data2: {3}, data3: {4}", m_response, m_messageType, m_data1, m_data2, m_data3);

                switch ((eDialogCode)m_messageType)
                {
                case eDialogCode.CustomDialog:
                {
                    if (m_data2 == 0x01)
                    {
                        CustomDialogResponse callback;
                        lock (player)
                        {
                            callback = player.CustomDialogCallback;
                            player.CustomDialogCallback = null;
                        }

                        if (callback == null)
                        {
                            return;
                        }

                        callback(player, m_response);
                    }
                    break;
                }

                case eDialogCode.GuildInvite:
                {
                    var guildLeader = WorldMgr.GetObjectByIDFromRegion(player.CurrentRegionID, (ushort)m_data1) as GamePlayer;
                    if (m_response == 0x01)                                     //accept
                    {
                        if (guildLeader == null)
                        {
                            player.Out.SendMessage("You need to be in the same region as the guild leader to accept an invitation.",
                                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (player.Guild != null)
                        {
                            player.Out.SendMessage("You are still in a guild, you'll have to leave it first.", eChatType.CT_System,
                                                   eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (guildLeader.Guild != null)
                        {
                            guildLeader.Guild.AddPlayer(player);
                            return;
                        }

                        player.Out.SendMessage("Player doing the invite is not in a guild!", eChatType.CT_System,
                                               eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (guildLeader != null)
                    {
                        guildLeader.Out.SendMessage(player.Name + " declined your invite.", eChatType.CT_System,
                                                    eChatLoc.CL_SystemWindow);
                    }
                    return;
                }

                case eDialogCode.GuildLeave:
                {
                    if (m_response == 0x01)                                     //accepte
                    {
                        if (player.Guild == null)
                        {
                            player.Out.SendMessage("You are not in a guild.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }

                        player.Guild.RemovePlayer(player.Name, player);
                    }
                    else
                    {
                        player.Out.SendMessage("You decline to quit your guild.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    break;
                }

                case eDialogCode.QuestSubscribe:
                {
                    var questNPC = (GameLiving)WorldMgr.GetObjectByIDFromRegion(player.CurrentRegionID, (ushort)m_data2);
                    if (questNPC == null)
                    {
                        return;
                    }

                    var args = new QuestEventArgs(questNPC, player, (ushort)m_data1);
                    if (m_response == 0x01)                                     // accept
                    {
                        // TODO add quest to player
                        // Note: This is done withing quest code since we have to check requirements, etc for each quest individually
                        // i'm reusing the questsubscribe command for quest abort since its 99% the same, only different event dets fired
                        player.Notify(m_data3 == 0x01 ? GamePlayerEvent.AbortQuest : GamePlayerEvent.AcceptQuest, player, args);
                        return;
                    }
                    player.Notify(m_data3 == 0x01 ? GamePlayerEvent.ContinueQuest : GamePlayerEvent.DeclineQuest, player, args);
                    return;
                }

                case eDialogCode.GroupInvite:
                {
                    if (m_response == 0x01)
                    {
                        GameClient cln = WorldMgr.GetClientFromID(m_data1);
                        if (cln == null)
                        {
                            return;
                        }

                        GamePlayer groupLeader = cln.Player;
                        if (groupLeader == null)
                        {
                            return;
                        }

                        if (player.Group != null)
                        {
                            player.Out.SendMessage("You are still in a group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (!GameServer.ServerRules.IsAllowedToGroup(groupLeader, player, false))
                        {
                            return;
                        }
                        if (player.InCombatPvE)
                        {
                            player.Out.SendMessage("You can't join a group while in combat!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (groupLeader.Group != null)
                        {
                            if (groupLeader.Group.Leader != groupLeader)
                            {
                                return;
                            }
                            if (groupLeader.Group.MemberCount >= ServerProperties.Properties.GROUP_MAX_MEMBER)
                            {
                                player.Out.SendMessage("The group is full.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                                return;
                            }
                            groupLeader.Group.AddMember(player);
                            GameEventMgr.Notify(GamePlayerEvent.AcceptGroup, player);
                            return;
                        }

                        var group = new Group(groupLeader);
                        GroupMgr.AddGroup(group);

                        group.AddMember(groupLeader);
                        group.AddMember(player);

                        GameEventMgr.Notify(GamePlayerEvent.AcceptGroup, player);

                        return;
                    }
                    break;
                }

                case eDialogCode.KeepClaim:
                {
                    if (m_response == 0x01)
                    {
                        if (player.Guild == null)
                        {
                            player.Out.SendMessage("You have to be a member of a guild, before you can use any of the commands!",
                                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }

                        AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(player.CurrentRegionID, player.Position, WorldMgr.VISIBILITY_DISTANCE);
                        if (keep == null)
                        {
                            player.Out.SendMessage("You have to be near the keep to claim it.", eChatType.CT_System,
                                                   eChatLoc.CL_SystemWindow);
                            return;
                        }

                        if (keep.CheckForClaim(player))
                        {
                            keep.Claim(player);
                        }
                        break;
                    }
                    break;
                }

                case eDialogCode.HousePayRent:
                {
                    if (m_response == 0x00)
                    {
                        if (player.TempProperties.getProperty <long>(HousingConstants.MoneyForHouseRent, -1) != -1)
                        {
                            player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                        }

                        if (player.TempProperties.getProperty <long>(HousingConstants.BPsForHouseRent, -1) != -1)
                        {
                            player.TempProperties.removeProperty(HousingConstants.BPsForHouseRent);
                        }

                        player.TempProperties.removeProperty(HousingConstants.HouseForHouseRent);

                        return;
                    }

                    var house      = player.TempProperties.getProperty <House>(HousingConstants.HouseForHouseRent, null);
                    var moneyToAdd = player.TempProperties.getProperty <long>(HousingConstants.MoneyForHouseRent, -1);
                    var bpsToMoney = player.TempProperties.getProperty <long>(HousingConstants.BPsForHouseRent, -1);

                    if (moneyToAdd != -1)
                    {
                        // if we're giving money and already have some in the lockbox, make sure we don't
                        // take more than what would cover 4 weeks of rent.
                        if (moneyToAdd + house.KeptMoney > HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS)
                        {
                            moneyToAdd = (HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS) - house.KeptMoney;
                        }

                        // take the money from the player
                        if (!player.RemoveMoney(moneyToAdd))
                        {
                            return;
                        }
                        InventoryLogging.LogInventoryAction(player, "(HOUSE;" + house.HouseNumber + ")", eInventoryActionType.Other, moneyToAdd);

                        // add the money to the lockbox
                        house.KeptMoney += moneyToAdd;

                        // save the house and the player
                        house.SaveIntoDatabase();
                        player.SaveIntoDatabase();

                        // notify the player of what we took and how long they are prepaid for
                        player.Out.SendMessage("You deposit " + Money.GetString(moneyToAdd) + " in the lockbox.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The lockbox now has " + Money.GetString(house.KeptMoney) + " in it.  The weekly payment is " +
                                               Money.GetString(HouseMgr.GetRentByModel(house.Model)) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The house is now prepaid for the next " + (house.KeptMoney / HouseMgr.GetRentByModel(house.Model)) +
                                               " payments.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                        // clean up
                        player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                    }
                    else
                    {
                        if (bpsToMoney + house.KeptMoney > HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS)
                        {
                            bpsToMoney = (HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS) - house.KeptMoney;
                        }

                        if (!player.RemoveBountyPoints(Money.GetGold(bpsToMoney)))
                        {
                            return;
                        }

                        // add the bps to the lockbox
                        house.KeptMoney += bpsToMoney;

                        // save the house and the player
                        house.SaveIntoDatabase();
                        player.SaveIntoDatabase();

                        // notify the player of what we took and how long they are prepaid for
                        player.Out.SendMessage("You deposit " + Money.GetString(bpsToMoney) + " in the lockbox.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The lockbox now has " + Money.GetString(house.KeptMoney) + " in it.  The weekly payment is " +
                                               Money.GetString(HouseMgr.GetRentByModel(house.Model)) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The house is now prepaid for the next " + (house.KeptMoney / HouseMgr.GetRentByModel(house.Model)) +
                                               " payments.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                        // clean up
                        player.TempProperties.removeProperty(HousingConstants.BPsForHouseRent);
                    }

                    // clean up
                    player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                    break;
                }

                case eDialogCode.MasterLevelWindow:
                {
                    player.Out.SendMasterLevelWindow(m_response);
                    break;
                }
                }
            }
Exemplo n.º 6
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            GameClient playerClient = null;

            if (args[1].StartsWith("#"))
            {
                try
                {
                    var sessionID = Convert.ToUInt32(args[1].Substring(1));
                    playerClient = WorldMgr.GetClientFromID(sessionID);
                }
                catch
                {
                    DisplayMessage(client, "Invalid client ID");
                }
            }
            else
            {
                playerClient = WorldMgr.GetClientByPlayerName(args[1], true, false);
            }

            if (playerClient == null)
            {
                DisplayMessage(client, "No player found for '" + args[1] + "'");
                return;
            }

            if (client.Account.PrivLevel < playerClient.Account.PrivLevel)
            {
                DisplayMessage(client, "Your privlevel is not high enough to mute this player.");
                return;
            }

            bool mutedAccount = false;

            if (args.Length > 2 && (args[2].ToLower() == "account" || args[2].ToLower() == "allchars"))
            {
                if (playerClient != null)
                {
                    playerClient.Account.IsMuted = true;
                    playerClient.Player.IsMuted  = true;
                    GameServer.Database.SaveObject(playerClient.Account);
                    mutedAccount = true;
                }
            }
            else if (args.Length > 2 && args[2].ToLower() == "remove")
            {
                if (playerClient != null)
                {
                    playerClient.Account.IsMuted = false;
                    playerClient.Player.IsMuted  = false;
                    GameServer.Database.SaveObject(playerClient.Account);
                    mutedAccount = true;
                }
            }
            else
            {
                if (playerClient != null)
                {
                    if (playerClient.Account.IsMuted)
                    {
                        DisplayMessage(client, "This player has an allchars mute which must be removed first.");
                        return;
                    }

                    playerClient.Player.IsMuted = !playerClient.Player.IsMuted;
                }
            }

            if (playerClient.Player.IsMuted)
            {
                playerClient.Player.Out.SendMessage("You have been muted from public channels by staff member " + client.Player.Name + "!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                client.Player.Out.SendMessage("You have muted player " + playerClient.Player.Name + " from public channels!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                if (mutedAccount)
                {
                    playerClient.Player.Out.SendMessage("This mute has been placed on all characters for this account.", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                    client.Player.Out.SendMessage("This action was done to the players account.", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                }

                log.Warn(client.Player.Name + " muted " + playerClient.Player.Name);
            }
            else
            {
                playerClient.Player.Out.SendMessage("You have been unmuted from public channels by staff member " + client.Player.Name + "!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                client.Player.Out.SendMessage("You have unmuted player " + playerClient.Player.Name + " from public channels!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                if (mutedAccount)
                {
                    client.Player.Out.SendMessage("This action was done to the players account.", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                }

                log.Warn(client.Player.Name + " un-muted " + playerClient.Player.Name);
            }
            return;
        }
Exemplo n.º 7
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 3)
            {
                DisplaySyntax(client);
                return;
            }

            GameClient gc = null;

            if (args[2].StartsWith("#"))
            {
                try
                {
                    var sessionID = Convert.ToUInt32(args[1].Substring(1));
                    gc = WorldMgr.GetClientFromID(sessionID);
                }
                catch
                {
                    DisplayMessage(client, "Invalid client ID");
                }
            }
            else
            {
                gc = WorldMgr.GetClientByPlayerName(args[2], false, false);
            }

            var acc = gc != null ? gc.Account : DOLDB <Account> .SelectObject(DB.Column("Name").IsLike(args[2]));

            if (acc == null)
            {
                client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.UnableToFindPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (client.Account.PrivLevel < acc.PrivLevel)
            {
                DisplayMessage(client, "Your privlevel is not high enough to ban this player.");
                return;
            }

            if (client.Account.Name == acc.Name)
            {
                DisplayMessage(client, "Your can't ban yourself!");
                return;
            }

            try
            {
                DBBannedAccount b = new DBBannedAccount
                {
                    DateBan = DateTime.Now,
                    Author  = client.Player.Name,
                    Ip      = acc.LastLoginIP,
                    Account = acc.Name
                };

                if (args.Length >= 4)
                {
                    b.Reason = String.Join(" ", args, 3, args.Length - 3);
                }
                else
                {
                    b.Reason = "No Reason.";
                }

                switch (args[1].ToLower())
                {
                    #region Account
                case "account":
                    var acctBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("A").Or(DB.Column("Type").IsEqualTo("B")).And(DB.Column("Account").IsEqualTo(acc.Name)));

                    if (acctBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.AAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "A";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.ABanned", acc.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                    #endregion Account
                    #region IP
                case "ip":
                    var ipBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("I").Or(DB.Column("Type").IsEqualTo("B")).And(DB.Column("Ip").IsEqualTo(acc.LastLoginIP)));

                    if (ipBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "I";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IBanned", acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                    #endregion IP
                    #region Both
                case "both":
                    var acctIpBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("B").And(DB.Column("Account").IsEqualTo(acc.Name)).And(DB.Column("Ip").IsEqualTo(acc.LastLoginIP)));

                    if (acctIpBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "B";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BBanned", acc.Name, acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                    #endregion Both
                    #region Default
                default:
                {
                    DisplaySyntax(client);
                    return;
                }
                    #endregion Default
                }
                GameServer.Database.AddObject(b);

                if (log.IsInfoEnabled)
                {
                    log.Info("Ban added [" + args[1].ToLower() + "]: " + acc.Name + "(" + acc.LastLoginIP + ")");
                }
                return;
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("/ban Exception", e);
                }
            }

            // if not returned here, there is an error
            DisplaySyntax(client);
        }
Exemplo n.º 8
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 3)
            {
                DisplaySyntax(client);
                return;
            }

            GameClient gc = null;

            if (args[2].StartsWith("#"))
            {
                try
                {
                    int sessionID = Convert.ToInt32(args[1].Substring(1));
                    gc = WorldMgr.GetClientFromID(sessionID);
                }
                catch
                {
                    DisplayMessage(client, "Invalid client ID");
                }
            }
            else
            {
                gc = WorldMgr.GetClientByPlayerName(args[2], false, false);
            }

            Account acc = gc != null ? gc.Account : GameServer.Database.SelectObjects <Account>("`Name` LIKE @Name", new QueryParameter("@Name", args[2])).FirstOrDefault();

            if (acc == null)
            {
                client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.UnableToFindPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (client.Account.PrivLevel < acc.PrivLevel)
            {
                DisplayMessage(client, "Your privlevel is not high enough to ban this player.");
                return;
            }

            if (client.Account.Name == acc.Name)
            {
                DisplayMessage(client, "Your can't ban yourself!");
                return;
            }

            try
            {
                DBBannedAccount b = new DBBannedAccount
                {
                    DateBan = DateTime.Now,
                    Author  = client.Player.Name,
                    Ip      = acc.LastLoginIP,
                    Account = acc.Name
                };

                if (args.Length >= 4)
                {
                    b.Reason = string.Join(" ", args, 3, args.Length - 3);
                }
                else
                {
                    b.Reason = "No Reason.";
                }

                switch (args[1].ToLower())
                {
                case "account":
                    var acctBans = GameServer.Database.SelectObjects <DBBannedAccount>("(`Type` = @TypeA OR `Type` = @TypeB) AND `Account` = @Account", new[] { new QueryParameter("@TypeA", "A"), new QueryParameter("@TypeB", "B"), new QueryParameter("@Account", acc.Name) });
                    if (acctBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.AAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "A";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.ABanned", acc.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                case "ip":
                    var ipBans = GameServer.Database.SelectObjects <DBBannedAccount>("(`Type` = @TypeI OR `Type` = @TypeB) AND `Ip` = @Ip", new[] { new QueryParameter("@TypeI", "I"), new QueryParameter("@TypeB", "B"), new QueryParameter("@Ip", acc.LastLoginIP) });
                    if (ipBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "I";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IBanned", acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                case "both":
                    var acctIpBans = GameServer.Database.SelectObjects <DBBannedAccount>("`Type` = @Type AND `Account` = @Account AND `Ip` = @Ip", new[] { new QueryParameter("@Type", "B"), new QueryParameter("@Account", acc.Name), new QueryParameter("@Ip", acc.LastLoginIP) });
                    if (acctIpBans.Count > 0)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    b.Type = "B";
                    client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BBanned", acc.Name, acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    break;

                default:
                {
                    DisplaySyntax(client);
                    return;
                }
                }

                GameServer.Database.AddObject(b);

                if (log.IsInfoEnabled)
                {
                    log.Info("Ban added [" + args[1].ToLower() + "]: " + acc.Name + "(" + acc.LastLoginIP + ")");
                }

                return;
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("/ban Exception", e);
                }
            }

            // if not returned here, there is an error
            DisplaySyntax(client);
        }