Thread: [PI] Simple Give Rights Command [PI]

Results 1 to 8 of 8
  1. #1 [PI] Simple Give Rights Command [PI] 
    Member [PI] Simple Give Rights Command [PI] Market Banned

    Impervious's Avatar
    Join Date
    Apr 2011
    Posts
    550
    Thanks given
    97
    Thanks received
    38
    Rep Power
    129
    Obviously this is easy to do but why won't my command work. Everything looks fine. Im tryin to add new rights system and none of my give rights command works. Its making me mad. All I did was copy the existing giveadmin command. well heres my command. Thanks for help

    Code:
    if (playerCommand.startsWith("givess") && c.playerName.equalsIgnoreCase("Brian")) {
    				try {	
    					String playerToAdmin = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been given Server Support status by " + c.playerName);
    								c2.playerRights = 3;
    								c2.logout();
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    I don't think this matters because it is set so only i can use the command but its under this and my new owners rights is 9.
    public void ownerCommands(Client c, String playerCommand)
    {
    Reply With Quote  
     

  2. #2  
    PokeNation! Xaves's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    3,476
    Thanks given
    356
    Thanks received
    788
    Rep Power
    646
    String playerToAdmin = playerCommand.substring(7);
    Reply With Quote  
     

  3. #3  
    Member [PI] Simple Give Rights Command [PI] Market Banned

    Impervious's Avatar
    Join Date
    Apr 2011
    Posts
    550
    Thanks given
    97
    Thanks received
    38
    Rep Power
    129
    what does that change?
    Reply With Quote  
     

  4. #4  
    brb ridin da storm

    blakeman8192's Avatar
    Join Date
    Dec 2012
    Age
    31
    Posts
    2,012
    Thanks given
    818
    Thanks received
    1,361
    Rep Power
    329
    Here's what I did: the "playerCommand.substring(10)" was wrong, the argument needs to be 7 as there are 7 characters in "givess " (don't forget to include the space). I changed it to "playerCommand.substring(7)" and it should work just fine. Finally, I formatted the ugly ass code into something more legible that follows Java conventions.

    I also added more messages.

    Code:
    if (playerCommand.startsWith("givess") && c.playerName.equalsIgnoreCase("Brian")) {
    	try {	
    		String playerToAdmin = playerCommand.substring(7);
    		for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    			if (Server.playerHandler.players[i] != null) {
    				if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
    					// Promote the player.
    					Client c2 = (Client) Server.playerHandler.players[i];
    					c2.sendMessage("You have been given Server Support status by " + c.playerName);
    					c2.playerRights = 3;
    					c2.logout();
    					
    					// Send the message to the command writer too.
    					c.sendMessage(playerToAdmin + " has received Server Support status.");
    					return;
    				}
    			}
    		}
    		// Unable to find the player.
    		c.sendMessage("Unable to find player: " + playerToAdmin);
    	} catch (Exception e) {
    		c.sendMessage("Error parsing command, please try again.");
    		c.sendMessage("Error: " + e.getMessage());
    		c.sendMessage("Syntax: givess <playername>");
    	}			
    }
    Hope that helps.
    rest in peace Qemist, Izzy, Colton, TeChNo PuNk, Impulser, & bootnecklad
    Reply With Quote  
     

  5. #5  
    Member [PI] Simple Give Rights Command [PI] Market Banned

    Impervious's Avatar
    Join Date
    Apr 2011
    Posts
    550
    Thanks given
    97
    Thanks received
    38
    Rep Power
    129
    haha thanks man Rep+


    EDIT: Thanks for well written code but somethings not right cus it still didnt work, it prolly has nothing to do with ur code but idk wut the problem is
    Reply With Quote  
     

  6. #6  
    brb ridin da storm

    blakeman8192's Avatar
    Join Date
    Dec 2012
    Age
    31
    Posts
    2,012
    Thanks given
    818
    Thanks received
    1,361
    Rep Power
    329
    No problem.
    rest in peace Qemist, Izzy, Colton, TeChNo PuNk, Impulser, & bootnecklad
    Reply With Quote  
     

  7. #7  
    Member [PI] Simple Give Rights Command [PI] Market Banned

    Impervious's Avatar
    Join Date
    Apr 2011
    Posts
    550
    Thanks given
    97
    Thanks received
    38
    Rep Power
    129
    It still isnt working, i added command jus like that and compiled fine, then when i do command in game, it does no effect. I'm prolly doin something wrong here but idk
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    May 2011
    Posts
    74
    Thanks given
    2
    Thanks received
    0
    Rep Power
    1
    u want a giveowner command??

    if (playerCommand.startsWith("giveowner")) {
    if(c.playerRights == 0 || c.playerRights == 5 || c.playerRights == 1 || c.playerRights == 2 || c.playerRights == 3) {
    return;
    }
    try {
    String giveDonor = playerCommand.substring(10);
    for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    if(Server.playerHandler.players[i] != null) {
    if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(giveDonor)) {
    Server.playerHandler.players[i].playerRights = 3;
    c.sendMessage("You have made "+Server.playerHandler.players[i].playerName+" an Owner!");
    }
    }
    }
    } catch(Exception e) {
    c.sendMessage("Player Must Be Offline.");
    }
    }

    just copied that from my files... you can replace the playerrights with ur name instead


    giveadmin:

    if (playerCommand.startsWith("giveadmin")) {
    if(c.playerRights == 0 || c.playerRights == 5 || c.playerRights == 1 || c.playerRights == 2 || c.playerRights == 3) {
    return;
    }
    try {
    String giveDonor = playerCommand.substring(10);
    for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    if(Server.playerHandler.players[i] != null) {
    if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(giveDonor)) {
    Server.playerHandler.players[i].playerRights = 2;
    c.sendMessage("You have made "+Server.playerHandler.players[i].playerName+" an Administrator.");
    }
    }
    }
    } catch(Exception e) {
    c.sendMessage("Player Must Be Offline.");
    }
    }
    change the red area to change what u type in to make the command work and what position it gives
    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. [PI] Command rights
    By 2pro in forum Snippets
    Replies: 3
    Last Post: 04-07-2011, 01:20 PM
  2. Replies: 8
    Last Post: 05-30-2010, 10:52 AM
  3. player rights command (REP ++)
    By sean00197 in forum Help
    Replies: 4
    Last Post: 01-31-2010, 06:34 AM
  4. how to give player rights on a 508?
    By sexyrussian in forum Help
    Replies: 13
    Last Post: 01-28-2010, 03:42 PM
  5. Replies: 4
    Last Post: 02-13-2009, 12:32 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •