Thread: disable items from spawning

Results 1 to 8 of 8
  1. #1 disable items from spawning 
    Donator

    Join Date
    Jul 2012
    Age
    28
    Posts
    657
    Thanks given
    269
    Thanks received
    58
    Rep Power
    10
    hey guys im making a spawn server but how can i disable items from spawning like donator items and pkp shop items?

    is there any easy command or something?
    Reply With Quote  
     

  2. #2  
    Registered Member
    Alpi's Avatar
    Join Date
    Jun 2011
    Age
    28
    Posts
    1,191
    Thanks given
    212
    Thanks received
    285
    Rep Power
    148
    Make an array, and loop through it.
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Banned

    Join Date
    Jul 2011
    Posts
    691
    Thanks given
    163
    Thanks received
    161
    Rep Power
    0
    Quote Originally Posted by RiiPiiNFtW View Post
    Make an array, and loop through it.
    He obviously has no clue what an array is, nor how to use one. I believe that is the reason behind him making this post.

    OT: I will show you how below...

    first, create an array with all the item id's you do not want people to spawn like so:
    Code:
    	public final int[] NO_SPAWN = {995,6950,15272};
    When you add in item id's, just add a comma to seperate that id from the others in the array.

    Then your spawn method should looking something like this:
    Code:
    	public void execute(Client client, String command) {
    		if (client.isOwner() || client.isAlan()) {
    			try {
    				String[] args = command.split(" ");
    				if (args.length == 2) {
    					int newItemID = Integer.parseInt(args[1]);
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, 1);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else {
    					client.sendMessage("Use as ::item 995 100");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    	}
    Yours is most likely different because i re-formatted my commands.

    Add this in:
    Code:
    				for(int no : NO_SPAWN){
    					if(newItemID == no){
    						c.sendMessage("You cannot spawn this item!");
    						return;
    					}
    				}
    So it looks like this:
    Code:
    package server.model.players.Content.command.impl;
    
    import server.Config;
    import server.model.players.Client;
    import server.model.players.Content.command.CommandHandler;
    
    public class Item implements CommandHandler {
    
    	public void execute(Client client, String command) {
    		if (client.isOwner() || client.isAlan()) {
    			try {
    				String[] args = command.split(" ");
    				if (args.length == 2) {
    					int newItemID = Integer.parseInt(args[1]);
    					for(int no : NO_SPAWN){
    						if(newItemID == no){
    							c.sendMessage("You cannot spawn this item!");
    							return;
    						}
    					}
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, 1);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    					for(int no : NO_SPAWN){
    						if(newItemID == no){
    							c.sendMessage("You cannot spawn this item!");
    							return;
    						}
    					}
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else {
    					client.sendMessage("Use as ::item 995 100");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    	}
    
    }
    Reply With Quote  
     

  5. #4  
    Registered Member
    Alpi's Avatar
    Join Date
    Jun 2011
    Age
    28
    Posts
    1,191
    Thanks given
    212
    Thanks received
    285
    Rep Power
    148
    Quote Originally Posted by Jesse Pinkman View Post
    He obviously has no clue what an array is, nor how to use one. I believe that is the reason behind him making this post.

    OT: I will show you how below...

    first, create an array with all the item id's you do not want people to spawn like so:
    Code:
    	public final int[] NO_SPAWN = {995,6950,15272};
    When you add in item id's, just add a comma to seperate that id from the others in the array.

    Then your spawn method should looking something like this:
    Code:
    	public void execute(Client client, String command) {
    		if (client.isOwner() || client.isAlan()) {
    			try {
    				String[] args = command.split(" ");
    				if (args.length == 2) {
    					int newItemID = Integer.parseInt(args[1]);
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, 1);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else {
    					client.sendMessage("Use as ::item 995 100");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    	}
    Yours is most likely different because i re-formatted my commands.

    Add this in:
    Code:
    				for(int no : NO_SPAWN){
    					if(newItemID == no){
    						c.sendMessage("You cannot spawn this item!");
    						return;
    					}
    				}
    So it looks like this:
    Code:
    package server.model.players.Content.command.impl;
    
    import server.Config;
    import server.model.players.Client;
    import server.model.players.Content.command.CommandHandler;
    
    public class Item implements CommandHandler {
    
    	public void execute(Client client, String command) {
    		if (client.isOwner() || client.isAlan()) {
    			try {
    				String[] args = command.split(" ");
    				if (args.length == 2) {
    					int newItemID = Integer.parseInt(args[1]);
    					for(int no : NO_SPAWN){
    						if(newItemID == no){
    							c.sendMessage("You cannot spawn this item!");
    							return;
    						}
    					}
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, 1);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    					for(int no : NO_SPAWN){
    						if(newItemID == no){
    							c.sendMessage("You cannot spawn this item!");
    							return;
    						}
    					}
    					if ((newItemID < Config.ITEM_LIMIT) && (newItemID > 0)) {
    						client.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						client.sendMessage("You cannot spawn items that high.");
    					}
    				} else {
    					client.sendMessage("Use as ::item 995 100");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    	}
    
    }
    Oh I forget, this community spoon feeds. To used to the real community out there.
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Banned

    Join Date
    Jul 2011
    Posts
    691
    Thanks given
    163
    Thanks received
    161
    Rep Power
    0
    Quote Originally Posted by RiiPiiNFtW View Post
    Oh I forget, this community spoon feeds. To used to the real community out there.
    This is not a snippet section smart ass, if you are not going to actually help then why the hell are you in the section ?

    Ignorance is not the answer.
    Reply With Quote  
     

  8. #6  
    Registered Member
    Alpi's Avatar
    Join Date
    Jun 2011
    Age
    28
    Posts
    1,191
    Thanks given
    212
    Thanks received
    285
    Rep Power
    148
    Quote Originally Posted by Jesse Pinkman View Post
    This is not a snippet section smart ass, if you are not going to actually help then why the hell are you in the section ?

    Ignorance is not the answer.
    K... so how would this not being a snippet section change the fact that you don't learn anything by copying and pasting? Enlighten me please.
    Reply With Quote  
     

  9. #7  
    Registered Member
    Join Date
    Dec 2012
    Posts
    307
    Thanks given
    63
    Thanks received
    36
    Rep Power
    9
    @Jesse Pinkman i think its funny how u say this
    He obviously has no clue what an array is, nor how to use one. I believe that is the reason behind him making this post.
    but then you say
    first, create an array
    Reply With Quote  
     

  10. #8  
    Extreme Donator


    Join Date
    Feb 2009
    Posts
    361
    Thanks given
    53
    Thanks received
    85
    Rep Power
    177
    Quote Originally Posted by pkerrrr View Post
    @Jesse Pinkman i think its funny how u say this but then you say
    He provided a example of what an array is just below his statement..
    Reply With Quote  
     

  11. Thankful user:



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. *HELP* how to enable/disable rights to spawn items
    By professionalzerk in forum Help
    Replies: 12
    Last Post: 09-29-2012, 03:19 AM
  2. [PI] Array to stop certain items from spawning
    By ....>§exy<.... in forum Help
    Replies: 10
    Last Post: 01-01-2012, 12:12 AM
  3. Replies: 2
    Last Post: 11-24-2011, 01:32 AM
  4. Replies: 1
    Last Post: 04-24-2011, 12:30 AM
  5. Blocking some items from being spawned/NPC talking
    By Hyperventilate in forum Help
    Replies: 0
    Last Post: 03-24-2009, 12:04 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
  •