Thread: [PI] Give admin Command (one small error) [PI]

Results 1 to 7 of 7
  1. #1 [PI] Give admin Command (one small error) [PI] 
    Registered Member Akeid's Avatar
    Join Date
    May 2009
    Posts
    911
    Thanks given
    22
    Thanks received
    15
    Rep Power
    37
    ok guys , im trying to make a give admin cmd for pi, i already have this

    Code:
    			if (playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Akeid")) {
    				String name = playerCommand.substring(10);
    
    				try {
    					for (int j = 0; j < Server.playerHandler.players.length; j++) {
    						if (j == c.playerId)
    							continue;
    					
    				int p = Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName);
    				
    				Client c2 = (Client)Server.playerHandler.players[p];
    				c.playerRights = 2;
    				//save method here
    					}
    				} catch (Exception e) {
    				c.sendMessage("This Player isn't online or you need to log in & out.");
    				}
    			}

    The Red part is whats wrong in eclipse, can anyone help rep ++
    Reply With Quote  
     

  2. #2  
    Registered Member Regicidal's Avatar
    Join Date
    Nov 2009
    Posts
    266
    Thanks given
    11
    Thanks received
    13
    Rep Power
    43
    It's name not playername i believe.
    Reply With Quote  
     

  3. #3  
    The Illest

    iitzTyson's Avatar
    Join Date
    May 2010
    Posts
    1,164
    Thanks given
    345
    Thanks received
    73
    Rep Power
    103
    Yeah, i think he's right. If That doesnt work try adding ""'s
    Reply With Quote  
     

  4. #4  
    Registered Member Mayday Parade's Avatar
    Join Date
    Apr 2009
    Age
    27
    Posts
    495
    Thanks given
    20
    Thanks received
    17
    Rep Power
    8
    Quote Originally Posted by Tysonn View Post
    Yeah, i think he's right. If That doesnt work try adding ""'s
    I don't believe adding quotes would be correct, you are trying to make Player1 (the one using the command) make player2 (the soon-to-be admin) obtain the player rights of 2. However, it could be just the "name" without the quotes.

    EDIT: I am going to expirement with your code. When I compile it comes up with an error but you prolly know that. idk yet, so im gonna keep trying.

    Spoiler for LoL:
    Quote Originally Posted by Imbued View Post
    Quote Originally Posted by pasta186 View Post
    That tutorial doesnt walk.
    That's because it got no legs..
    Best report I've sent? "Mass spam? Also in wrong sexual"
    LOL
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Aug 2008
    Posts
    57
    Thanks given
    0
    Thanks received
    7
    Rep Power
    8
    Quote Originally Posted by akeid View Post
    ok guys , im trying to make a give admin cmd for pi, i already have this

    Code:
    			if (playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Akeid")) {
    				String name = playerCommand.substring(10);
    
    				try {
    					for (int j = 0; j < Server.playerHandler.players.length; j++) {
    						if (j == c.playerId)
    							continue;
    					
    				int p = Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName);
    				
    				Client c2 = (Client)Server.playerHandler.players[p];
    				c.playerRights = 2;
    				//save method here
    					}
    				} catch (Exception e) {
    				c.sendMessage("This Player isn't online or you need to log in & out.");
    				}
    			}

    The Red part is whats wrong in eclipse, can anyone help rep ++
    Code:
    		
    if (playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Akeid")) {
    				String name = playerCommand.substring(10);
    
    		try {
    				for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if(Server.playerHandler.players[i] != null) {
    				if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {				
    				Client c2 = (Client)Server.playerHandler.players[i];
    				c2.playerRights = 2;
    				Server.playerHandler.players[i].disconnected = true;
    					}}}
    				} catch (Exception e) {
    				c.sendMessage("This Player isn't online or you need to log in & out.");
    				}
    }
    the problem with this:
    Code:
    int p = Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName);
    is that it returns a boolean, not the players id number.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    Code:
    for(Player plr : Server.playerHandler.players)
        if(plr.playerName.equalsIgnoreCase(name)
            p = plr;
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    May 2009
    Posts
    844
    Thanks given
    44
    Thanks received
    39
    Rep Power
    29
    Thanks, i've been needing this, haha
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •