Thread: Help with ::yell for premium.

Results 1 to 5 of 5
  1. #1 Help with ::yell for premium. 
    Banned
    Join Date
    Dec 2008
    Age
    28
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I made this code so only premium member can yell:

    Code:
    if (command.startsWith("yell") && command.length() > 8) {     
       if(premiumStatus >= 1){
          if(!muted){
             String text = command.substring(5);
             yell(playerName +":  " + Character.toUpperCase(text.charAt(0)) + text.substring(1));
          } else {
             sM("You are muted you cannot yell!");
          }
       } else {
          sM("You need to be a Premium Member to use the yell command.");
       }
    }
    But only the thing that doesn't work is when a non premium try to yell, it doesn't say: "You need to be a Premium Member to use the yell command.". How can I make it so it can show?

    Thanks.
     

  2. #2  
    Registered Member
    Join Date
    Dec 2009
    Posts
    253
    Thanks given
    5
    Thanks received
    0
    Rep Power
    3
    Try useing this:
    Code:
    if (command.startsWith("yell") && command.length() > 8) {     
       if(premiumStatus >= 1){
          if(!muted){
             String text = command.substring(5);
             yell(playerName +":  " + Character.toUpperCase(text.charAt(0)) + text.substring(1));
          } else {
             sM("You are muted you cannot yell!");
          }
       } if(premiumStatus == 0){
          sM("You need to be a Premium Member to use the yell command.");
       }
    }
     

  3. #3  
    Banned
    Join Date
    Dec 2008
    Age
    28
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by addinol View Post
    Try useing this:
    Code:
    if (command.startsWith("yell") && command.length() > 8) {     
       if(premiumStatus >= 1){
          if(!muted){
             String text = command.substring(5);
             yell(playerName +":  " + Character.toUpperCase(text.charAt(0)) + text.substring(1));
          } else {
             sM("You are muted you cannot yell!");
          }
       } if(premiumStatus == 0){
          sM("You need to be a Premium Member to use the yell command.");
       }
    }
    Code:
    if (command.startsWith("yell") && command.length() > 8) {     
       if(premiumStatus >= 1){
          if(!muted){
             String text = command.substring(5);
             yell(playerName +": " + Character.toUpperCase(text.charAt(0)) + text.substring(1));
          } else {
             sM("You are muted you cannot yell!");
          }
       } if(premiumStatus == 0){
          sM("You need to be a Premium Member to use the yell command.");
       }
    }
    Now it works but we need to say at least 3 words to yell or else it doesn't show. How can I make it so I can only say at least 1 word?
     

  4. #4  
    Previously Hyperion


    Join Date
    Jan 2009
    Posts
    1,254
    Thanks given
    3
    Thanks received
    18
    Rep Power
    138
    command.length() > 5
     

  5. #5  
    Registered Member
    PSNB's Avatar
    Join Date
    Aug 2009
    Posts
    885
    Thanks given
    8
    Thanks received
    103
    Rep Power
    590
    for the words, you can do

    Code:
    String[] words = command.substring(5).split(" ");
        	
    if(words.length < WORDS_REQUIRED)
    return;
    This will create a substring starting at the 5th character (Start of first word). Then it splits that substring at the spaces (into separate words). Then it checks to see if the length of the 'words' array is smaller than the required number of words needed to send the message. If there's not enough words, it'll just return. If you want, you can change the 'return' to something to inform the user. that they need to send longer messages.
     


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
  •