Thread: Few PI easy questions

Results 1 to 8 of 8
  1. #1 Few PI easy questions 
    Registered Member
    Join Date
    Jul 2010
    Posts
    44
    Thanks given
    2
    Thanks received
    1
    Rep Power
    1
    So basically, I have a system where you kill a NPC and you get a point that is already setup. But when I use the shop, I click on the item is gives "this item cost X amount of points" like it is suppose to do. However, when buying the item, it takes coins, but after clicking buy it says "not enough points" but still gives the item, and takes coins. I have the values setup correctly for the items in the shop also.

    here is my shop assistant.java that has to relate with the shop...

    Under

    Code:
    public boolean buyItem(int itemID, int fromSlot, int amount)
    I have

    Code:
    if(c.myShopId == 15) {
                    	if (c.randomPoints >= TotPrice2) {
    						if (c.getItems().freeSlots() > 0) {
    							c.randomPoints -= TotPrice2;
    							c.getItems().addItem(itemID, 1);
    							Server.shopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
    							Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
    							if ((fromSlot + 1) > Server.shopHandler.ShopItemsStandard[c.myShopId]) {
    								Server.shopHandler.ShopItems[c.myShopId][fromSlot] = 0;
    							}
    						} else {
    							c.sendMessage("You don't have enough space in your inventory.");
    							break;
    						}
    					} else {
    						c.sendMessage("You don't have enough Points.");
    						break;
    								}
                    }
    Under
    Code:
    public void handleOtherShop(int itemID) {
    I have
    Code:
    	} else if (c.myShopId == 15) {
    				if (c.randomPoints >= getSpecialItemValue(itemID)) {
    					if (c.getItems().freeSlots() > 0){
    						c.randomPoints -= getSpecialItemValue(itemID);
    						c.getItems().addItem(itemID,1);
    						c.getItems().resetItems(3823);
    					}
    				} else {
    					c.sendMessage("You do not have enough points to buy this item.");			
    				}

    Problem 2:
    Fixed
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jul 2009
    Posts
    81
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Ok so problem one, I think your issue is in this method

    Code:
    public boolean buyItem(int itemID, int fromSlot, int amount)
    It looks like right here
    Code:
     if (c.randomPoints >= TotPrice2) {
    You are trying to see if the player has enough points to match the coined amount of the item. so maybe change it to this.

    Code:
    if (c.randomPoints >= getSpecialItemValue(itemID)) {
    And that should stop you or at least stop that message from saying you don't have enough points, as it sounds like the first one is telling you, that you don't have enough, But then your handleOtherShop() method thinks that you do have enough points.

    And for your second bug:
    replace this:
    Code:
    case SECOND_CLICK:
    				c.npcClickIndex = c.inStream.readSignedWordBigEndian();
    				c.npcType = Server.npcHandler.npcs[c.npcClickIndex].npcType; 
    				case 334:
    				case 233:
    				case 316:
    				case 312:
    				c.getFishing().fish(Server.npcHandler.npcs[c.npcClickIndex], false);
    				break;
    				c.NPCClicked = Server.npcHandler.npcs[c.npcClickIndex];
    				if(c.goodDistance(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY(), c.getX(), c.getY(), 1)) {
    					c.turnPlayerTo(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY());
    					c.getActions().secondClickNpc(c.npcType);	
    				} else {
    					c.clickNpcType = 2;
    				}
    				break;
    with this

    Code:
    case SECOND_CLICK:
    				c.npcClickIndex = c.inStream.readSignedWordBigEndian();
    				c.npcType = Server.npcHandler.npcs[c.npcClickIndex].npcType; 
    				case 334:
    				case 233:
    				case 316:
    				case 312:
    				c.getFishing().fish(Server.npcHandler.npcs[c.npcClickIndex], false);
    				//break; This break is stopping your code from reaching everything under
                                    // here. Its a common mistake that i used to make a lot.
    				c.NPCClicked = Server.npcHandler.npcs[c.npcClickIndex];
    				if(c.goodDistance(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY(), c.getX(), c.getY(), 1)) {
    					c.turnPlayerTo(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY());
    					c.getActions().secondClickNpc(c.npcType);	
    				} else {
    					c.clickNpcType = 2;
    				}
    				break;

    I wrote a note of what was happening. You had a break; that was stopping before it reached the rest of the code in that statement giving you your "unreachable statement" error.

    I hope this helped good luck.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2010
    Posts
    44
    Thanks given
    2
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by cejay View Post
    Ok so problem one, I think your issue is in this method

    Code:
    public boolean buyItem(int itemID, int fromSlot, int amount)
    It looks like right here
    Code:
     if (c.randomPoints >= TotPrice2) {
    You are trying to see if the player has enough points to match the coined amount of the item. so maybe change it to this.

    Code:
    if (c.randomPoints >= getSpecialItemValue(itemID)) {
    And that should stop you or at least stop that message from saying you don't have enough points, as it sounds like the first one is telling you, that you don't have enough, But then your handleOtherShop() method thinks that you do have enough points.

    And for your second bug:
    replace this:
    Code:
    case SECOND_CLICK:
    				c.npcClickIndex = c.inStream.readSignedWordBigEndian();
    				c.npcType = Server.npcHandler.npcs[c.npcClickIndex].npcType; 
    				case 334:
    				case 233:
    				case 316:
    				case 312:
    				c.getFishing().fish(Server.npcHandler.npcs[c.npcClickIndex], false);
    				break;
    				c.NPCClicked = Server.npcHandler.npcs[c.npcClickIndex];
    				if(c.goodDistance(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY(), c.getX(), c.getY(), 1)) {
    					c.turnPlayerTo(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY());
    					c.getActions().secondClickNpc(c.npcType);	
    				} else {
    					c.clickNpcType = 2;
    				}
    				break;
    with this

    Code:
    case SECOND_CLICK:
    				c.npcClickIndex = c.inStream.readSignedWordBigEndian();
    				c.npcType = Server.npcHandler.npcs[c.npcClickIndex].npcType; 
    				case 334:
    				case 233:
    				case 316:
    				case 312:
    				c.getFishing().fish(Server.npcHandler.npcs[c.npcClickIndex], false);
    				//break; This break is stopping your code from reaching everything under
                                    // here. Its a common mistake that i used to make a lot.
    				c.NPCClicked = Server.npcHandler.npcs[c.npcClickIndex];
    				if(c.goodDistance(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY(), c.getX(), c.getY(), 1)) {
    					c.turnPlayerTo(Server.npcHandler.npcs[c.npcClickIndex].getX(), Server.npcHandler.npcs[c.npcClickIndex].getY());
    					c.getActions().secondClickNpc(c.npcType);	
    				} else {
    					c.clickNpcType = 2;
    				}
    				break;

    I wrote a note of what was happening. You had a break; that was stopping before it reached the rest of the code in that statement giving you your "unreachable statement" error.

    I hope this helped good luck.
    Thanks for explaining both of these for me!

    I changed my first error, but still didn't work.

    But thanks for the response for the 2nd one, works fine now.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2009
    Posts
    81
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    That first error, Will need some bug testing , Try making a send message in both things like c.sendMessage("I'm getting here"), Or even see what your points are and what its trying to match. Its difficult for me to help you out on an obob when i can't bug test it.

    Hopefully you can figure it out. good luck.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jul 2010
    Posts
    44
    Thanks given
    2
    Thanks received
    1
    Rep Power
    1
    Bump, can someone please tell me how to fix this.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jul 2010
    Posts
    44
    Thanks given
    2
    Thanks received
    1
    Rep Power
    1
    Bump, can someone please help me.
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    I would help if you didn't scam me for the 10 bucks
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Dec 2011
    Posts
    454
    Thanks given
    17
    Thanks received
    37
    Rep Power
    61
    case itemid
    return tokenprice;
    That should give the items a value in the shop.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Easy questions
    By *MartiX in forum Help
    Replies: 0
    Last Post: 01-27-2011, 09:45 AM
  2. Few easy questions.
    By Cody_ in forum Help
    Replies: 4
    Last Post: 01-27-2011, 05:39 AM
  3. Some easy questions pi
    By *MartiX in forum Help
    Replies: 3
    Last Post: 01-03-2011, 03:13 PM
  4. Few questions. (Easy rep+)
    By Cody_ in forum Help
    Replies: 1
    Last Post: 12-30-2010, 12:02 PM
  5. A few easy questions
    By FuglyNerd in forum Help
    Replies: 9
    Last Post: 11-21-2009, 12:09 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •