Thread: [pi] Problem with Drops

Results 1 to 10 of 10
  1. #1 [pi] Problem with Drops 
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    Hello guys, I've recently added something so when you die in pvp with chaotics, they drop to coins ( in fact i wanted them untradeable)
    Since then, all 'untradeables' have been just disapearing exept the chaotics, even in pvm which is the annoying part.

    I've added an other "else if" for thoses untradeables, and in my config.java, chaotics and untradeables are two different things

    Still doesn't work, can anyone check into this or make it cleaner?

    Code:
    	public void dropAllItems() {
    		Client o = (Client) Server.playerHandler.players[c.killerId];
    		if (c.playerRights == 3/*|| c.isInArd() || c.isInFala()*/){
    		return;
    		}
    		for(int i = 0; i < c.playerItems.length; i++) {
    			if(o != null) {
    				if (tradeable(c.playerItems[i] - 1)) {
    					Server.itemHandler.createGroundItem(o, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.killerId);
    				} else {
    					if (pvp(c.playerItems[i] - 1))
    						Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerItems[i]-1), c.killerId);
    					
    				}
    			} else {
    					if (untradeable(c.playerItems[i] - 1))
    				                Server.itemHandler.createGroundItem(c, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.playerId);
    			}
    		} 
    		for(int e = 0; e < c.playerEquipment.length; e++) {
    			if(o != null) {
    				if (tradeable(c.playerEquipment[e])) {
    					Server.itemHandler.createGroundItem(o, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.killerId);
    				} else {
    					if (pvp(c.playerEquipment[e]))
    						Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerEquipment[e]), c.killerId);
    				}
    			} else {
    					if (untradeable(c.playerItems[e]))
    				                Server.itemHandler.createGroundItem(c, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.playerId);
    			}
    		}
    		if(o != null) {	
    			Server.itemHandler.createGroundItem(o, 526, c.getX(), c.getY(), 1, c.killerId);
    	          }
    	}
    	public int getPvpPrice(int item) {
    		switch (item) {
    			case 18349:
    			case 18351:
    			case 18353:
    			case 18355:
    			case 18357:
    			case 18359:
    			case 18361:
    			case 18363:
    			return 100000000;
    		}
    		return 0;
    	}
    	
    	
    	public boolean tradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return false;
    		}	
    		return true;
    	}
    	
    	public boolean untradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return true;
    		}	
    		return false;
    	}
    	
    	public boolean pvp(int itemId) {
    		for (int j = 0; j < Config.ITEM_PVP.length; j++) {
    			if (itemId == Config.ITEM_PVP[j])
    				return true;
    		}	
    		return false;
    	}
    Thanks
    Attached image
    Reply With Quote  
     

  2. #2  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    Bump
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2011
    Posts
    276
    Thanks given
    60
    Thanks received
    5
    Rep Power
    22
    make a backup and then try this...
    let me know if there are any errors or if it doesn't work, i didn't and can't test it (i also did it in notepad...)

    Code:
    	public void dropAllItems() {
    		Client o = (Client) Server.playerHandler.players[c.killerId];
    		if (c.playerRights == 3){
    			return; //we are not dropping items for admins
    		}
    		for(int i = 0; i < c.playerItems.length; i++) {
    			if(o != null) {
    				if (tradeable(c.playerItems[i] - 1)) {
    					Server.itemHandler.createGroundItem(o, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.killerId);
    				} else {
    					if (pvp(c.playerItems[i] - 1))
    					Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerItems[i]-1), c.killerId);
    					
    				} else {
    					if (untradeable(c.playerItems[i] - 1))
    					Server.itemHandler.createGroundItem(c, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.playerId);
    				}
    		} //end of for loop
    		for(int e = 0; e < c.playerEquipment.length; e++) {
    			if(o != null) {
    				if (tradeable(c.playerEquipment[e])) {
    				Server.itemHandler.createGroundItem(o, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.killerId);
    			} else {
    				if (pvp(c.playerEquipment[e]))
    				Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerEquipment[e]), c.killerId);
    			} else {
    				if (untradeable(c.playerItems[e]))
    				Server.itemHandler.createGroundItem(c, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.playerId);
    			}
    		} //end of for loop
    		if(o != null) {	
    			Server.itemHandler.createGroundItem(o, 526, c.getX(), c.getY(), 1, c.killerId);
    	        }
    	} //end of dropAllItems();
    
    	public int getPvpPrice(int item) {
    		switch (item) {
    			case 18349:
    			case 18351:
    			case 18353:
    			case 18355:
    			case 18357:
    			case 18359:
    			case 18361:
    			case 18363:
    			return 100000000;
    		}
    		return 0;
    	}
    	
    	
    	public boolean tradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return false;
    		}	
    		return true;
    	}
    	
    	public boolean untradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return true;
    		}	
    		return false;
    	}
    	
    	public boolean pvp(int itemId) {
    		for (int j = 0; j < Config.ITEM_PVP.length; j++) {
    			if (itemId == Config.ITEM_PVP[j])
    				return true;
    		}	
    		return false;
    	}
    Reply With Quote  
     

  4. #4  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    I was customizing my thing and I got lost at some point ahaha >.< Alright I'm trying your way
    1 sec

    Edit : No errors, but doesn't work , :/
    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Nov 2011
    Posts
    276
    Thanks given
    60
    Thanks received
    5
    Rep Power
    22
    try this, lemme know errors and what works/doesn't work...
    i don't have a copy of your source so i can't really test and debug till it works, so i am relying on what you tell me, if that makes sense.

    Code:
    public void dropAllItems() {
    	Client o = (Client) Server.playerHandler.players[c.killerId];
    	if (c.playerRights == 3){
    		return; //we are not dropping items for admins
    	} //end of admin check
    	for(int e = 0; e < c.playerEquipment.length; e++) {
    		if(o != null) {
    			if (tradeable(c.playerEquipment[e])) {
    				Server.itemHandler.createGroundItem(o, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.killerId);
    			}
    			if (pvp(c.playerEquipment[e])) {
    				Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerEquipment[e]), c.killerId);
    			}
    			if (untradeable(c.playerItems[e])) {
    				Server.itemHandler.createGroundItem(c, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.playerId);
    			}
    		} //end of for loop
    } //end of dropAllItems();
    
    	switch (item) {
    			case 18349:
    			case 18351:
    			case 18353:
    			case 18355:
    			case 18357:
    			case 18359:
    			case 18361:
    			case 18363:
    			return 100000000;
    		}
    		return 0;
    	}
    	
    	
    	public boolean tradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return false;
    		}	
    		return true;
    	}
    	
    	public boolean untradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return true;
    		}	
    		return false;
    	}
    	
    	public boolean pvp(int itemId) {
    		for (int j = 0; j < Config.ITEM_PVP.length; j++) {
    			if (itemId == Config.ITEM_PVP[j])
    				return true;
    		}	
    		return false;
    	}
    also can i get your "Config.ITEM_PVP"?
    Reply With Quote  
     

  6. #6  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    In this case i'm pretty sure that inventory items will just not drop at all :\ infact you removed that part..

    public static final int[] ITEM_PVP = {18349,18351,18353,18355,18357,18359,18361,18363};
    Attached image
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Nov 2011
    Posts
    276
    Thanks given
    60
    Thanks received
    5
    Rep Power
    22
    Quote Originally Posted by Olinice View Post
    In this case i'm pretty sure that inventory items will just not drop at all :\ infact you removed that part..

    public static final int[] ITEM_PVP = {18349,18351,18353,18355,18357,18359,18361,18363};
    you are correct, sorry about that, like i said, i have been looking through it in notepad and forgot to copy that part over...
    i've been busy but i will continue to look into this when i have time
    Reply With Quote  
     

  8. #8  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    Alright sure it's always nice to get people to check in my problems for free anyways
    Attached image
    Reply With Quote  
     

  9. #9  
    Registered Member muppet head's Avatar
    Join Date
    Aug 2010
    Posts
    68
    Thanks given
    1
    Thanks received
    1
    Rep Power
    27
    The 'error': If the item was untradeable it would only drop if the item was a PVP item, else nothing. I also cleaned the code a bit by removing the void function 'untradeable' because it did the exactly same as the 'tradeable' function except opposite.

    If you have any 'untradeable(item)' in your source you will need to change them to '!tradeable(item)'!

    Here's the fix:

    Code:
    public void dropAllItems() {
    		Client o = (Client) Server.playerHandler.players[c.killerId];
    		if (c.playerRights == 3/*|| c.isInArd() || c.isInFala()*/){
    		return;
    		}
    		for(int i = 0; i < c.playerItems.length; i++) {
    			if(o != null) {
    				if (tradeable(c.playerItems[i] - 1)) {
    					Server.itemHandler.createGroundItem(o, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.killerId);
    				} else {
    					if (pvp(c.playerItems[i] - 1))
    						Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerItems[i]-1), c.killerId);
    					else
    						Server.itemHandler.createGroundItem(c, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.playerId);
    				}
    			} else {
    				if (!tradeable(c.playerItems[i] - 1))
    				    Server.itemHandler.createGroundItem(c, c.playerItems[i] -1, c.getX(), c.getY(), c.playerItemsN[i], c.playerId);
    			}
    		} 
    		for(int e = 0; e < c.playerEquipment.length; e++) {
    			if(o != null) {
    				if (tradeable(c.playerEquipment[e])) {
    					Server.itemHandler.createGroundItem(o, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.killerId);
    				} else {
    					if (pvp(c.playerEquipment[e]))
    						Server.itemHandler.createGroundItem(o, 995, c.getX(), c.getY(), getPvpPrice(c.playerEquipment[e]), c.killerId);
    					else
    						Server.itemHandler.createGroundItem(c, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.playerId);
    				}
    			} else {
    				if (!tradeable(c.playerItems[e]))
    					Server.itemHandler.createGroundItem(c, c.playerEquipment[e], c.getX(), c.getY(), c.playerEquipmentN[e], c.playerId);
    			}
    		}
    		if(o != null) {	
    			Server.itemHandler.createGroundItem(o, 526, c.getX(), c.getY(), 1, c.killerId);
    	          }
    	}
    	public int getPvpPrice(int item) {
    		switch (item) {
    			case 18349:
    			case 18351:
    			case 18353:
    			case 18355:
    			case 18357:
    			case 18359:
    			case 18361:
    			case 18363:
    			return 100000000;
    		}
    		return 0;
    	}
    	
    	
    	public boolean tradeable(int itemId) {
    		for (int j = 0; j < Config.ITEM_TRADEABLE.length; j++) {
    			if (itemId == Config.ITEM_TRADEABLE[j])
    				return false;
    		}	
    		return true;
    	}
    	
    	public boolean pvp(int itemId) {
    		for (int j = 0; j < Config.ITEM_PVP.length; j++) {
    			if (itemId == Config.ITEM_PVP[j])
    				return true;
    		}	
    		return false;
    	}
    Reply With Quote  
     

  10. #10  
    Donator
    Darkness's Avatar
    Join Date
    Nov 2012
    Age
    26
    Posts
    876
    Thanks given
    121
    Thanks received
    75
    Rep Power
    47
    I'll get to try this out soon but I don't think i'll need to test, that seems pretty accurate
    Thank you so much ahaha i've went fast on a pretty leaky code and forgot how to went back through it ahah!
    Attached image
    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. [PI] Problem with depositing items
    By Alexander in forum Help
    Replies: 3
    Last Post: 11-06-2010, 06:51 PM
  2. [PI]Problems with Dialogue Option select
    By Mr Impact in forum Help
    Replies: 5
    Last Post: 08-03-2010, 03:24 AM
  3. [PI] Problem with item.cfg
    By Eddie12390 in forum Help
    Replies: 3
    Last Post: 07-15-2010, 10:51 PM
  4. [PI] Problem with Tzhaar Caves
    By NickDuhGreat in forum Help
    Replies: 1
    Last Post: 07-09-2010, 09:43 PM
  5. Problem with dropped items
    By Kihomura in forum Help
    Replies: 1
    Last Post: 10-09-2008, 11:15 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •