Thread: command problems

Results 1 to 5 of 5
  1. #1 command problems 
    Banned

    Join Date
    Nov 2012
    Posts
    1,094
    Thanks given
    173
    Thanks received
    136
    Rep Power
    0
    Code:
    if(p.Pin != null){
    							characterfile.write("Pin = ", 0, 6);
    							characterfile.write(p.Pin, 0, p.Pin.length());
    							characterfile.newLine();
    							}
    That is what it's saving it as.



    command to set the pin -


    Code:
    if (playerCommand.startsWith("setpin")) {
    		
    			if (c.Pin == "None"){
    			try {
    				String Pin = playerCommand.substring(9);
    				String[] args = playerCommand.split(" ");
    				c.Pin = Pin;
    				c.sendMessage("@blu@Your safety PIN is now: " + c.Pin);
    			} catch (Exception ex) {
    				ex.printStackTrace();
    			}
    			}else{
    			c.sendMessage("@red@You have already set your safety PIN.");
    			}
    }

    Basically when you type :etpin it misses out numbers like sometimes it'll say 'your safety pin is now: 04' when you set it as '2904'
    Reply With Quote  
     

  2. #2  
    Perplexity owner

    Join Date
    Feb 2011
    Posts
    171
    Thanks given
    32
    Thanks received
    15
    Rep Power
    0
    Quote Originally Posted by _Sean View Post
    Code:
    if(p.Pin != null){
    							characterfile.write("Pin = ", 0, 6);
    							characterfile.write(p.Pin, 0, p.Pin.length());
    							characterfile.newLine();
    							}
    That is what it's saving it as.



    command to set the pin -


    Code:
    if (playerCommand.startsWith("setpin")) {
    		
    			if (c.Pin == "None"){
    			try {
    				String Pin = playerCommand.substring(9);
    				String[] args = playerCommand.split(" ");
    				c.Pin = Pin;
    				c.sendMessage("@blu@Your safety PIN is now: " + c.Pin);
    			} catch (Exception ex) {
    				ex.printStackTrace();
    			}
    			}else{
    			c.sendMessage("@red@You have already set your safety PIN.");
    			}
    }

    Basically when you type :etpin it misses out numbers like sometimes it'll say 'your safety pin is now: 04' when you set it as '2904'

    if you look at this logically it missed of the first 2 numbers of your command and only took the info from the last 2 you entered

    the problem is in the second line try figure out why yourself first, if your having difficulty let me know and i will help you further
    Code:
    if (playerCommand.startsWith("setpin")) {
    Code:
    String Pin = playerCommand.substring(9);
    Reply With Quote  
     

  3. #3  
    Registered Member Jumper's Avatar
    Join Date
    Aug 2013
    Posts
    721
    Thanks given
    19
    Thanks received
    103
    Rep Power
    63
    or he could use the split string in there so command name/length doesn't matter

    Code:
    if (playerCommand.startsWith("setpin")) {
    	if (c.Pin.length() < 1){
    		try {
    			String[] args = playerCommand.split(" ");
    			c.Pin = args[1];
    			c.sendMessage("@blu@Your safety PIN is now: " + c.Pin);
    		} catch (Exception ex) {
    			ex.printStackTrace();
    		}
    	} else {
    		c.sendMessage("@red@You have already set your safety PIN.");
    	}
    }
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Nov 2012
    Posts
    1,094
    Thanks given
    173
    Thanks received
    136
    Rep Power
    0
    FIXED, thanks guys for the help anyways.
    Reply With Quote  
     

  5. #5  
    Donator

    Join Date
    Oct 2014
    Posts
    587
    Thanks given
    29
    Thanks received
    76
    Rep Power
    26
    Quote Originally Posted by Jumper View Post
    or he could use the split string in there so command name/length doesn't matter

    Code:
    if (playerCommand.startsWith("setpin")) {
    	if (c.Pin.length() < 1){
    		try {
    			String[] args = playerCommand.split(" ");
    			c.Pin = args[1];
    			c.sendMessage("@blu@Your safety PIN is now: " + c.Pin);
    		} catch (Exception ex) {
    			ex.printStackTrace();
    		}
    	} else {
    		c.sendMessage("@red@You have already set your safety PIN.");
    	}
    }
    And what if a player wants to use a space in their pin? You would have to give a warning to use a underscore or something and revert that back again using String#replace.

    Thats why it might be better to just use substring.
    Programming service - Fast, Cheap & Quality
    http://www.rune-server.org/black-mar...-services.html

    Project that I am currently working on:
    http://www.rune-server.org/runescape...emon-rsps.html

    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. [iClarity] My Jail Command Problem
    By Zetux in forum Help
    Replies: 3
    Last Post: 09-26-2009, 03:41 PM
  2. Command problems hard to explain.
    By P A N I C in forum Help
    Replies: 12
    Last Post: 07-16-2009, 09:09 PM
  3. ::char command problems
    By giggadude in forum Help
    Replies: 11
    Last Post: 07-13-2009, 11:18 PM
  4. command problem on delta
    By d34d pk3r in forum Requests
    Replies: 4
    Last Post: 04-01-2009, 02:04 AM
  5. Command Problem
    By Chachi in forum Help
    Replies: 10
    Last Post: 02-08-2009, 06:37 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
  •