Exemplo n.º 1
0
        public void addUser(Player p)
        {
            ClanUser user = new ClanUser(p, this);
            if (p.getLoginDetails().getUsername().Equals(owner))
            {
                user.setClanRights(ClanRank.OWNER);
                own = p;
            }
            if (ownerFriends.Contains(p.getLoginDetails().getLongName()))
            {
                if (user.getClanRights() == ClanRank.NO_RANK)
                {
                    user.setClanRights(ClanRank.FRIEND);
                }
            }

            foreach (KeyValuePair<string, ClanRank> u in usersWithRank)
            {
                if (u.Key.Equals(p.getLoginDetails().getUsername()))
                {
                    user.setClanRights(u.Value);
                    break;
                }
            }
            p.setClan(this);
            lock (users)
            {
                users.Add(user);
            }
        }
Exemplo n.º 2
0
        public void addFriend(long name)
        {
            Player friend = null;

            if (friends.Count >= 200)
            {
                player.getPackets().sendMessage("Your friends list is full.");
                return;
            }
            if (friends.Contains((long)name))
            {
                player.getPackets().sendMessage(Misc.formatPlayerNameForDisplay(Misc.longToPlayerName(name)) + " is already on your friends list.");
                return;
            }
            friends.Add((long)name);
            foreach (Player p in Server.getPlayerList())
            {
                if (p != null)
                {
                    if (p.getLoginDetails().getLongName() == name)
                    {
                        friend = p;
                    }
                }
            }
            if (friend != null)
            {
                if (privateStatus != STATUS.OFF)
                {
                    friend.getFriends().registered(player);
                }
                Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                if (clan != null)
                {
                    clan.getOwnerFriends().Add(name);
                    if (clan.getUser(friend) != null)
                    {
                        if (clan.getUser(friend).getClanRights() == Clan.ClanRank.NO_RANK)
                        {
                            clan.getUser(friend).setClanRights(Clan.ClanRank.FRIEND);
                            Server.getClanManager().updateClan(clan);
                        }
                    }
                }
                if (friend.getFriends().getPrivateStatus() == STATUS.OFF || (friend.getFriends().getPrivateStatus() == STATUS.FRIENDS && !friend.getFriends().isFriend(player)))
                {
                    return;
                }
                player.getPackets().sendFriend(name, getWorld(name));
            }
        }
Exemplo n.º 3
0
 public void openEnterPin()
 {
     if (bankPinRemoved)
     {
         openPinSettings(9);
         return;
     }
     if (bankPin == null || changingPin)
     {
         player.getPackets().showChildInterface(13, 29, false);
     }
     else if (bankPin != null && !changingPin)
     {
         player.getPackets().setRightClickOptions(2, 851997, -1, -1);
     }
     if (lastDeletionRequest != 0)
     {
         int daysLeft = recoveryDaysRequired - TimeSpan.FromTicks(lastDeletionRequest).Days;
         player.getPackets().modifyText("Your Bank PIN will be deleted in another " + daysLeft + " days.", 13, 31);
     }
     else
     {
         player.getPackets().modifyText("Bank of " + player.getLoginDetails().getUsername(), 13, 31);
     }
     scrambleNumbers();
     player.getPackets().displayInterface(13);
 }
Exemplo n.º 4
0
        private void unregistered(Player p)
        {
            long n = p.getLoginDetails().getLongName();

            if (friends.Contains(n))
            {
                player.getPackets().sendFriend(n, 0);
            }
        }
Exemplo n.º 5
0
        private bool isFriend(Player player)
        {
            long n = player.getLoginDetails().getLongName();

            if (friends.Contains(n))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        private void openTrade()
        {
            player.getPackets().displayInterface(335);
            player.getPackets().displayInventoryInterface(336);
            player.getPackets().setRightClickOptions(1278, (335 * 65536) + 30, 0, 27);
            player.getPackets().setRightClickOptions(1026, (335 * 65536) + 32, 0, 27);
            player.getPackets().setRightClickOptions(1278, (336 * 65536), 0, 27);
            player.getPackets().setRightClickOptions(2360446, (336 * 65536), 0, 27);
            object[] opts1 = new object[] { "", "", "", "Value", "Remove X", "Remove All", "Remove 10", "Remove 5", "Remove 1", -1, 0, 7, 4, 90, 21954590 };
            object[] opts2 = new object[] { "", "", "Lend", "Value", "Offer X", "Offer All", "Offer 10", "Offer 5", "Offer 1", -1, 0, 7, 4, 93, 22020096 };
            object[] opts3 = new object[] { "", "", "", "", "", "", "", "", "Value", -1, 0, 7, 4, 90, 21954592 };
            player.getPackets().sendClientScript(150, opts1, "IviiiIsssssssss");
            player.getPackets().sendClientScript(150, opts2, "IviiiIsssssssss");
            player.getPackets().sendClientScript(695, opts3, "IviiiIsssssssss");

            player.getPackets().modifyText("Trading with: " + player2.getLoginDetails().getUsername(), 335, 15);
            player.getPackets().modifyText(player2.getLoginDetails().getUsername() + " has " + player2.getInventory().getTotalFreeSlots() + " free inventory slots.", 335, 21);
            player.getPackets().modifyText("", 335, 36);

            refreshTrade();
        }
Exemplo n.º 7
0
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Yell command]: what you expecting to yell blank message?");
                return;
            }

            string yellMsg = string.Join(" ", arguments);

            foreach (Player p in Server.getPlayerList())
            {
                if (p != null)
                {
                    p.getPackets().sendMessage(player.getLoginDetails().getUsername() + ": " + yellMsg);
                }
            }
        }
Exemplo n.º 8
0
 public void updateSearchItem(int item)
 {
     p.getPackets().sendConfig(1109, item);
     p.getPackets().sendConfig(1110, 0);
     ItemData.Item def = ItemData.forId(item);
     if (def == null)
     {
         return;
     }
     p.getPackets().sendConfig(1109, item);
     p.getPackets().sendConfig(1114, def.getPrice().getNormalPrice());
     p.getPackets().sendConfig(1116, def.getPrice().getMaximumPrice());
     p.getPackets().sendConfig(1115, def.getPrice().getMinimumPrice());
     p.getPackets().sendConfig(1111, def.getPrice().getNormalPrice());
     currentOffer = new BuyOffer(slot, p.getLoginDetails().getUsername());
     currentOffer.setTotalAmount(0);
     currentOffer.setItem(item);
     currentOffer.setPriceEach(def.getPrice().getNormalPrice());
     p.getPackets().sendInterface(0, 752, 6, 137); // Removes the item search
 }
Exemplo n.º 9
0
 private void unregistered(Player p)
 {
     long n = p.getLoginDetails().getLongName();
     if (friends.Contains(n))
     {
         player.getPackets().sendFriend(n, 0);
     }
 }
