Index: C:/Development/l2j/eclipse/workspace/L2_GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestBuyItem.java =================================================================== --- C:/Development/l2j/eclipse/workspace/L2_GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestBuyItem.java (revision 1247) +++ C:/Development/l2j/eclipse/workspace/L2_GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestBuyItem.java (working copy) @@ -94,10 +94,15 @@ { L2PcInstance activeChar = getClient().getActiveChar(); L2FolkInstance folk = activeChar.getLastFolkNPC(); - if (!(folk instanceof L2MerchantInstance) || activeChar.getDistance(folk.getX(), folk.getY()) > L2NpcInstance.INTERACTION_DISTANCE) - return; + if ((folk instanceof L2MerchantInstance) && activeChar.getDistance(folk.getX(), folk.getY()) > L2NpcInstance.INTERACTION_DISTANCE) + return; // If talking to a merchant and too far + else if (!(folk instanceof L2MerchantInstance) && !activeChar.isGM()) + return; // If not talking to a merchant and not a gm (gm shop) - L2MerchantInstance merchant = (L2MerchantInstance)folk; + L2MerchantInstance merchant = null; + // prevent cast exception and allow GMs use gmshop + if (folk instanceof L2MerchantInstance) + merchant = (L2MerchantInstance)folk; if (_listId > 1000000) // lease { @@ -138,7 +143,7 @@ int tax = 0; double taxRate = 0; - if (merchant.getCastle() != null) + if (merchant != null && merchant.getCastle() != null) taxRate = merchant.getCastle().getTaxRate(); for (int i = 0; i < items.size(); i++) @@ -241,7 +246,7 @@ } // Add tax to castle treasury if not owned by npc clan - if (merchant.getCastle() != null && merchant.getCastle().getOwnerId() > 0) + if (merchant != null && merchant.getCastle() != null && merchant.getCastle().getOwnerId() > 0) merchant.getCastle().addToTreasury(tax); //TODO only send Inventory update instead of full list !