Thread: Premium Method Command Problem

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 Premium Method Command Problem 
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    So I am adding a simple premium method to my server..

    The player save added fine without any errors

    Now I am trying to add a command to give players premium status

    Here is the command code

    Code:
    			if (playerCommand.startsWith("giveprem")) {
    				try {	
    					String playerToVet = playerCommand.substring(8);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToPrem)) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been given premium status by " + c.playerName);
    								c2.isPremium = 1;
    								c2.logout();
    								
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    Here are the save methods:

    Code:
    } else if (token.equals("isPremium")) {
    						p.isPremium = Integer.parseInt(token2);
    Code:
    			characterfile.write("isPremium = ", 0, 12);
    			characterfile.write(Integer.toString(p.isPremium), 0,      Integer.toString(p.isPremium).length());
    Error:

    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    May 2009
    Posts
    290
    Thanks given
    3
    Thanks received
    59
    Rep Power
    53
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Quote Originally Posted by the egg pk View Post
    I see that..

    And I want to know where I went wrong..
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Edit
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Fixed it myself.. It was this line:

    String playerToVet = playerCommand.substring(8);
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Nevermind..

    The command is still not working..

    No errors at all

    Here is the command code:

    Code:
    if (playerCommand.startsWith("giveprem")) {
    				try {	
    					String playerToPre = playerCommand.substring(8);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToPre)) {
    								Client c2 = (Client)Server.playerHandler.players[i];	
    								c2.sendMessage("You have been given premium status by " + c.playerName);
    								c2.isPremium = 1;
    								c2.logout();
    								
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    Reply With Quote  
     

  7. #7  
    Registered Member
    The Wanderer's Avatar
    Join Date
    Mar 2010
    Posts
    596
    Thanks given
    44
    Thanks received
    152
    Rep Power
    196
    It may be your substring, not certain though. Add a out print to make sure it works correctly... like...

    System.out.println("Player Name: " + Server.playerHandler.players[i].playerName + ", Premium: " + c2.isPremium + ".");

    That way you can check to make sure the name is correct and that it is changing the value correctly. Just add that right before the break;
    "But men may construe things after their fashion,. Clean from the purpose of the things themselves" - Shakespeare
    Reply With Quote  
     

  8. Thankful user:


  9. #8  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Quote Originally Posted by The Wanderer View Post
    It may be your substring, not certain though. Add a out print to make sure it works correctly... like...

    System.out.println("Player Name: " + Server.playerHandler.players[i].playerName + ", Premium: " + c2.isPremium + ".");

    That way you can check to make sure the name is correct and that it is changing the value correctly. Just add that right before the break;
    Thanks for this, But I tested the command on myself and a couple of players..

    It does not log them out.. Just like it should.. And when it does when I use ::givevet or ::givedonor

    And it does not set the status in the character files
    Reply With Quote  
     

  10. #9  
    Registered Member
    The Wanderer's Avatar
    Join Date
    Mar 2010
    Posts
    596
    Thanks given
    44
    Thanks received
    152
    Rep Power
    196
    Then the error lies with your substring. It isn't getting the right player name from the command. At least, that is the only thing that sounds logical to me. You would know if the name was correct if you added my check. My thinking is that when you type ::giveprem scotticus it is taking " scotticus". So therefore it isn't giving the premium to "scotticus", but to " scotticus". See what I mean?
    "But men may construe things after their fashion,. Clean from the purpose of the things themselves" - Shakespeare
    Reply With Quote  
     

  11. Thankful user:


  12. #10  
    Registered Member
    Join Date
    Jan 2011
    Age
    36
    Posts
    223
    Thanks given
    75
    Thanks received
    6
    Rep Power
    25
    Quote Originally Posted by The Wanderer View Post
    Then the error lies with your substring. It isn't getting the right player name from the command. At least, that is the only thing that sounds logical to me. You would know if the name was correct if you added my check. My thinking is that when you type ::giveprem scotticus it is taking " scotticus". So therefore it isn't giving the premium to "scotticus", but to " scotticus". See what I mean?
    Ye, I see what you mean.. How can I fix it
    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. AUTODONATION PROBLEM!Webpage command problem!
    By Jay Gatsby in forum Help
    Replies: 5
    Last Post: 10-24-2011, 07:06 PM
  2. 317 PI command problem
    By Tinkerbell1234 in forum Help
    Replies: 12
    Last Post: 05-03-2011, 08:47 PM
  3. 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
  •