Thread: PI command error

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 PI command error 
    Registered Member Real Slim's Avatar
    Join Date
    Mar 2013
    Posts
    223
    Thanks given
    10
    Thanks received
    1
    Rep Power
    11
    Code:
    src\server\model\players\packets\Commands.java:563: error: incomparable types: i
    nt and int[]
                                                    }else if ((ID <= 15500) && (ID >
    = 0) && (ID != UNSP)) {
    
                ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    Press any key to continue . . .
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Dec 2011
    Age
    29
    Posts
    794
    Thanks given
    92
    Thanks received
    84
    Rep Power
    250
    Code:
    src\server\model\players\packets\Commands.java:563: error: incomparable types: i
    nt and int[]
                                                    }else if ((ID <= 15500) && (ID >
    = 0) && (ID != UNSP)) {
    
                ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    Press any key to continue . . .
    The errors says "Incomparable types... int and int[] can't be compared" this can be due to one of the compared ints is an array and the other is a usual int.

    Reply With Quote  
     

  3. #3  
    Registered Member Real Slim's Avatar
    Join Date
    Mar 2013
    Posts
    223
    Thanks given
    10
    Thanks received
    1
    Rep Power
    11
    How to fix that?
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Dec 2011
    Age
    29
    Posts
    794
    Thanks given
    92
    Thanks received
    84
    Rep Power
    250
    Quote Originally Posted by Real Slim View Post
    How to fix that?
    Look up for public int UNSP and public int ID , turn the one which is a normal int to an int array.....

    Reply With Quote  
     

  5. #5  
    Registered Member Real Slim's Avatar
    Join Date
    Mar 2013
    Posts
    223
    Thanks given
    10
    Thanks received
    1
    Rep Power
    11
    Lol i suck at this
    heres my command:
    Code:
    if (playerCommand.startsWith("item") && (c.playerRights != 2 || c.playerRights != 3 || c.playerRights != 12)) {
    		int UNSP[] = {14484, 6586, 6585, 4151, 4152, 15486, 15487, 10551, 19784, 19780, 18786, 10548};
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    								int ID = Integer.parseInt(args[1]);
    					if (c.inPvP() || c.inWild())
    						return;
    						int newItemAmount = Integer.parseInt(args[2]);
    						if (newItemAmount > 1000) {
    							c.sendMessage("<shad=1242141>You can't spawn more than 1000 of an item");
    								return;
    									}
    						if((ID > 13300) && (ID < 13940)) {
    								c.sendMessage("<shad=214141>Ya'd think these would be spawnable?</col>");
    									return;
    							}else if((ID > 11250) && (ID < 11900)) {
    								c.sendMessage("<shad=214141>Cannot spawn godwars items</col>");
    									return;
    							}else if((ID > 1030) && (ID < 1080)) {
    								c.sendMessage("<shad=214141>You cannot spawn rares</col>");
    									return;
    							}else if((ID > 4600) && (ID < 4900)) {
    								c.sendMessage("<shad=212441>Can't spawn barrows buddy");
    									return;
    							}else if((ID > 14700) && (ID < 15000)) {
    								c.sendMessage("<shad=241> Can't Spawn Statuetes");
    									return;
    							}else if((ID > 13300) && (ID < 13800)) {
    								c.sendMessage("<shad=241> Nice try buddy, maybe next time");
    									return;
    							}else if ((ID <= 15500) && (ID >= 0) && (ID != UNSP)) {
    								c.getItems().addItem(ID, newItemAmount);	
    							}else {
    								c.sendMessage("<shad=214141>This Item is Unattainable or Earnable</col>");
    									}
    							} else {
    								c.sendMessage("Wrong usage: (Ex:(::item 995 1))");
    								}
    							} catch(Exception e) {
    					
    								}  
    								}
    Reply With Quote  
     

  6. #6  
    Registered Member

    Join Date
    Dec 2011
    Age
    29
    Posts
    794
    Thanks given
    92
    Thanks received
    84
    Rep Power
    250
    You can use a for loop for that, like

    Code:
    for(int i = 0; i <= UNSP.length; i++) {

    Reply With Quote  
     

  7. #7  
    Registered Member Real Slim's Avatar
    Join Date
    Mar 2013
    Posts
    223
    Thanks given
    10
    Thanks received
    1
    Rep Power
    11
    I dont get it
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    Dec 2011
    Age
    29
    Posts
    794
    Thanks given
    92
    Thanks received
    84
    Rep Power
    250
    Code:
    c.playerRights != 2
    lol admins are not allowed to spawn?

    You created an array but didn't use it? Why use the ugly if statements, use enums?

    Code:
    if(player.Command.startsWith("item) && (c.playerRights >= 2) && (c.playerRights <= 3) && (c.playerRights == 12)) {
    	
        		int UNSP[] = {14484, 6586, 6585, 4151, 4152, 15486, 15487, 10551, 19784, 19780, 18786, 10548};
    
    			try {
    				String[] args = playerCommand.split(" ");
    				if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    			for(int i = 0; i <= UNSP.length; i++) {
    				if(newItemId.contains(i) {
    					c.sendMessage("You cannot spawn this item.");
    				}
    			} else if ((newItemID <= 25000) && (newItemID >= 0)) {
    						c.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						c.sendMessage("That item ID does not exist.");
    					}
    				} else {
    					c.sendMessage("Wrong syntax, Use as ::item_id_amount (Ex ::item 995 1)");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    How about thsi code?

    Reply With Quote  
     

  9. #9  
    Registered Member Real Slim's Avatar
    Join Date
    Mar 2013
    Posts
    223
    Thanks given
    10
    Thanks received
    1
    Rep Power
    11
    i got spawn server and i want some items unspanable and that was easy way to do it but cant get it work... (im too lazy to add every item id to the int...)
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Dec 2011
    Age
    29
    Posts
    794
    Thanks given
    92
    Thanks received
    84
    Rep Power
    250
    Quote Originally Posted by Real Slim View Post
    i got spawn server and i want some items unspanable and that was easy way to do it but cant get it work... (im too lazy to add every item id to the int...)
    Create a boolean for that then

    Code:
    if(player.Command.startsWith("item) && (c.playerRights >= 2) && (c.playerRights <= 3) && (c.playerRights == 12)) {
    	
        		int UNSP[] = {14484, 6586, 6585, 4151, 4152, 15486, 15487, 10551, 19784, 19780, 18786, 10548};
    
    			try {
    				String[] args = playerCommand.split(" ");
    				if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);
    					int newItemAmount = Integer.parseInt(args[2]);
    			for(int i = 0; i <= UNSP.length; i++) {
    		boolean isUnSpawnable() {
    		if((ID > 13300) && (ID < 13940) || (ID > 11250) && (ID < 11900) || (ID > 1030) && (ID < 1080) || (ID > 4600) && (ID < 4900) || (ID > 14700) && (ID < 15000) || (ID > 13300) && (ID < 13800) || ID.contains(i) {
    		return true;
    	}
    				if(isUnSpawnable()) {
    					c.sendMessage("You cannot spawn this item.");
    				}
    			} else if ((newItemID <= 25000) && (newItemID >= 0)) {
    						c.getItems().addItem(newItemID, newItemAmount);
    					} else {
    						c.sendMessage("That item ID does not exist.");
    					}
    				} else {
    					c.sendMessage("Wrong syntax, Use as ::item_id_amount (Ex ::item 995 1)");
    				}
    			} catch (Exception e) {
    
    			}
    		}
    I think you're new to RSPS coding.

    Edited this after 2 minutes of replying (changed a logical and(&&) to logical or (||).

    Reply With Quote  
     

Page 1 of 2 12 LastLast

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 command error - Solved
    By Olem in forum Help
    Replies: 4
    Last Post: 02-22-2012, 08:22 PM
  2. pi command error
    By g0d 0f war in forum Help
    Replies: 4
    Last Post: 09-14-2011, 05:37 AM
  3. PI Command errors
    By Shady in forum Help
    Replies: 5
    Last Post: 04-27-2011, 10:18 PM
  4. [PI] Command Error
    By #Trilla in forum Help
    Replies: 6
    Last Post: 04-25-2011, 05:03 PM
  5. PI command error
    By Despised Icon in forum Help
    Replies: 2
    Last Post: 06-09-2010, 09:11 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
  •