Exemplo n.º 10
0
        private void handleClickFour(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 4: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 763: // Bank inventory - Custom amount.
                    player.getBank().deposit(slot, player.getBank().getLastXAmount());
                    player.getBank().refreshBank();
                    break;

                case 762: // Bank - Custom amount.
                    player.getBank().withdraw(slot, player.getBank().getLastXAmount());
                    player.getBank().refreshBank();
                    break;

                case 154: // Craft normal leather.
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(154, child));
                    break;

                case 542: // Glassblowing.
                    switch (child)
                    {
                        case 40: // Make X beer glass.
                        case 41: // Make X candle lantern.
                        case 42: // Make X oil lamp.
                        case 38: // Make X vial.
                        case 44: // Make X Fishbowl
                        case 39: // Make X orb.
                        case 43: // Make X lantern lens
                        case 45: // Make X dorgeshuun light orb.
                            player.getPackets().displayEnterAmount();
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(542, child));
                            break;
                    }
                    break;

                case 336: // Trade/stake inventory - trade all.
                    if (player.getTrade() != null)
                    {
                        player.getTrade().tradeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot)));
                        break;
                    }
                    if (player.getDuel() != null)
                    {
                        player.getDuel().stakeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot)));
                        break;
                    }
                    break;

                case 335: // Trade interface - remove all.
                    player.getTrade().removeItem(slot, player.getTrade().getItemAmount(player.getTrade().getItemInSlot(slot)));
                    break;

                case 631: // Duel interface - remove All
                    if (player.getDuel() != null)
                    {
                        player.getDuel().removeItem(slot, player.getDuel().getItemAmount(player.getDuel().getItemInSlot(slot)));
                        break;
                    }
                    break;

                case 620: // Shop - buy 10.
                    player.getShopSession().buyItem(slot, 10);
                    break;

                case 621: // Shop - sell 10.
                    player.getShopSession().sellItem(slot, 10);
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - corporal.
                            clan.setEnterRights(Clan.ClanRank.CORPORAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - corporal.
                            clan.setTalkRights(Clan.ClanRank.CORPORAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 25: // // "Who can kick in chat" - corporal.
                            clan.setKickRights(Clan.ClanRank.CORPORAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
                            break;

                        case 26: // "Who can share loot" - corporal.
                            clan.setLootRights(Clan.ClanRank.CORPORAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 11
0
 public void openClanSetup(Player p)
 {
     p.getPackets().displayInterface(590);
     Clan clan = getClanByOwner(p.getLoginDetails().getUsername());
     if (clan == null)
     {
         Clan newClan = new Clan(p, "Clan name", p.getLoginDetails().getUsername());
         addChannel(newClan);
         p.getPackets().sendMessage("Your clan chat has been succesfully set up.");
         return;
     }
     p.getPackets().modifyText(Misc.formatPlayerNameForDisplay(clan.getClanName()), 590, 22);
     p.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
     p.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
     p.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
     p.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
 }
Exemplo n.º 12
0
        public void removeItem(int slot, int amount)
        {
            if (status > 2 || items[slot] == null)
            {
                return;
            }
            int  itemId    = getItemInSlot(slot);
            int  tradeSlot = findItem(itemId);
            bool stackable = ItemData.forId(itemId).isStackable();

            if (tradeSlot == -1)
            {
                Misc.WriteError("user tried to remove non-existing item from trade! " + player.getLoginDetails().getUsername());
                return;
            }
            if (amount > getItemAmount(itemId))
            {
                amount = getItemAmount(itemId);
            }
            if (!stackable)
            {
                for (int i = 0; i < amount; i++)
                {
                    tradeSlot = findItem(itemId);
                    if (player.getInventory().addItem(itemId, amount))
                    {
                        items[tradeSlot].setItemAmount(getAmountInSlot(tradeSlot) - amount);
                        if (getAmountInSlot(tradeSlot) <= 0)
                        {
                            items[tradeSlot] = null;
                        }
                        player2.getPackets().tradeWarning(tradeSlot);
                    }
                }
                if (status == 2 || player2.getTrade().getStatus() == 2)
                {
                    this.status = 1;
                    player2.getTrade().setStatus(1);
                    player.getPackets().modifyText("", 335, 36);
                    player2.getPackets().modifyText("", 335, 36);
                }
                refreshTrade();
            }
            else
            {
                tradeSlot = findItem(itemId);
                if (player.getInventory().addItem(itemId, amount))
                {
                    items[tradeSlot].setItemAmount(getAmountInSlot(tradeSlot) - amount);
                    if (getAmountInSlot(tradeSlot) <= 0)
                    {
                        items[tradeSlot] = null;
                    }
                    player2.getPackets().tradeWarning(tradeSlot);
                }
            }
            if (status == 2 || player2.getTrade().getStatus() == 2)
            {
                this.status = 1;
                player2.getTrade().setStatus(1);
                player.getPackets().modifyText("", 335, 36);
                player2.getPackets().modifyText("", 335, 36);
            }
            refreshTrade();
            tradeModified = true;
        }
Exemplo n.º 13
0
        private void handleClickEight(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 8: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - general.
                            clan.setEnterRights(Clan.ClanRank.GENERAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - general.
                            clan.setTalkRights(Clan.ClanRank.GENERAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 25: // // "Who can kick in chat" - general.
                            clan.setKickRights(Clan.ClanRank.GENERAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
                            break;

                        case 26: // "Who can share loot" - general.
                            clan.setLootRights(Clan.ClanRank.GENERAL);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 14
0
 public bool isFriendOfOwner(Player p)
 {
     return ownerFriends.Contains(p.getLoginDetails().getLongName());
 }
Exemplo n.º 15
0
        public static void talkToKamfreena(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            switch (status)
            {
                case 77:
                    p.getPackets().sendNPCHead(4289, 241, 2);
                    p.getPackets().modifyText("Kamfreena", 241, 3);
                    p.getPackets().modifyText("Hello! Can I help you?.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 78;
                    break;

                case 78:
                    p.getPackets().modifyText("I'd like to kill some Cyclops please.", 228, 2);
                    p.getPackets().modifyText("Never mind, sorry to bother you.", 228, 3);
                    p.getPackets().sendChatboxInterface(228);
                    newStatus = 79;
                    break;

                case 79:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'd like to kill some Cyclops please.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 81;
                    break;

                case 80:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Never mind, sorry to bother you.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    break;

                case 81:
                    if (!p.getInventory().hasItemAmount(8851, 100))
                    {
                        p.getPackets().sendNPCHead(4289, 242, 2);
                        p.getPackets().modifyText("Kamfreena", 242, 3);
                        p.getPackets().modifyText("You require a minimum of 100 tokens in order", 242, 4);
                        p.getPackets().modifyText("to be able to enter the Cyclops' room.", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                        break;
                    }
                    else
                    {
                        int currentDefenderStatus = getDefenderStatus(p);
                        int lastDefenderStatus = p.getDefenderWave();
                        p.setDefenderWave(currentDefenderStatus);
                        string s = currentDefenderStatus != lastDefenderStatus ? " now " : " ";
                        p.getPackets().sendNPCHead(4289, 242, 2);
                        p.getPackets().modifyText("Kamfreena", 242, 3);
                        p.getPackets().modifyText("Very well. The Cyclops will" + s + "drop:", 242, 4);
                        p.getPackets().modifyText(ItemData.forId(DEFENDERS[currentDefenderStatus]).getName() + ".", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                        newStatus = 82;
                    }
                    break;

                case 82:
                    if (p.getDefenderWave() < 6)
                    {
                        p.getPackets().sendNPCHead(4289, 242, 2);
                        p.getPackets().modifyText("Kamfreena", 242, 3);
                        p.getPackets().modifyText("Be sure to speak to me once you have retrieved one", 242, 4);
                        p.getPackets().modifyText("if you wish to advance!", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                    }
                    else
                    {
                        p.getPackets().sendNPCHead(4289, 242, 2);
                        p.getPackets().modifyText("Kamfreena", 242, 3);
                        p.getPackets().modifyText("Since Rune is the highest Defender available, you don't", 242, 4);
                        p.getPackets().modifyText("need to speak to me once you have retrieved one.", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                    }
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Exemplo n.º 16
0
        private void handleClickThree(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 3: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 154: // Craft normal leather.
                    Leather.craftNormalLeather(player, child, player.getInventory().getItemAmount(1741), true);
                    break;

                case 542: // Glassblowing.
                    int totalGlass = player.getInventory().getItemAmount(1775);
                    switch (child)
                    {
                        case 40: // Make all beer glass.
                            Glass.craftGlass(player, totalGlass, 0, true);
                            break;

                        case 41: // Make all candle lantern.
                            Glass.craftGlass(player, totalGlass, 1, true);
                            break;

                        case 42: // Make all oil lamp.
                            Glass.craftGlass(player, totalGlass, 2, true);
                            break;

                        case 38: // Make all vial.
                            Glass.craftGlass(player, totalGlass, 3, true);
                            break;

                        case 44: // Make all Fishbowl
                            Glass.craftGlass(player, totalGlass, 4, true);
                            break;

                        case 39: // Make all orb.
                            Glass.craftGlass(player, totalGlass, 5, true);
                            break;

                        case 43: // Make all lantern lens
                            Glass.craftGlass(player, totalGlass, 6, true);
                            break;

                        case 45: // Make all dorgeshuun light orb.
                            Glass.craftGlass(player, totalGlass, 7, true);
                            break;
                    }
                    break;

                case 763: // Bank inventory - 10.
                    player.getBank().deposit(slot, 10);
                    player.getBank().refreshBank();
                    break;

                case 762: // Bank - 10.
                    player.getBank().withdraw(slot, 10);
                    player.getBank().refreshBank();
                    break;

                case 336: // Trade/stake inventory - trade 10.
                    if (player.getTrade() != null)
                    {
                        player.getTrade().tradeItem(slot, 10);
                        break;
                    }
                    if (player.getDuel() != null)
                    {
                        player.getDuel().stakeItem(slot, 10);
                        break;
                    }
                    break;

                case 335: // Trade interface - remove 10.
                    player.getTrade().removeItem(slot, 10);
                    break;

                case 631: // Duel interface - remove 10.
                    if (player.getDuel() != null)
                    {
                        player.getDuel().removeItem(slot, 5);
                        break;
                    }
                    break;

                case 620: // Shop - buy 5.
                    player.getShopSession().buyItem(slot, 5);
                    break;

                case 621: // Shop - sell 5.
                    player.getShopSession().sellItem(slot, 5);
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - recruit.
                            clan.setEnterRights(Clan.ClanRank.RECRUIT);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - recruit.
                            clan.setTalkRights(Clan.ClanRank.RECRUIT);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 26: // "Who can share loot" - recruit.
                            clan.setLootRights(Clan.ClanRank.RECRUIT);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 17
0
 private void handleTradePlayer(Player player, Packet packet)
 {
     int index = packet.readLEShortA();
     if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     Player p2 = Server.getPlayerList()[index];
     if (p2 == null)
     {
         return;
     }
     player.setFaceLocation(p2.getLocation());
     if (player.getTrade() != null)
     {
         player.getTrade().decline();
         return;
     }
     player.getPackets().closeInterfaces();
     if (!player.getLocation().withinDistance(p2.getLocation(), 1))
     {
         int x = p2.getLocation().getX();
         int y = p2.getLocation().getY();
         AreaEvent tradePlayerAreaEvent = new AreaEvent(player, x - 1, y - 1, x + 1, y + 1);
         tradePlayerAreaEvent.setAction(() =>
         {
             player.getWalkingQueue().resetWalkingQueue();
             player.getPackets().clearMapFlag();
             if (p2.getGESession() != null || p2.getTrade() != null || p2.getDuel() != null || p2.getShopSession() != null || p2.getBank().isBanking())
             {
                 player.getPackets().sendMessage("That player is busy at the moment.");
                 return;
             }
             if (p2.wantsToTrade(player))
             {
                 player.getPackets().closeInterfaces();
                 p2.getPackets().closeInterfaces();
                 p2.setFaceLocation(player.getLocation());
                 player.setTrade(new TradeSession(player, p2));
                 p2.setTrade(new TradeSession(p2, player));
                 return;
             }
             player.setFaceLocation(p2.getLocation());
             p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":tradereq:");
             player.getPackets().sendMessage("Sending trade offer...");
             player.newTradeRequest(p2);
         });
         Server.registerCoordinateEvent(tradePlayerAreaEvent);
         return;
     }
     if (p2.getGESession() != null || p2.getTrade() != null || p2.getDuel() != null || p2.getShopSession() != null || p2.getBank().isBanking())
     {
         player.getPackets().sendMessage("That player is busy at the moment.");
         return;
     }
     if (p2.wantsToTrade(player))
     {
         player.getPackets().closeInterfaces();
         p2.getPackets().closeInterfaces();
         p2.setFaceLocation(player.getLocation());
         player.setTrade(new TradeSession(player, p2));
         p2.setTrade(new TradeSession(p2, player));
         return;
     }
     player.newTradeRequest(p2);
     p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":tradereq:");
     player.getPackets().sendMessage("Sending trade offer...");
 }
Exemplo n.º 18
0
        private void handleAttackPlayer(Player player, Packet packet)
        {
            int index = packet.readLEShortA();
            if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }
            SkillHandler.resetAllSkills(player);
            Player p2 = Server.getPlayerList()[index];
            if (p2 == null)
                return;

            player.setFaceLocation(p2.getLocation());
            player.getPackets().closeInterfaces();
            if (Location.atDuelArena(player.getLocation()))
            {
                if (player.getDuel() != null)
                {
                    if (player.getDuel().getStatus() < 4)
                    {
                        player.getDuel().declineDuel();
                        return;
                    }
                    else if (player.getDuel().getStatus() == 5 && player.getDuel().getPlayer2().Equals(p2))
                    {
                        player.getPackets().sendMessage("The duel has not yet started!");
                        return;
                    }
                    else if ((player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) && !player.getDuel().getPlayer2().Equals(p2))
                    {
                        return;
                    }
                    else if (player.getDuel().getStatus() == 6)
                    {
                        Combat.newAttack(player, p2);
                        return;
                    }
                }
                if (!player.getLocation().withinDistance(p2.getLocation(), 1))
                {
                    int x = p2.getLocation().getX();
                    int y = p2.getLocation().getY();
                    AreaEvent attackAreaEvent = new AreaEvent(player, x - 1, y - 1, x + 1, y + 1);
                    attackAreaEvent.setAction(() =>
                    {
                        player.getWalkingQueue().resetWalkingQueue();
                        player.getPackets().clearMapFlag();
                        if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking())
                        {
                            player.getPackets().sendMessage("That player is busy at the moment.");
                            return;
                        }
                        if (p2.wantsToDuel(player))
                        {
                            p2.setFaceLocation(player.getLocation());
                            player.getPackets().closeInterfaces();
                            p2.getPackets().closeInterfaces();
                            player.setDuelSession(new DuelSession(player, p2));
                            p2.setDuelSession(new DuelSession(p2, player));
                            return;
                        }
                        player.setFaceLocation(p2.getLocation());
                        p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
                        player.getPackets().sendMessage("Sending duel request...");
                        player.newDuelRequest(p2);
                    });
                    Server.registerCoordinateEvent(attackAreaEvent);
                    return;
                }
                if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking())
                {
                    player.getPackets().sendMessage("That player is busy at the moment.");
                    return;
                }
                if (p2.wantsToDuel(player))
                {
                    player.getPackets().closeInterfaces();
                    p2.getPackets().closeInterfaces();
                    p2.setFaceLocation(player.getLocation());
                    player.setDuelSession(new DuelSession(player, p2));
                    p2.setDuelSession(new DuelSession(p2, player));
                    return;
                }
                player.newDuelRequest(p2);
                p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
                player.getPackets().sendMessage("Sending duel request...");
                return;
            }
            Combat.newAttack(player, p2);
        }
Exemplo n.º 19
0
 private void handleClanKick(Player player, Packet packet)
 {
     long name = packet.readLong();
     if (name < 0)
     {
         return;
     }
     Clan clan = Server.getClanManager().getClanByPlayer(player);
     if (clan != null)
     {
         ClanUser user = clan.getUserByName(player.getLoginDetails().getUsername());
         if (user != null)
         {
             if (user.getClanRights() < clan.getKickRights())
             {
                 player.getPackets().sendMessage("You do not have a high enough rank to kick users from this clan chat.");
                 return;
             }
             clan.kickUser(name);
         }
     }
 }
Exemplo n.º 20
0
 private void handleClanRanks(Player player, Packet packet)
 {
     int rank = packet.readByteA();
     long name = packet.readLong();
     if (name < 0 || (rank < 0 || rank > 6))
     {
         return;
     }
     Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
     if (clan != null)
     {
         ClanUser user = clan.getUserByName(Misc.longToPlayerName(name));
         if (user != null)
         {
             user.setClanRights((Clan.ClanRank)rank);
             Server.getClanManager().updateClan(clan);
         }
         Clan.ClanRank userExists;
         if (clan.getUsersWithRank().TryGetValue(Misc.longToPlayerName(name), out userExists))
             clan.getUsersWithRank()[Misc.longToPlayerName(name)] = (Clan.ClanRank)rank;  //Exists already, so altar.
         else
             clan.getUsersWithRank().Add(Misc.longToPlayerName(name), (Clan.ClanRank)rank); //Not existed yet. so add
     }
 }
Exemplo n.º 21
0
        public static void doDialogue(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            switch (status)
            {
                case 1:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ahoy Cap'n!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 2;
                    break;

                case 2:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Ahoy there!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 3;
                    break;

                case 3:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Avast ye scurvy swabs!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 4;
                    break;

                case 4:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Huh?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 5;
                    break;

                case 5:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Don't mind me parrot, he's Cracked Jenny's Tea Cup!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 6;
                    break;

                case 6:
                    p.getPackets().sendChatboxInterface2(235);
                    p.getPackets().modifyText("What is this place?", 235, 2);
                    p.getPackets().modifyText("What do i do in the arena?", 235, 3);
                    p.getPackets().modifyText("I'd like to use the Agility Arena, please.", 235, 4);
                    p.getPackets().modifyText("Could you sell me a Skillcape of Agility?.", 235, 5);
                    p.getPackets().modifyText("See you later.", 235, 6);
                    newStatus = 7;
                    break;

                case 7:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What is this place?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 8;
                    break;

                case 8:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("This, me hearty, is the entrance to the Brimhaven", 242, 4);
                    p.getPackets().modifyText("Agility Arena!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 9;
                    break;

                case 9:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("I were diggin for buried treasure when I found it!", 242, 4);
                    p.getPackets().modifyText("Amazed I was! It was a sight to behold!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 10;
                    break;

                case 10:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Buried treasure!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 11;
                    break;

                case 11:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("It were the biggest thing i'd ever seen! It must've been", 242, 4);
                    p.getPackets().modifyText("atleast a league from side to side!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 12;
                    break;

                case 12:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("It made me list, I were that excited!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 13;
                    break;

                case 13:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Get on with it!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 14;
                    break;

                case 14:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("I'd found a huge cave with all these platforms. I reckon", 244, 4);
                    p.getPackets().modifyText("it be an ancient civilisation that made it. I had to be", 244, 5);
                    p.getPackets().modifyText("mighty careful as there was these traps everywhere!", 244, 6);
                    p.getPackets().modifyText("Dangerous it was!", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 15;
                    break;

                case 15:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Danger! Danger!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 16;
                    break;

                case 16:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Entrance is only " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 6;
                    break;

                case 17:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What do I do in the arena?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 18;
                    break;

                case 18:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("Well, me hearty, it's simple. Ye can cross between two", 244, 4);
                    p.getPackets().modifyText("platforms by using the traps or obstacles strung across", 244, 5);
                    p.getPackets().modifyText("'em. Try and make your way to the pillar that is", 244, 6);
                    p.getPackets().modifyText("indicated by the flashing arrow.", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 19;
                    break;

                case 19:
                    p.getPackets().sendNPCHead(437, 243, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 243, 3);
                    p.getPackets().modifyText("Ye receive tickets for tagging more than one pillar in a", 243, 4);
                    p.getPackets().modifyText("row. So ye won't get a ticket from the first pillar but", 243, 5);
                    p.getPackets().modifyText("ye will for every platform ye tag in a row after that.", 243, 6);
                    p.getPackets().animateInterface(9827, 243, 2);
                    p.getPackets().sendChatboxInterface2(243);
                    newStatus = 20;
                    break;

                case 20:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    p.getPackets().modifyText("If ye miss a platform ye will miss out on the next ticket", 244, 4);
                    p.getPackets().modifyText("so try and get every platform you can! When ye be", 244, 5);
                    p.getPackets().modifyText("done, take the tickets to Jackie over there and she'll", 244, 6);
                    p.getPackets().modifyText("exchange them for experience or items.", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 21;
                    break;

                case 21:
                    p.getPackets().sendNPCHead(4535, 242, 1);
                    p.getPackets().modifyText("Parrot", 242, 3);
                    p.getPackets().modifyText("Tag when green light means tickets!", 242, 4);
                    p.getPackets().modifyText("Tag when red light means green light!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 1);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 22;
                    break;

                case 22:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Thanks me hearty!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 23;
                    break;

                case 23:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Thanks!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 6;
                    break;

                case 24:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'd like to use the Agility Arena, please.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 25;
                    break;

                case 25:
                    string message = "";
                    if (p.hasPaidAgilityArena())
                    {
                        message = "Ye've already paid, so down ye goes...";
                    }
                    else
                    {
                        message = "Aye, Entrance be " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.";
                        newStatus = 26;
                    }
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText(message, 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 26:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("Pieces of eight!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 27;
                    break;

                case 27:
                    p.getPackets().sendNPCHead(437, 242, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                    p.getPackets().modifyText("A word of warning me hearty! There are dangerous", 242, 4);
                    p.getPackets().modifyText("traps down there!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 28;
                    break;

                case 28:
                    if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE))
                    {
                        p.getPackets().sendPlayerHead(64, 2);
                        p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                        p.getPackets().modifyText("I don't have enough money on me at the moment..", 64, 4);
                        p.getPackets().animateInterface(9827, 64, 2);
                        p.getPackets().sendChatboxInterface2(64);
                        newStatus = 31;
                        break;
                    }
                    p.getPackets().modifyText("Ok, here's " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.", 228, 2);
                    p.getPackets().modifyText("Never mind.", 228, 3);
                    p.getPackets().sendChatboxInterface(228);
                    newStatus = 29;
                    break;

                case 29:
                    if (p.getInventory().deleteItem(995, AGILITY_ARENA_PRICE))
                    {
                        p.setPaidAgilityArena(true);
                    }
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ok, here's " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 30;
                    break;

                case 30:
                    p.getPackets().sendMessage("You pay Cap'n Izzy " + AGILITY_ARENA_PRICE.ToString("#,##0") + " coins.");
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("May the wind be in ye sails!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 31:
                    p.getPackets().sendNPCHead(4535, 241, 1);
                    p.getPackets().modifyText("Parrot", 241, 3);
                    p.getPackets().modifyText("*Squawk*", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 1);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 32;
                    break;

                case 32:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("No coins, no entrance!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 33:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Never mind.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    break;

                case 34:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Could you sell me a Skillcape of Agility?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 35;
                    break;

                case 35:
                    p.getPackets().sendNPCHead(437, 244, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 244, 3);
                    if (p.getSkills().getMaxLevel(Skills.SKILL.AGILITY) < 99)
                    {
                        p.getPackets().modifyText("Unfortunatly not. I may only sell the Skillcape of Agility", 244, 4);
                        p.getPackets().modifyText("to those that have conquered the obstacles of Runescape,", 244, 5);
                        p.getPackets().modifyText("can climb like a cat and run like the wind! which err..", 244, 6);
                        p.getPackets().modifyText("isnt you. Is there anything else?", 244, 7);
                        newStatus = 6;
                    }
                    else
                    {
                        p.getPackets().modifyText("Indeed! You have reached level 99 Agility and have", 244, 4);
                        p.getPackets().modifyText("become a master of dexterity. It would be a pleasure", 244, 5);
                        p.getPackets().modifyText("to sell you an Agility skillcape and hood for a sum of", 244, 6);
                        p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 244, 7);
                        newStatus = 36;
                    }
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    break;

                case 36:
                    p.getPackets().modifyText("I'll pay " + SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 228, 2);
                    p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " is a crazy price!", 228, 3);
                    p.getPackets().sendChatboxInterface(228);
                    newStatus = 37;
                    break;

                case 37:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'll pay " + SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " coins.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 38;
                    break;

                case 38:
                    if (p.getInventory().getTotalFreeSlots() < 2)
                    {
                        p.getPackets().sendNPCHead(437, 241, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                        p.getPackets().modifyText("Ye require 2 free inventory spaces!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                        break;
                    }
                    if (p.getInventory().deleteItem(995, SkillHandler.SKILLCAPE_PRICE))
                    {
                        int cape = p.getSkills().hasMultiple99s() ? 9772 : 9771;
                        int hood = 9773;
                        p.getInventory().addItem(cape);
                        p.getInventory().addItem(hood);
                        p.getPackets().sendNPCHead(437, 242, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 242, 3);
                        p.getPackets().modifyText("One Agility Skillcape & hood.", 242, 4);
                        p.getPackets().modifyText("Wear it with pride.", 242, 5);
                        p.getPackets().animateInterface(9827, 242, 2);
                        p.getPackets().sendChatboxInterface2(242);
                    }
                    else
                    {
                        p.getPackets().sendNPCHead(437, 241, 2);
                        p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                        p.getPackets().modifyText("Ye don't have enough coins!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                    }
                    break;

                case 39:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText(SkillHandler.SKILLCAPE_PRICE.ToString("#,##0") + " is a crazy price!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 40;
                    break;

                case 40:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("I'm sure ye will change your mind eventually..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 41:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("See you later.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 42;
                    break;

                case 42:
                    p.getPackets().sendNPCHead(437, 241, 2);
                    p.getPackets().modifyText("Cap'n Izzy No-Beard", 241, 3);
                    p.getPackets().modifyText("Aye, goodbye " + p.getLoginDetails().getUsername() + ".", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                /*
                 * NOW TALKING TO JACKIE THE FRUIT
                 */

                case 43:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Ahoy there!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 44;
                    break;

                case 44:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Ahoy!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 45;
                    break;

                case 45:
                    p.getPackets().sendChatboxInterface2(232);
                    p.getPackets().modifyText("What is this place?", 232, 2);
                    p.getPackets().modifyText("What do you do?", 232, 3);
                    p.getPackets().modifyText("I'd like to trade in my tickets, please.", 232, 4);
                    p.getPackets().modifyText("See you later.", 232, 5);
                    newStatus = 46;
                    break;

                case 46:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Welcome to the Brimhaven Agility Arena!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 47;
                    break;

                case 47:
                    p.getPackets().sendNPCHead(1055, 242, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 242, 3);
                    p.getPackets().modifyText("If ye want to know more, talk to Cap'n Izzy, after", 242, 4);
                    p.getPackets().modifyText("all... he did find it!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 2);
                    p.getPackets().sendChatboxInterface2(242);
                    newStatus = 45;
                    break;

                case 48:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("What do you do?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 49;
                    break;

                case 49:
                    p.getPackets().sendNPCHead(1055, 244, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 244, 3);
                    p.getPackets().modifyText("I be the jack o' tickets. I exchange the tickets ye", 244, 4);
                    p.getPackets().modifyText("Collect in the Agility arena for more stuff. Ye can", 244, 5);
                    p.getPackets().modifyText("obtain more Agility experience or items ye won't", 244, 6);
                    p.getPackets().modifyText("find anywhere else!", 244, 7);
                    p.getPackets().animateInterface(9827, 244, 2);
                    p.getPackets().sendChatboxInterface2(244);
                    newStatus = 50;
                    break;

                case 50:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Sounds good!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 45;
                    break;

                case 51:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'd like to trade in my tickets, please.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 52;
                    break;

                case 52:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Aye, ye be on the right track.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 53;
                    break;

                case 53:
                    p.getPackets().displayInterface(6);
                    break;

                case 54:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("See you later.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 55;
                    break;

                case 55:
                    p.getPackets().sendNPCHead(1055, 241, 2);
                    p.getPackets().modifyText("Pirate Jackie the Fruit", 241, 3);
                    p.getPackets().modifyText("Goodbye.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Exemplo n.º 22
0
        private void handleClickSeven(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 7: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 762: // Bank - All but one.
                    player.getBank().withdraw(slot, player.getBank().getAmountInSlot(slot) - 1);
                    player.getBank().refreshBank();
                    break;

                case 336: // Trade inventory - trade all.
                    //player.getTrade().lendItem(slot);
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - captain.
                            clan.setEnterRights(Clan.ClanRank.CAPTAIN);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - captain.
                            clan.setTalkRights(Clan.ClanRank.CAPTAIN);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 25: // // "Who can kick in chat" - captain.
                            clan.setKickRights(Clan.ClanRank.CAPTAIN);
                            player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
                            break;

                        case 26: // "Who can share loot" - captain.
                            clan.setLootRights(Clan.ClanRank.CAPTAIN);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 23
0
        public ReturnCode loadPlayer(Connection connection)
        {
            if (connection == null)
                return ReturnCode.COULD_NOT_COMPLETE;
            LoginDetails loginDetails = connection.getLoginDetails();
            if (loginDetails == null || loginDetails.getUsername() == "" || loginDetails.getLongName() == 0)
                return ReturnCode.INVALID_PASSWORD;//ReturnCode.INVALID_PASSWORD;

            foreach (char c in loginDetails.getUsername().ToCharArray())
            {
                if (!char.IsLetterOrDigit(c) && !char.IsWhiteSpace(c))
                    return ReturnCode.INVALID_PASSWORD;
            }
            Player createdPlayer = new Player(connection);
            connection.setPlayer(createdPlayer); //player finally created.
            createdPlayer.setLoginDetails(loginDetails);

            if (!File.Exists(Misc.getServerPath() + @"\accounts\" + loginDetails.getUsername() + ".xml"))
            {
                createdPlayer.setRights(2); //all new users admins atm (change later).
                createdPlayer.setLocation(new Location(2323, 3174, 0));
                return ReturnCode.LOGIN_OK; //new user.
            }
            //Yeah reading XML files is a bit h**o.
            try
            {
                int temp;
                long lTemp;
                string username = createdPlayer.getLoginDetails().getUsername().ToLower();
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Misc.getServerPath() + @"\accounts\" + username + ".xml");

                XmlNode xmlNode = xmlDocument.SelectSingleNode("/Player/Login/Password");
                if (xmlNode == null) return ReturnCode.INVALID_PASSWORD; //no password node.
                if (createdPlayer.getLoginDetails().getPassword() != xmlNode.InnerText)
                    return ReturnCode.INVALID_PASSWORD;

                XmlNode loginElement = xmlDocument.SelectSingleNode("/Player/Login");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Rights":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                createdPlayer.setRights(temp);
                                break;

                            case "BankPin":
                                if (element.InnerText == "") continue;
                                createdPlayer.getBank().setBankPin(element.InnerText);
                                break;
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Position");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Location location = new Location();
                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "X":
                                if (!int.TryParse(element.InnerText, out temp))
                                {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setX(temp);
                                break;

                            case "Y":
                                if (!int.TryParse(element.InnerText, out temp))
                                {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setY(temp);
                                break;

                            case "Z":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                location.setZ(temp);
                                break;
                        }
                    }
                    createdPlayer.setLocation(location);
                    if (Location.atDuelArena(createdPlayer.getLocation()))
                        DuelSession.teleportDuelArenaHome(createdPlayer);
                }

                xmlNode = xmlDocument.SelectSingleNode("/Player/Settings/RunEnergy");
                if (xmlNode == null)
                {
                    temp = 100;
                }
                else
                {
                    if (!int.TryParse(xmlNode.InnerText, out temp))
                        temp = 100;
                }
                createdPlayer.setRunEnergyLoad(temp);

                loginElement = xmlDocument.SelectSingleNode("/Player/Settings/PrivacySettings");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Friends.STATUS publicStatus = Friends.STATUS.ON, privateStatus = Friends.STATUS.ON, tradeStatus = Friends.STATUS.ON;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Public":
                                publicStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;

                            case "Private":
                                privateStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;

                            case "Trade":
                                tradeStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;
                        }
                    }
                    createdPlayer.getFriends().setPrivacyOptions(publicStatus, privateStatus, tradeStatus);
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Friends");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if (element.Name == "Friend")
                        {
                            if (long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getFriendsList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Ignores");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if (element.Name == "Ignore")
                        {
                            if (long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getIgnoresList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Stats");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;
                    foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                    {
                        skillNode = loginElement.SelectSingleNode("/Player/Stats/" + skill.ToString());

                        foreach (XmlElement element in skillNode.ChildNodes)
                        { //CurrentLevel/XP
                            switch (element.Name)
                            {
                                case "CurrentLevel":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setCurLevel(skill, 1);
                                        else
                                            createdPlayer.getSkills().setCurLevel(skill, 10);
                                        break;
                                    }
                                    createdPlayer.getSkills().setCurLevel(skill, temp);
                                    break;

                                case "XP":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setXp(skill, 0);
                                        else
                                            createdPlayer.getSkills().setXp(skill, 1184);
                                        break;
                                    }
                                    createdPlayer.getSkills().setXp(skill, temp);
                                    break;
                            }
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/EquipmentItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;

                    foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
                    {
                        if (equip == ItemData.EQUIP.NOTHING) continue;
                        skillNode = loginElement.SelectSingleNode("/Player/EquipmentItems/" + equip.ToString());
                        if (skillNode == null) continue;
                        int id = -1, amount = 0;
                        foreach (XmlElement element in skillNode.ChildNodes)
                        {
                            switch (element.Name)
                            {
                                case "Id":
                                    if (!int.TryParse(element.InnerText, out id))
                                        id = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(element.InnerText, out amount))
                                        amount = 0;
                                    break;
                            }
                        }
                        if (id != -1)
                        {
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemId(id);
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemAmount(amount);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/InventoryItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;

                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1)
                        {
                            createdPlayer.getInventory().getItems()[slot].setItemId(id);
                            createdPlayer.getInventory().getItems()[slot].setItemAmount(amount);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/BankItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;

                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;

                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1)
                        {
                            createdPlayer.getBank().getBank()[slot].setItemId(id);
                            createdPlayer.getBank().getBank()[slot].setItemAmount(amount);
                        }
                    }
                }

                return ReturnCode.LOGIN_OK; //new user.
            }
            catch (Exception e)
            {
                Misc.WriteError(e.Message);
                return ReturnCode.COULD_NOT_COMPLETE;
            }
        }
Exemplo n.º 24
0
        private void handleClickSix(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 6: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 763: // Bank inventory - All.
                    player.getBank().deposit(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot)));
                    player.getBank().refreshBank();
                    break;

                case 762: // Bank - All.
                    player.getBank().withdraw(slot, player.getBank().getAmountInSlot(slot));
                    player.getBank().refreshBank();
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - lieutenant.
                            clan.setEnterRights(Clan.ClanRank.LIEUTENANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - lieutenant.
                            clan.setTalkRights(Clan.ClanRank.LIEUTENANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 25: // // "Who can kick in chat" - lieutenant.
                            clan.setKickRights(Clan.ClanRank.LIEUTENANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
                            break;

                        case 26: // "Who can share loot" - lieutenant.
                            clan.setLootRights(Clan.ClanRank.LIEUTENANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 25
0
        private void handleActionButton(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            ushort buttonId = packet.readUShort();
            ushort buttonId2 = 0;
            if (packet.getLength() >= 6)
            {
                buttonId2 = packet.readUShort();
            }
            if (buttonId2 == 65535)
            {
                buttonId2 = 0;
            }
            Console.WriteLine("button = " + interfaceId + " " + buttonId + " " + buttonId2);
            switch (interfaceId)
            {
                case 389: // GE Item Search
                    if (player.getGESession() != null)
                    {
                        if (player.getGESession().getCurrentOffer() != null)
                        {
                            if (player.getGESession().getCurrentOffer() is BuyOffer)
                            {
                                player.getPackets().sendInterface(0, 752, 6, 137); // Removes the item search
                            }
                        }
                    }
                    break;

                case 374: // Tzhaar fight pits viewing orb
                    Server.getMinigames().getFightPits().useOrb(player, buttonId);
                    break;

                case 107: // GE Sell inventory.
                    if (player.getGESession() == null)
                    {
                        break;
                    }
                    switch (buttonId)
                    {
                        case 18: // Offer
                            player.getGESession().offerSellItem(buttonId2);
                            break;
                    }
                    break;

                case 105: // GE interface
                    if (player.getGESession() == null)
                    {
                        break;
                    }
                    switch (buttonId)
                    {
                        case 209: // Collect-notes
                            player.getGESession().collectSlot1(true);
                            break;

                        case 203: // Abort offer
                            player.getGESession().abortOffer();
                            break;

                        case 31: // Sell, box 1
                            player.getGESession().newSellOffer(0);
                            break;

                        case 30: // Buy, box 1
                            player.getGESession().newBuyOffer(0);
                            break;

                        case 18: // Check status, box 1
                            player.getGESession().checkOffer(0);
                            break;

                        case 46: // Buy, box 2
                            player.getGESession().newBuyOffer(1);
                            break;

                        case 47: // Sell, box 2
                            player.getGESession().newSellOffer(1);
                            break;

                        case 34: // Check status, box 2
                            player.getGESession().checkOffer(1);
                            break;

                        case 62: // Buy, box 3
                            player.getGESession().newBuyOffer(2);
                            break;

                        case 63: // Sell, box 3
                            player.getGESession().newSellOffer(2);
                            break;

                        case 50: // Check status, box 3
                            player.getGESession().checkOffer(2);
                            break;

                        case 81: // Buy, box 4
                            player.getGESession().newBuyOffer(3);
                            break;

                        case 82: // Sell, box 4
                            player.getGESession().newSellOffer(3);
                            break;

                        case 69: // Check status, box 4
                            player.getGESession().checkOffer(3);
                            break;

                        case 100: // Buy, box 5
                            player.getGESession().newBuyOffer(4);
                            break;

                        case 101: // Sell, box 5
                            player.getGESession().newSellOffer(4);
                            break;

                        case 88: // Check status, box 5
                            player.getGESession().checkOffer(4);
                            break;

                        case 119: // Buy, box 6
                            player.getGESession().newBuyOffer(5);
                            break;

                        case 120: // Sell, box 6
                            player.getGESession().newSellOffer(5);
                            break;

                        case 107: // Check status, box 6
                            player.getGESession().checkOffer(5);
                            break;

                        case 127: // The "back" button
                            player.getPackets().closeInterfaces();
                            player.setGESession(new GESession(player));
                            break;

                        case 194: // Search for item
                            player.getGESession().openItemSearch();
                            break;

                        case 159: // Increment amount by 1
                            player.getGESession().incrementAmount(1);
                            break;

                        case 157: // Decrease amount by 1
                            player.getGESession().decreaseAmount(1);
                            break;

                        case 162: // Increase amount by +1
                            player.getGESession().incrementAmount(1);
                            break;

                        case 164: // Increase amount by +10
                            player.getGESession().incrementAmount(10);
                            break;

                        case 166: // Increase amount by +100
                            player.getGESession().incrementAmount(100);
                            break;

                        case 168: // Increase amount by +1k (or All if selling)
                            player.getGESession().incrementAmount(1000);
                            break;

                        case 170: //custom enter quantity
                            player.getPackets().displayEnterAmount();
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(105, 0));
                            break;

                        case 185: //custom enter per price
                            player.getPackets().displayEnterAmount();
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(105, 1));
                            break;

                        case 177: // Set price to minimum
                            player.getGESession().setPrice(0);
                            break;

                        case 180: // Set price to medium
                            player.getGESession().setPrice(1);
                            break;

                        case 183: // Set price to maximum
                            player.getGESession().setPrice(2);
                            break;

                        case 171: // Set price -1
                            player.getGESession().setPrice(3);
                            break;

                        case 173: // Set price +1
                            player.getGESession().setPrice(4);
                            break;

                        case 190: // Confirm offer
                            player.getGESession().confirmOffer();
                            break;
                    }
                    break;

                case 161: // Slayer points interfaces
                case 163:
                case 164:
                    Slayer.handlePointsInterface(player, interfaceId, buttonId);
                    break;

                case 675: // Craft jewellery:
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(675, buttonId));
                    break;

                case 154: // Craft normal leather.
                    Leather.craftNormalLeather(player, buttonId, 1, true);
                    break;

                case 542: // Craft glass.
                    switch (buttonId)
                    {
                        case 40: // Make 1 beer glass.
                            Glass.craftGlass(player, 1, 0, true);
                            break;

                        case 41: // Make 1 candle lantern.
                            Glass.craftGlass(player, 1, 1, true);
                            break;

                        case 42: // Make 1 oil lamp.
                            Glass.craftGlass(player, 1, 2, true);
                            break;

                        case 38: // Make 1 vial.
                            Glass.craftGlass(player, 1, 3, true);
                            break;

                        case 44: // Make 1 Fishbowl
                            Glass.craftGlass(player, 1, 4, true);
                            break;

                        case 39: // Make 1 orb.
                            Glass.craftGlass(player, 1, 5, true);
                            break;

                        case 43: // Make 1 lantern lens
                            Glass.craftGlass(player, 1, 6, true);
                            break;

                        case 45: // Make 1 dorgeshuun light orb.
                            Glass.craftGlass(player, 1, 7, true);
                            break;
                    }
                    break;

                case 271: // Prayer tab.
                    if (!Prayer.canUsePrayer(player, buttonId))
                    {
                        Prayer.deactivateAllPrayers(player);
                        break;
                    }
                    switch (buttonId)
                    {
                        case 5: // Thick skin.
                            Prayer.togglePrayer(player, 1, 1);
                            break;

                        case 15: // Rock skin.
                            Prayer.togglePrayer(player, 1, 2);
                            break;

                        case 31: // Steel skin.
                            Prayer.togglePrayer(player, 1, 3);
                            break;

                        case 7: // Burst of strength.
                            Prayer.togglePrayer(player, 2, 1);
                            break;

                        case 17: // Superhuman strength.
                            Prayer.togglePrayer(player, 2, 2);
                            break;

                        case 33: // Ultimate strength.
                            Prayer.togglePrayer(player, 2, 3);
                            break;

                        case 9: // Clarity of thought.
                            Prayer.togglePrayer(player, 3, 1);
                            break;

                        case 19: // Improved reflexes.
                            Prayer.togglePrayer(player, 3, 2);
                            break;

                        case 35: // Incredible reflexes.
                            Prayer.togglePrayer(player, 3, 3);
                            break;

                        case 37: // Magic protect.
                            Prayer.togglePrayer(player, 4, 1);
                            break;

                        case 39: // Ranged protect.
                            Prayer.togglePrayer(player, 4, 2);
                            break;

                        case 41: // Melee protect.
                            Prayer.togglePrayer(player, 4, 3);
                            break;

                        case 47: // Retribution.
                            Prayer.togglePrayer(player, 4, 4);
                            break;

                        case 49: // Redemption.
                            Prayer.togglePrayer(player, 4, 5);
                            break;

                        case 51: // Smite.
                            Prayer.togglePrayer(player, 4, 6);
                            break;

                        case 55: // Chivalry.
                            Prayer.togglePrayer(player, 5, 1);
                            break;

                        case 57: // Piety.
                            Prayer.togglePrayer(player, 5, 2);
                            break;

                        case 25: // Protect item.
                            Prayer.togglePrayer(player, 6, 1);
                            break;

                        case 21: // Rapid restore
                            Prayer.togglePrayer(player, 7, 1);
                            break;

                        case 23: // Rapid heal.
                            Prayer.togglePrayer(player, 7, 2);
                            break;

                        case 11: // Sharp eye.
                            Prayer.togglePrayer(player, 8, 1);
                            break;

                        case 27: // Hawk Eye.
                            Prayer.togglePrayer(player, 8, 2);
                            break;

                        case 43: // Eagle Eye.
                            Prayer.togglePrayer(player, 8, 3);
                            break;

                        case 13: // Mystic will.
                            Prayer.togglePrayer(player, 9, 1);
                            break;

                        case 29: // Mystic Lore.
                            Prayer.togglePrayer(player, 9, 2);
                            break;

                        case 45: // Mystic Might.
                            Prayer.togglePrayer(player, 9, 3);
                            break;
                    }
                    break;

                case 90: // Staff attack interface.
                    switch (buttonId)
                    {
                        case 5: // Select spell (Magic XP)
                            MagicData.configureSelectSpellInterface(player);
                            break;

                        case 9: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            MagicData.cancelAutoCast(player, true);
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 388: // Ancient magic autocast select spell.
                    switch (buttonId)
                    {
                        case 0: // Smoke rush.
                            MagicData.setAutoCastSpell(player, 16, 8, true);
                            break;

                        case 1: // Shadow rush.
                            MagicData.setAutoCastSpell(player, 17, 12, true);
                            break;

                        case 2: // Blood rush.
                            MagicData.setAutoCastSpell(player, 18, 4, true);
                            break;

                        case 3: // Ice rush.
                            MagicData.setAutoCastSpell(player, 19, 0, true);
                            break;

                        case 4: // Smoke burst.
                            MagicData.setAutoCastSpell(player, 20, 10, true);
                            break;

                        case 5: // Shadow burst.
                            MagicData.setAutoCastSpell(player, 21, 14, true);
                            break;

                        case 6: // Blood burst.
                            MagicData.setAutoCastSpell(player, 22, 6, true);
                            break;

                        case 7: // Ice burst.
                            MagicData.setAutoCastSpell(player, 23, 2, true);
                            break;

                        case 8: // Smoke blitz.
                            MagicData.setAutoCastSpell(player, 24, 9, true);
                            break;

                        case 9: // Shadow blitz.
                            MagicData.setAutoCastSpell(player, 25, 13, true);
                            break;

                        case 10: // Blood blitz.
                            MagicData.setAutoCastSpell(player, 26, 5, true);
                            break;

                        case 11: // Ice blitz.
                            MagicData.setAutoCastSpell(player, 27, 1, true);
                            break;

                        case 12: // Smoke barrage.
                            MagicData.setAutoCastSpell(player, 28, 11, true);
                            break;

                        case 13: // Shadow barrage.
                            MagicData.setAutoCastSpell(player, 29, 15, true);
                            break;

                        case 14: // Blood barrage.
                            MagicData.setAutoCastSpell(player, 30, 7, true);
                            break;

                        case 15: // Ice barrage.
                            MagicData.setAutoCastSpell(player, 31, 3, true);
                            break;

                        case 16: // Cancel.
                            MagicData.cancelAutoCast(player, false);
                            break;
                    }
                    break;

                case 406: // Void knight mace autocast select spell.
                    switch (buttonId)
                    {
                        case 0: // Crumble undead.
                            MagicData.setAutoCastSpell(player, 32, 22, false);
                            break;

                        case 1: // Guthix claws.
                            MagicData.setAutoCastSpell(player, 34, 42, false);
                            break;

                        case 2: // Wind wave.
                            MagicData.setAutoCastSpell(player, 12, 45, false);
                            break;

                        case 3: // Water wave.
                            MagicData.setAutoCastSpell(player, 13, 48, false);
                            break;

                        case 4: // Earth wave.
                            MagicData.setAutoCastSpell(player, 14, 52, false);
                            break;

                        case 5: // Fire wave.
                            MagicData.setAutoCastSpell(player, 15, 55, false);
                            break;

                        case 6: // Cancel.
                            MagicData.cancelAutoCast(player, false);
                            break;
                    }
                    break;

                case 310: // Slayer staff autocast select spell.
                    switch (buttonId)
                    {
                        case 0: // Crumble undead.
                            MagicData.setAutoCastSpell(player, 32, 22, false);
                            break;

                        case 1: // Slayer dart.
                            MagicData.setAutoCastSpell(player, 33, 31, false);
                            break;

                        case 2: // Wind wave.
                            MagicData.setAutoCastSpell(player, 12, 45, false);
                            break;

                        case 3: // Water wave.
                            MagicData.setAutoCastSpell(player, 13, 48, false);
                            break;

                        case 4: // Earth wave.
                            MagicData.setAutoCastSpell(player, 14, 52, false);
                            break;

                        case 5: // Fire wave.
                            MagicData.setAutoCastSpell(player, 15, 55, false);
                            break;

                        case 6: // Cancel.
                            MagicData.cancelAutoCast(player, false);
                            break;
                    }
                    break;

                case 319: // Normal magic autocast select spell.
                    switch (buttonId)
                    {
                        case 0: // Wind strike.
                            MagicData.setAutoCastSpell(player, 0, 1, false);
                            break;

                        case 1: // Water strike.
                            MagicData.setAutoCastSpell(player, 1, 4, false);
                            break;

                        case 2: // Earth strike.
                            MagicData.setAutoCastSpell(player, 2, 6, false);
                            break;

                        case 3: // Fire strike.
                            MagicData.setAutoCastSpell(player, 3, 8, false);
                            break;

                        case 4: // Wind bolt.
                            MagicData.setAutoCastSpell(player, 4, 10, false);
                            break;

                        case 5: // Water bolt.
                            MagicData.setAutoCastSpell(player, 5, 14, false);
                            break;

                        case 6: // Earth bolt.
                            MagicData.setAutoCastSpell(player, 6, 17, false);
                            break;

                        case 7: // Fire bolt.
                            MagicData.setAutoCastSpell(player, 7, 20, false);
                            break;

                        case 8: // Wind blast.
                            MagicData.setAutoCastSpell(player, 8, 24, false);
                            break;

                        case 9: // Water blast.
                            MagicData.setAutoCastSpell(player, 9, 27, false);
                            break;

                        case 10: // Earth blast.
                            MagicData.setAutoCastSpell(player, 10, 33, false);
                            break;

                        case 11: // Fire blast.
                            MagicData.setAutoCastSpell(player, 11, 38, false);
                            break;

                        case 12: // Wind wave.
                            MagicData.setAutoCastSpell(player, 12, 45, false);
                            break;

                        case 13: // Water wave.
                            MagicData.setAutoCastSpell(player, 13, 48, false);
                            break;

                        case 14: // Earth wave.
                            MagicData.setAutoCastSpell(player, 14, 52, false);
                            break;

                        case 15: // Fire wave.
                            MagicData.setAutoCastSpell(player, 15, 55, false);
                            break;

                        case 16: // Cancel.
                            MagicData.cancelAutoCast(player, false);
                            break;
                    }
                    break;

                case 182: // Logout tab.
                    player.getPackets().logout();
                    break;

                case 261: // Settings tab.
                    switch (buttonId)
                    {
                        case 16: // Display settings.
                            player.getPackets().displayInterface(742);
                            break;

                        case 18: // Audio settings.
                            player.getPackets().displayInterface(743);
                            break;

                        case 3: // Run toggle.
                            if (!player.getWalkingQueue().isRunToggled())
                            {
                                player.getWalkingQueue().setRunToggled(true);
                                player.getPackets().sendConfig(173, 1);
                            }
                            else
                            {
                                player.getWalkingQueue().setRunToggled(false);
                                player.getPackets().sendConfig(173, 0);
                            }
                            break;

                        case 4: // Chat effect toggle.
                            if (!player.isChatEffectsEnabled())
                            {
                                player.setChatEffectsEnabled(true);
                                player.getPackets().sendConfig(171, 0);
                            }
                            else
                            {
                                player.setChatEffectsEnabled(false);
                                player.getPackets().sendConfig(171, 1);
                            }
                            break;

                        case 5: // Split private chat toggle.
                            if (!player.isPrivateChatSplit())
                            {
                                player.setPrivateChatSplit(true);
                                player.getPackets().sendConfig(287, 1);
                            }
                            else
                            {
                                player.setPrivateChatSplit(false);
                                player.getPackets().sendConfig(287, 0);
                            }
                            break;

                        case 7: // Accept aid toggle.
                            if (!player.isAcceptAidEnabled())
                            {
                                player.setAcceptAidEnabled(true);
                                player.getPackets().sendConfig(427, 1);
                            }
                            else
                            {
                                player.setAcceptAidEnabled(false);
                                player.getPackets().sendConfig(427, 0);
                            }
                            break;

                        case 6: // Mouse buttons toggle.
                            if (!player.isMouseTwoButtons())
                            {
                                player.setMouseTwoButtons(true);
                                player.getPackets().sendConfig(170, 0);
                            }
                            else
                            {
                                player.setMouseTwoButtons(false);
                                player.getPackets().sendConfig(170, 1);
                            }
                            break;
                    }
                    break;

                case 589: // Clan chat
                    if (buttonId == 9)
                    {
                        foreach (long friend in player.getFriends().getFriendsList())
                        {
                            player.getPackets().sendFriend(friend, player.getFriends().getWorld(friend));
                        }
                        Server.getClanManager().openClanSetup(player);
                        break;
                    }
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        break;
                    }
                    switch (buttonId)
                    {
                        case 22: // Clan name
                            player.getPackets().displayEnterText("Enter clan name :");
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(590, 0));
                            break;

                        case 23: // "Who can enter chat" - anyone.
                            clan.setEnterRights(Clan.ClanRank.NO_RANK);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - anyone.
                            clan.setTalkRights(Clan.ClanRank.NO_RANK);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 26: // "Who can share loot" - anyone.
                            clan.setLootRights(Clan.ClanRank.NO_RANK);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;

                case 763: // Bank inventory
                    switch (buttonId)
                    {
                        case 0: // Deposit 1.
                            player.getBank().deposit(buttonId2, 1);
                            player.getBank().refreshBank();
                            break;
                    }
                    break;

                case 762: // Bank
                    switch (buttonId)
                    {
                        case 73: // withdraw 1.
                            player.getBank().withdraw(buttonId2, 1);
                            player.getBank().refreshBank();
                            break;

                        case 16: // Note item.
                            player.getBank().asNote();
                            break;

                        case 41: // first (main) bank tab
                            player.getBank().setCurrentTab(10);
                            break;

                        case 39: // first bank tab
                            player.getBank().setCurrentTab(2);
                            break;

                        case 37: // second bank tab
                            player.getBank().setCurrentTab(3);
                            break;

                        case 35: // third bank tab
                            player.getBank().setCurrentTab(4);
                            break;

                        case 33: // fourth bank tab
                            player.getBank().setCurrentTab(5);
                            break;

                        case 31: // fifth bank tab
                            player.getBank().setCurrentTab(6);
                            break;

                        case 29: // sixth bank tab
                            player.getBank().setCurrentTab(7);
                            break;

                        case 27: // seventh bank tab
                            player.getBank().setCurrentTab(8);
                            break;

                        case 25: // eighth bank tab
                            player.getBank().setCurrentTab(9);
                            break;
                    }
                    break;

                case 626: // Stake duel confirmation interface.
                    if (buttonId == 53)
                    {
                        if (player.getDuel() != null)
                        {
                            player.getDuel().acceptDuel();
                            break;
                        }
                    }
                    break;

                case 631: // Stake duel first interface.
                    if (player.getDuel() != null)
                    {
                        if (buttonId == 103)
                        {
                            player.getDuel().removeItem(buttonId2, 1);
                            break;
                        }
                        else
                        {
                            player.getDuel().toggleDuelRules(buttonId);
                            break;
                        }
                    }
                    break;

                case 387: // Equipment tab.
                    switch (buttonId)
                    {
                        case 55: // Character display.
                            player.getEquipment().displayEquipmentScreen();
                            break;

                        case 52: // Items kept on death.
                            ProtectedItems.displayItemsInterface(player);
                            break;
                    }
                    break;

                case 274: // Quest tab.
                    switch (buttonId)
                    {
                        case 3: // Achievment diary toggle.
                            player.getPackets().sendTab(85, 259);
                            player.setAchievementDiaryTab(true);
                            break;
                    }
                    break;

                case 259: // Achievment diary tab.
                    switch (buttonId)
                    {
                        case 8: // Quest tab toggle.
                            player.getPackets().sendTab(85, 274);
                            player.setAchievementDiaryTab(false);
                            break;
                    }
                    break;

                case 620: // Shop interface.
                    if (player.getShopSession() == null)
                    {
                        return;
                    }
                    switch (buttonId)
                    {
                        case 26: // Player stock tab.
                            player.getShopSession().openPlayerShop();
                            break;

                        case 25: // Main stock tab.
                            player.getShopSession().openMainShop();
                            break;

                        case 23: // Value (main stock)
                        case 24: // Value (player stock)
                            player.getShopSession().valueItem(buttonId2, false);
                            break;
                    }
                    break;

                case 621: // Shop inventory.
                    if (player.getShopSession() == null)
                    {
                        return;
                    }
                    switch (buttonId)
                    {
                        case 0: // Value (player stock)
                            player.getShopSession().valueItem(buttonId2, true);
                            break;
                    }
                    break;

                case 192: // Normal Magic tab.
                    switch (buttonId)
                    {
                        case 0: // Home Teleport.
                            Teleport.homeTeleport(player);
                            break;

                        case 15: // Varrock teleport.
                            Teleport.teleport(player, 0);
                            break;

                        case 18: // Lumbridge teleport.
                            Teleport.teleport(player, 1);
                            break;

                        case 21: // Falador teleport.
                            Teleport.teleport(player, 2);
                            break;

                        case 23: // POH teleport.
                            player.getPackets().sendMessage("This teleport is unavailable.");
                            break;

                        case 26: // Camelot teleport.
                            Teleport.teleport(player, 3);
                            break;

                        case 32: // Ardougne teleport.
                            Teleport.teleport(player, 4);
                            break;

                        case 37: // Watchtower teleport.
                            player.getPackets().sendMessage("This teleport is unavailable.");
                            //Teleport.teleport(player, 5);
                            break;

                        case 44: // Trollheim teleport.
                            Teleport.teleport(player, 6);
                            break;

                        case 47: // Ape Atoll teleport.
                            player.getPackets().sendMessage("This teleport is unavailable.");
                            break;

                        case 58: // Charge.
                            MagicCombat.castCharge(player);
                            break;
                    }
                    break;

                case 193: // Ancient magic tab.
                    switch (buttonId)
                    {
                        case 20: // Paddewwa teleport.
                            Teleport.teleport(player, 7);
                            break;

                        case 21: // Senntisten teleport.
                            Teleport.teleport(player, 8);
                            break;

                        case 22: // Kharyrll teleport.
                            Teleport.teleport(player, 9);
                            break;

                        case 23: // Lassar teleport.
                            Teleport.teleport(player, 10);
                            break;

                        case 24: // Dareeyak teleport.
                            Teleport.teleport(player, 11);
                            break;

                        case 25: // Carrallanger teleport.
                            Teleport.teleport(player, 12);
                            break;

                        case 27: // Ghorrock teleport.
                            Teleport.teleport(player, 14);
                            break;

                        case 26: // Annakarl teleport.
                            Teleport.teleport(player, 13);
                            break;

                        case 28: // Ancients Home teleport.
                            Teleport.homeTeleport(player);
                            break;
                    }
                    break;

                case 13: // Bank pin buttons.
                    if (buttonId == 29)
                    {
                        player.getBank().forgotPin();
                        break;
                    }
                    player.getBank().handleEnterPin(buttonId);
                    break;

                case 14: // Bank pin settings.
                    switch (buttonId)
                    {
                        case 60: // Set new bank pin.
                            player.getBank().displayFirstConfirmation();
                            break;

                        case 61: // Change recovery delay.
                            player.getBank().changePinDelay();
                            break;

                        case 91: // "No, I might forget it!".
                            if (player.getBank().isPinPending())
                            {
                                player.getBank().cancelPendingPin();
                                break;
                            }
                            player.getBank().openPinSettings(2);
                            break;

                        case 89: // Yes i want to set a pin.
                            if (player.getBank().isPinPending())
                            {
                                player.getBank().verifyPin(true);
                                break;
                            }
                            player.getBank().openEnterPin();
                            break;

                        case 65: // Cancel pin that's pending.
                            player.getBank().openPinSettings(4);
                            break;

                        case 62: // Change pin.
                            player.getBank().changePin();
                            break;

                        case 63: // Delete pin.
                            player.getBank().deletePin();
                            break;
                    }
                    break;

                case 464: // Emote tab.
                    Emotes.emote(player, buttonId);
                    break;

                case 320: // Skills Tab.
                    SkillMenu.display(player, buttonId);
                    break;

                case 499: // Skill menu side menu.
                    SkillMenu.subMenu(player, buttonId);
                    break;

                case 336: // Trade/duel inventory - trade 1.
                    if (player.getTrade() != null)
                    {
                        player.getTrade().tradeItem(buttonId2, 1);
                        break;
                    }
                    if (player.getDuel() != null)
                    {
                        player.getDuel().stakeItem(buttonId2, 1);
                        break;
                    }
                    break;

                case 335: // Trade interface.
                    if (player.getTrade() == null)
                    {
                        break;
                    }
                    switch (buttonId)
                    {
                        case 16: // Accept trade.
                            player.getTrade().accept();
                            break;

                        case 18: // Decline trade.
                            player.getTrade().decline();
                            break;

                        case 30: // Offer 1
                            player.getTrade().removeItem(buttonId2, 1);
                            break;
                    }
                    break;

                case 334: // Trade confirmation.
                    if (player.getTrade() == null)
                    {
                        break;
                    }
                    switch (buttonId)
                    {
                        case 21: // Decline trade.
                            player.getTrade().decline();
                            break;

                        case 20: // Accept trade.
                            player.getTrade().accept();
                            break;
                    }
                    break;

                case 750: // Run button
                    if (!player.getWalkingQueue().isRunToggled())
                    {
                        player.getWalkingQueue().setRunToggled(true);
                        player.getPackets().sendConfig(173, 1);
                    }
                    else
                    {
                        player.getWalkingQueue().setRunToggled(false);
                        player.getPackets().sendConfig(173, 0);
                    }
                    break;

                case 667: // Equipment/bonuses interface.
                    if (buttonId == 14)
                    {
                        player.getEquipment().unequipItem((ItemData.EQUIP)buttonId2);
                        break;
                    }
                    break;

                case 771: // Character design interface.
                    ConfigureAppearance.sortButton(player, buttonId);
                    break;

                case 311: // Smelt interface.
                    Smelting.smeltOre(player, buttonId, true, -1);
                    break;

                case 300: // Bar smithing interface.
                    Smithing.smithItem(player, buttonId, 1, true);
                    break;

                case 92: // Unarmed attack interface.
                    switch (buttonId)
                    {
                        case 24: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 85: // Spear attack interface.
                    switch (buttonId)
                    {
                        case 8: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 24: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 93: // Whip attack interface.
                    switch (buttonId)
                    {
                        case 8: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 24: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 89: // Dagger attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 82: // Longsword/scimitar attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 78: // Claw attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 81: // Godsword attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 88: // Mace attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 76: // Granite maul attack interface.
                    switch (buttonId)
                    {
                        case 8: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 24: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 77: // Bow attack interface.
                    switch (buttonId)
                    {
                        case 11: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            break;

                        case 27: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 75: // Battleaxe attack interface.
                    switch (buttonId)
                    {
                        case 10: // Special attack.
                            player.getSpecialAttack().toggleSpecBar();
                            player.getSpecialAttack().dragonBattleaxe();
                            break;

                        case 26: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 91: // Thrown weapon
                    switch (buttonId)
                    {
                        case 24: // Auto retaliate.
                            player.toggleAutoRetaliate();
                            break;

                        default:
                            AttackInterface.configureButton(player, interfaceId, buttonId);
                            break;
                    }
                    break;

                case 430: // Lunar interface
                    switch (buttonId)
                    {
                        case 14: // Vengeance
                            Lunar.castLunarSpell(player, buttonId);
                            break;
                    }
                    break;

                case 102: // Items on death interface
                    if (buttonId == 18)
                        player.getPackets().sendMessage("You will keep this item if you should you die.");
                    else
                        player.getPackets().sendMessage("You will lose this item if you should you die.");
                    break;

                default:
                    if (interfaceId != 548 && interfaceId != 751)
                    {
                        Console.WriteLine("Unhandled ActionButton : " + interfaceId + " " + buttonId + " " + buttonId2);
                    }
                    break;
            }
        }
Exemplo n.º 26
0
        private void handleClickTwo(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 2: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 105: // GE Interface
                    switch (child)
                    {
                        case 209: // "Collect" and "Collect-items" option
                            player.getGESession().collectSlot1(false);
                            break;

                        case 211: // Left box "Collect" option (coins)
                            player.getGESession().collectSlot2();
                            break;
                    }
                    break;

                case 154: // Craft normal leather.
                    Leather.craftNormalLeather(player, child, 5, true);
                    break;

                case 542: // Glassblowing.
                    switch (child)
                    {
                        case 40: // Make 5 beer glass.
                            Glass.craftGlass(player, 5, 0, true);
                            break;

                        case 41: // Make 5 candle lantern.
                            Glass.craftGlass(player, 5, 1, true);
                            break;

                        case 42: // Make 5 oil lamp.
                            Glass.craftGlass(player, 5, 2, true);
                            break;

                        case 38: // Make 5 vial.
                            Glass.craftGlass(player, 5, 3, true);
                            break;

                        case 44: // Make 5 Fishbowl
                            Glass.craftGlass(player, 5, 4, true);
                            break;

                        case 39: // Make 5 orb.
                            Glass.craftGlass(player, 5, 5, true);
                            break;

                        case 43: // Make 5 lantern lens
                            Glass.craftGlass(player, 5, 6, true);
                            break;

                        case 45: // Make 5 dorgeshuun light orb.
                            Glass.craftGlass(player, 5, 7, true);
                            break;
                    }
                    break;

                case 763: // Bank inventory - 5.
                    player.getBank().deposit(slot, 5);
                    player.getBank().refreshBank();
                    break;

                case 762: // Bank - 5.
                    player.getBank().withdraw(slot, 5);
                    player.getBank().refreshBank();
                    break;

                case 336: // Trade/stake inventory - trade 5.
                    if (player.getTrade() != null)
                    {
                        player.getTrade().tradeItem(slot, 5);
                        break;
                    }
                    if (player.getDuel() != null)
                    {
                        player.getDuel().stakeItem(slot, 5);
                        break;
                    }
                    break;

                case 631: // Duel interface - remove 5
                    if (player.getDuel() != null)
                    {
                        player.getDuel().removeItem(slot, 5);
                        break;
                    }
                    break;

                case 335: // Trade interface - remove 5.
                    player.getTrade().removeItem(slot, 5);
                    break;

                case 620: // Shop - buy 1.
                    player.getShopSession().buyItem(slot, 1);
                    break;

                case 621: // Shop - sell 1.
                    player.getShopSession().sellItem(slot, 1);
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - any friends.
                            clan.setEnterRights(Clan.ClanRank.FRIEND);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - any friends.
                            clan.setTalkRights(Clan.ClanRank.FRIEND);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 26: // "Who can share loot" - any friends.
                            clan.setLootRights(Clan.ClanRank.FRIEND);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 27
0
        public static void showBobDialogue(Player p, int status)
        {
            p.getPackets().softCloseInterfaces();
            int index = -1;
            int newStatus = -1;
            if (p.getTemporaryAttribute("bobsAxesBarrowItem") != null)
            {
                int item = (int)p.getTemporaryAttribute("bobsAxesBarrowItem");
                index = getIndex(item);
                if (index == -1)
                {
                    return;
                }
                else if (item == (int)DATA[index][0])
                {
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That item isn't broken..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    return;
                }
                else if (item != (int)DATA[index][1])
                {
                    return;
                }
            }
            switch (status)
            {
                case 101:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That'll cost you " + ((int)DATA[index][2]).ToString("#,##0") + " gold coins to fix, are you sure?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 102;
                    break;

                case 102:
                    p.getPackets().modifyText("Yes, I'm sure!", 557, 2);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 557, 3);
                    p.getPackets().sendChatboxInterface2(557);
                    newStatus = 103;
                    break;

                case 103:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Yes, I'm sure!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 104;
                    break;

                case 104:
                    if (!p.getInventory().hasItemAmount(995, (int)DATA[index][2]))
                    {
                        p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                        p.getPackets().modifyText("Bob", 241, 3);
                        p.getPackets().modifyText("You don't have enough money to pay for the repair!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                        break;
                    }
                    else
                    {
                        if (!p.getInventory().hasItem((int)DATA[index][1]))
                        {
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("The item seems to have gone from your inventory.", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            break;
                        }
                        else if (p.getInventory().deleteItem(995, (int)DATA[index][2]))
                        {
                            p.getInventory().replaceSingleItem((int)DATA[index][1], (int)DATA[index][0]);
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("There you go, happy doing business with you!", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            p.getPackets().sendMessage("You pay Bob his fee and he repairs your " + (string)DATA[index][3] + ".");
                            break;
                        }
                    }
                    break;

                case 105:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 106;
                    break;

                case 106:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Ok, but don't expect my prices to change anytime soon!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 107:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Hello there " + p.getLoginDetails().getUsername() + ", what can i do for you?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 108;
                    break;

                case 108:
                    p.getPackets().modifyText("Could you please repair my Barrow item?", 230, 2);
                    p.getPackets().modifyText("I'm interested in buying an axe.", 230, 3);
                    p.getPackets().modifyText("Nevermind.", 230, 4);
                    p.getPackets().sendChatboxInterface2(230);
                    newStatus = 109;
                    break;

                case 109:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Could you please repair my Barrow item?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 110;
                    break;

                case 110:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Certainly! Show me the item and i'll see what i can do.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 111:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'm interested in buying an axe.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 112;
                    break;

                case 112:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("What a coincidence! Axes are my speciality!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 113;
                    break;

                case 113:
                    //TODO open bob's shop
                    break;

                case 114:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Nevermind.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Exemplo n.º 28
0
        public static void showAliDialogue(Player p, int status)
        {
            int newStatus = -1;
            p.getPackets().softCloseInterfaces();
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            switch (status)
            {
                case 205:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("Would you like to go back to Lletya?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 206;
                    break;

                case 206:
                    p.getPackets().sendChatboxInterface2(228);
                    p.getPackets().modifyText("Yes please, let's go", 228, 2);
                    p.getPackets().modifyText("Not yet", 228, 3);
                    newStatus = 207;
                    break;

                case 207:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Yes please, let's go.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 208;
                    break;

                case 208:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("Very well.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 209;
                    break;

                case 209:
                    p.setTemporaryAttribute("unmovable", true);
                    p.getPackets().displayInterface(120);
                    p.getPackets().sendMessage("Your camel trots off slowly out of the desert..");
                    Event moveBackToLletyaEvent = new Event(2000);
                    int moveBackToLletyaCounter = 0;
                    moveBackToLletyaEvent.setAction(() =>
                    {
                        if (moveBackToLletyaCounter == 0)
                        {
                            moveBackToLletyaCounter++;
                            moveBackToLletyaEvent.setTick(600);
                            p.teleport(new Location(2340, 3799, 0));
                        }
                        else
                        {
                            moveBackToLletyaEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.getPackets().sendMessage("..You and Ali are back in Lletya.");
                            p.getPackets().closeInterfaces();
                        }
                    });
                    Server.registerEvent(moveBackToLletyaEvent);
                    break;

                case 210:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Not yet.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 211;
                    break;

                case 211:
                    p.getPackets().sendNPCHead(1862, 241, 2);
                    p.getPackets().modifyText("Ali Morissane", 241, 3);
                    p.getPackets().modifyText("No problem, I will be here when you decide to leave.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;
            }
            if (newStatus != -1)
            {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
Exemplo n.º 29
0
 public GEItem getOfferForSlot(Player p, int slot)
 {
     foreach (KeyValuePair<int, GEItem[]> buyOffer in buyOffers)
     {
         if (buyOffer.Value != null)
         {
             for (int i = 0; i < buyOffer.Value.Length; i++)
             {
                 if (buyOffer.Value[i] != null)
                 {
                     if (buyOffer.Value[i].getPlayerName().Equals(p.getLoginDetails().getUsername()) && buyOffer.Value[i].getSlot() == slot)
                     {
                         return buyOffer.Value[i];
                     }
                 }
             }
         }
     }
     foreach (KeyValuePair<int, GEItem[]> sellOffer in sellOffers)
     {
         if (sellOffer.Value != null)
         {
             for (int i = 0; i < sellOffer.Value.Length; i++)
             {
                 if (sellOffer.Value[i] != null)
                 {
                     if (sellOffer.Value[i].getPlayerName().Equals(p.getLoginDetails().getUsername()) && sellOffer.Value[i].getSlot() == slot)
                     {
                         return sellOffer.Value[i];
                     }
                 }
             }
         }
     }
     return null;
 }
Exemplo n.º 30
0
 public void enterChannel(Player p, string owner)
 {
     if (p.getClan() != null)
     {
         return;
     }
     p.getPackets().sendMessage("Attempting to join channel...:clan:");
     if (owner.Equals(p.getLoginDetails().getUsername()))
     {
         Clan newClan = new Clan(p, owner, owner);
         addChannel(newClan);
     }
     Event enterChannelEvent = new Event(700);
     enterChannelEvent.setAction(() =>
     {
         enterChannelEvent.stop();
         foreach (Clan c in clans)
         {
             if (c != null)
             {
                 if (c.getClanOwner().Equals(owner))
                 {
                     if (c.getUserList().Count >= 100)
                     {
                         p.getPackets().sendMessage("The channel is full.");
                         return;
                     }
                     if (!owner.Equals(p.getLoginDetails().getUsername()))
                     {
                         if (c.getEnterRights() != Clan.ClanRank.NO_RANK)
                         {
                             if (c.getEnterRights() == Clan.ClanRank.FRIEND)
                             {
                                 if (!c.isFriendOfOwner(p) && !c.userHasRank(p.getLoginDetails().getUsername()))
                                 {
                                     p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat.");
                                     return;
                                 }
                             }
                             else
                             {
                                 bool canEnter = true;
                                 foreach (KeyValuePair<string, Clan.ClanRank> u in c.getUsersWithRank())
                                 {
                                     if (u.Key.Equals(p.getLoginDetails().getUsername()))
                                     {
                                         if (u.Value < c.getEnterRights())
                                         {
                                             canEnter = false;
                                             break;
                                         }
                                     }
                                 }
                                 if (!canEnter)
                                 {
                                     p.getPackets().sendMessage("You do not have a high enough rank to enter this clan chat.");
                                     return;
                                 }
                             }
                         }
                     }
                     c.addUser(p);
                     updateClan(c);
                     p.getPackets().sendMessage("Now talking in channel : " + Misc.formatPlayerNameForDisplay(c.getClanName() + ":clan:"));
                     p.getPackets().sendMessage("To talk, start each line of chat with the / symbol. :clan:");
                     return;
                 }
             }
         }
         p.getPackets().sendMessage("The channel you tried to join does not exist. :clan:");
     });
     Server.registerEvent(enterChannelEvent);
 }
Exemplo n.º 31
0
 private void handleEnterText(Player player, Packet packet)
 {
     if (player.getTemporaryAttribute("interfaceVariable") == null)
     {
         player.getPackets().sendMessage("An error occured, please try again.");
         return;
     }
     long textAsLong = packet.readLong();
     EnterVariable var = (EnterVariable)player.getTemporaryAttribute("interfaceVariable");
     switch (var.getInterfaceId())
     {
         case 590: // Clan chat setup
             Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
             if (clan != null)
             {
                 clan.setClanName(Misc.longToPlayerName(textAsLong));
                 Server.getClanManager().updateClan(clan);
                 player.getPackets().modifyText(Misc.formatPlayerNameForDisplay(clan.getClanName()), 590, 22);
                 break;
             }
             player.getPackets().sendMessage("Please set up a clan channel before trying to change the name.");
             break;
     }
     player.removeTemporaryAttribute("interfaceVariable");
 }
Exemplo n.º 32
0
 public void recieveWinnings(Player p)
 {
     if (!winner.Equals(p))
     {
         Misc.WriteError(p.getLoginDetails().getUsername() + " tried to claim stake winnings that weren't his.");
         return;
     }
     if (status != 8)
     {
         return;
     }
     for (int i = 0; i < winnings.Length; i++)
     {
         if (winnings[i] != null)
         {
             if (!player.getInventory().addItem(winnings[i].getItemId(), winnings[i].getItemAmount()))
             {
                 Misc.WriteError("Possible stake winnings dupe " + player.getLoginDetails().getUsername());
             }
             else
             {
                 winnings[i] = null;
             }
         }
     }
 }
Exemplo n.º 33
0
        private void handleClickFive(Player player, Packet packet)
        {
            int interfaceId = packet.readUShort();
            int child = packet.readUShort();
            int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 5: interfaceId: " + interfaceId);
            switch (interfaceId)
            {
                case 763: // Bank inventory - X.
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                    break;

                case 762: // Bank - X.
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                    break;

                case 336: // Trade inventory - trade X.
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                    break;

                case 335: // Trade interface - remove X.
                    player.getPackets().displayEnterAmount();
                    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                    break;

                case 631: // Duel interface - remove All
                    if (player.getDuel() != null)
                    {
                        player.getPackets().displayEnterAmount();
                        player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                        break;
                    }
                    break;

                case 620: // Shop - buy X/buy 50.
                    if (player.getShopSession().isInMainStock())
                    {
                        player.getPackets().displayEnterAmount();
                        player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
                    }
                    else
                    {
                        player.getShopSession().buyItem(slot, 50);
                    }
                    break;

                case 621: // Shop - Sell 50.
                    player.getShopSession().sellItem(slot, 50);
                    break;

                case 590: // Clan chat setup
                    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
                    if (clan == null)
                    {
                        player.getPackets().sendMessage("Please create your clan chat before changing settings.");
                        break;
                    }
                    switch (child)
                    {
                        case 23: // "Who can enter chat" - sergeant.
                            clan.setEnterRights(Clan.ClanRank.SERGEANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
                            break;

                        case 24: // "Who can talk in chat" - sergeant.
                            clan.setTalkRights(Clan.ClanRank.SERGEANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
                            break;

                        case 25: // // "Who can kick in chat" - sergeant.
                            clan.setKickRights(Clan.ClanRank.SERGEANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
                            break;

                        case 26: // "Who can share loot" - sergeant.
                            clan.setLootRights(Clan.ClanRank.SERGEANT);
                            player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 34
0
        public bool savePlayer(Player p)
        {
            if (p == null) return false;
            try
            {
                string username = p.getLoginDetails().getUsername().ToLower();

                /* Character saving code goes here */
                XmlTextWriter writer = new XmlTextWriter(Misc.getServerPath() + @"\accounts\" + username + ".xml", null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartElement("Player");
                writer.WriteStartElement("Login");
                writer.WriteElementString("Password", p.getLoginDetails().getPassword());
                writer.WriteElementString("Rights", p.getRights().ToString());
                writer.WriteElementString("BankPin", p.getBank().getBankPin());
                writer.WriteEndElement();

                writer.WriteStartElement("Position");
                writer.WriteElementString("X", p.getLocation().getX().ToString());
                writer.WriteElementString("Y", p.getLocation().getY().ToString());
                writer.WriteElementString("Z", p.getLocation().getZ().ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Settings");
                writer.WriteElementString("RunEnergy", p.getRunEnergy().ToString());
                writer.WriteStartElement("PrivacySettings");
                writer.WriteElementString("Public", p.getFriends().getPrivacyOption(0).ToString());
                writer.WriteElementString("Private", p.getFriends().getPrivacyOption(1).ToString());
                writer.WriteElementString("Trade", p.getFriends().getPrivacyOption(2).ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteStartElement("Friends");
                foreach (long friend in p.getFriends().getFriendsList())
                    writer.WriteElementString("Friend", friend.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Ignores");
                foreach (long ignore in p.getFriends().getIgnoresList())
                    writer.WriteElementString("Ignore", ignore.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("Stats");
                foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                {
                    writer.WriteStartElement(skill.ToString()); //skill name.
                    writer.WriteElementString("CurrentLevel", p.getSkills().getCurLevel(skill).ToString());
                    writer.WriteElementString("XP", p.getSkills().getXp(skill).ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                Item item;
                writer.WriteStartElement("EquipmentItems");
                foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
                {
                    if (equip == ItemData.EQUIP.NOTHING) continue;
                    item = p.getEquipment().getSlot(equip);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement(equip.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteStartElement("InventoryItems");
                for (int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++)
                {
                    item = p.getInventory().getSlot(i);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement("Item");
                    writer.WriteElementString("Slot", i.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteStartElement("BankItems");
                for (int i = 0; i < Bank.MAX_BANK_SLOTS; i++)
                {
                    item = p.getBank().getSlot(i);
                    if (item.getItemId() == -1) continue; //empty slot.

                    writer.WriteStartElement("Item");
                    writer.WriteElementString("Slot", i.ToString());
                    writer.WriteElementString("Id", item.getItemId().ToString());
                    writer.WriteElementString("Amount", item.getItemAmount().ToString());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                //Write the XML to file and close the writer
                writer.Close();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 35
0
 private bool isFriend(Player player)
 {
     long n = player.getLoginDetails().getLongName();
     if (friends.Contains(n))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 36
0
        private static void appendAppearanceUpdate(Player p, PacketBuilder updateBlock)
        {
            PacketBuilder playerProps = new PacketBuilder().setSize(Packet.Size.Bare);

            Appearance app = p.getAppearance();
            playerProps.addByte((byte)(app.getGender() & 0xFF));
            if ((app.getGender() & 0x2) == 2)
            {
                playerProps.addByte((byte)0);
                playerProps.addByte((byte)0);
            }
            playerProps.addByte((byte)p.getPrayers().getPkIcon());
            playerProps.addByte((byte)p.getPrayers().getHeadIcon());
            if (!app.isInvisible())
            {
                if (!app.isNpc())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (p.getEquipment().getItemInSlot((ItemData.EQUIP)i) != -1)
                        {
                            playerProps.addUShort(32768 + p.getEquipment().getSlot((ItemData.EQUIP)i).getDefinition().getEquipId());
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.CHEST).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.AMULET));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addByte((byte)0);
                    }
                    Item chest = p.getEquipment().getSlot(ItemData.EQUIP.CHEST);
                    if (chest != null && chest.getDefinition() != null)
                    {
                        if (!ItemData.isFullBody(chest.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.LEGS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.SHIELD));
                    }
                    Item hat = p.getEquipment().getSlot(ItemData.EQUIP.HAT);
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullHat(hat.getDefinition()) && !ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.HANDS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CHEST));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.FEET) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.FEET).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(6));
                    }
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                    }
                }
                else
                {
                    playerProps.addUShort(-1);
                    playerProps.addUShort(app.getNpcId());
                    playerProps.addByte((byte)255);
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    playerProps.addByte((byte)0);
                }
            }
            foreach (int colour in app.getColoursArray())
            {
                playerProps.addByte((byte)colour);
            }
            playerProps.addUShort(p.getEquipment().getStandWalkAnimation());
            playerProps.addLong(p.getLoginDetails().getLongName());
            playerProps.addByte((byte)p.getSkills().getCombatLevel());
            playerProps.addUShort(0);
            playerProps.addByte((byte)0);
            updateBlock.addByteA((byte)(playerProps.getLength() & 0xFF));
            updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength());
        }
Exemplo n.º 37
0
        /**
         * Unregister a player.
         * @param p as Player
         */
        public static void unregister(Player p)
        {
            if (p.getTrade() != null)
            {
                p.getTrade().decline();
                p.setTrade(null);
            }
            minigames.getFightPits().removeWaitingPlayer(p);
            minigames.getFightPits().removePlayingPlayer(p);
            if (p.getTemporaryAttribute("cantDoAnything") != null && Location.inFightPits(p.getLocation()))
            {
                minigames.getFightPits().useOrb(p, 5);
                return;
            }
            if (Location.inFightPits(p.getLocation()))
            {
                Server.getMinigames().getFightPits().teleportToWaitingRoom(p, false);
                return;
            }
            if (p.getFightCave() != null)
            {
                if (!p.getFightCave().isGamePaused())
                {
                    p.getFightCave().teleFromCave(true);
                    return;
                }
                else
                {
                    p.setLocation(new Location(2439, 5169, 0));
                }
            }
            if (!Combat.isXSecondsSinceCombat(p, p.getLastAttacked(), 10000) || p.isDead() || p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().getStatus() == 8)
                {
                    if (p.getDuel().getWinner().Equals(p))
                    {
                        p.getDuel().recieveWinnings(p);
                    }
                }
                else
                {
                    if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
                    {
                        p.getDuel().finishDuel(true, true);
                    }
                }
            }
            removeAllPlayersNPCs(p);

            foreach (Player p2 in players)
            {
                if (p == p2) continue;
                //Remove me from anyone who has Seen me.. or attempting to see me (new players).
                if (p2.getLocalEnvironment().getSeenPlayers().Contains(p) || p2.getLocalEnvironment().getNewPlayers().Contains(p))
                    p2.getLocalEnvironment().getRemovedPlayers().Add(p);
            }

            clanManager.leaveChannel(p);
            loginHandler.addSavePlayer(p);
            players.Remove(p);
            p.getFriends().unregistered();
            Console.WriteLine("Unregistered " + p.getLoginDetails().getUsername() + " [online = " + players.Count + "]");
        }