Thread: z508 staff spawn items in wild

Results 1 to 4 of 4
  1. #1 z508 staff spawn items in wild 
    Registered Member
    Join Date
    Feb 2010
    Posts
    17
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    How do I fix staff spawning in wild? Will rep+++
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jun 2010
    Posts
    26
    Thanks given
    0
    Thanks received
    0
    Rep Power
    6
    Quote Originally Posted by sparc mac1 View Post
    How do I fix staff spawning in wild? Will rep+++
    Code:
    if (cmd[0].equalsIgnoreCase("item") && p.jailed == 0) {
    					int itemID = Integer.parseInt(cmd[1]);
    					int itemAmount = Integer.parseInt(cmd[2]);
    					String itemName = Engine.items.getItemName(itemID);
    					if (p.rights > 2) {
    						Engine.playerItems.addItem(p, itemID, itemAmount);
    						return;
    					}
    					if (p.wildernessZone(p.absX, p.absY)) {
    						p
    								.getActionSender()
    								.sendMessage(p,
    										"You cannot spawn items while inside of the wilderness.");
    						return;
    Something close to that, Post any errors.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2010
    Posts
    17
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Thanks repped
    Reply With Quote  
     

  4. #4  
    Super Donator

    Sydney's Avatar
    Join Date
    Jul 2009
    Age
    28
    Posts
    560
    Thanks given
    184
    Thanks received
    175
    Rep Power
    867
    Quote Originally Posted by Paul View Post
    Code:
    if (cmd[0].equalsIgnoreCase("item") && p.jailed == 0) {
    					int itemID = Integer.parseInt(cmd[1]);
    					int itemAmount = Integer.parseInt(cmd[2]);
    					String itemName = Engine.items.getItemName(itemID);
    					if (p.rights > 2) {
    						Engine.playerItems.addItem(p, itemID, itemAmount);
    						return;
    					}
    					if (p.wildernessZone(p.absX, p.absY)) {
    						p
    								.getActionSender()
    								.sendMessage(p,
    										"You cannot spawn items while inside of the wilderness.");
    						return;
    Something close to that, Post any errors.
    You're going to get an error. You didn't close two brackets. And your conventions are putrid.

    Code:
    if (cmd[0].equalsIgnoreCase("item")) {
    	if (p.jailed) {
    		p.getActionSender().sendMessage(p, "You cannot spawn items while you're jailed.");
    		return;
    	}
    	if (p.rights <= 1) {
    		p.getActionSender().sendMessage(p, "You do not have sufficient rights to spawn items.");
    		return;
    	}
    	if (p.wildernessZone(p.absX, p.absY)) {
    		p.getActionSender().sendMessage(p, "You cannot spawn items while inside of the Wilderness.");
    		return;
    	}
    	int itemID = Integer.parseInt(cmd[1]);
    	int itemAmount = Integer.parseInt(cmd[2]);
    	String itemName = Engine.items.getItemName(itemID);
    }
    This is plenty better than the garbage above this, and the garbage above this lets people with rights greater than 2 spawn. So, even admins can't spawn with that code. Also, for this to work, your jail system has to use a boolean (like it should), not an int.
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •