Thread: [PI] Pk Points Command

Results 1 to 8 of 8
  1. #1 [PI] Pk Points Command 
    Registered Member
    Join Date
    May 2011
    Posts
    114
    Thanks given
    10
    Thanks received
    1
    Rep Power
    2
    So I have this command,

    Code:
    			if (playerCommand.startsWith("givecp") && c.playerName.equalsIgnoreCase ("Pyroz") || c.playerName.equalsIgnoreCase("Aaron") || c.playerName.equalsIgnoreCase ("Donbest")) {
    				try {	
    					String[] args = playerCommand.split(" ");
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[i])) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.pcPoints = Integer.parseInt(args[2]);
    								c.sendMessage("You gave "+ Integer.parseInt(args[2])+" points to "+c2.playerName+", he now has "+c2.pcPoints+" points.");
    								c2.sendMessage("You recieve "+Integer.parseInt(args[2])+", you now have "+c2.pcPoints+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player must be offline.");
    				}
    			}
    And what it does , is it gives players a custom amount of PK points with just the command [::givecp (playername) (amount)]

    Only one problem, I can't get it to work with players who have spaces in their names.
    I do not want to have to disable spaces in the usernames. :/

    Help is greatly appreciated !
    Reply With Quote  
     

  2. #2  



    Join Date
    Oct 2011
    Posts
    874
    Thanks given
    301
    Thanks received
    373
    Rep Power
    338
    Code:
    if (playerCommand.startsWith("givecp") && c.playerName.equalsIgnoreCase ("Pyroz") || c.playerName.equalsIgnoreCase("Aaron") || c.playerName.equalsIgnoreCase ("Donbest")) {
    				try {	
    					String[] args = playerCommand.split(" ", 2);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[i])) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.pcPoints = Integer.parseInt(args[2]);
    								c.sendMessage("You gave "+ Integer.parseInt(args[2])+" points to "+c2.playerName+", he now has "+c2.pcPoints+" points.");
    								c2.sendMessage("You recieve "+Integer.parseInt(args[2])+", you now have "+c2.pcPoints+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player must be offline.");
    				}
    			}
    Easy enough to fix.

    Try that and tell me if it works.


    If that doesn't work, try this one instead:

    Code:
    if (playerCommand.startsWith("givecp") && c.playerName.equalsIgnoreCase ("Pyroz") || c.playerName.equalsIgnoreCase("Aaron") || c.playerName.equalsIgnoreCase ("Donbest")) {
    				try {	
    					String[] args = playerCommand.split("-");
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[i])) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.pcPoints = Integer.parseInt(args[2]);
    								c.sendMessage("You gave "+ Integer.parseInt(args[2])+" points to "+c2.playerName+", he now has "+c2.pcPoints+" points.");
    								c2.sendMessage("You recieve "+Integer.parseInt(args[2])+", you now have "+c2.pcPoints+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player must be offline.");
    				}
    			}
    Use the command above as:


    Code:
    //Player with one word
    
    ::givecp-name
    
    
    
    Player with two or more spaces
    
    ::giveco-name name

    If you're using the second command I gave you make sure you use the "-" or it won't work. You can use the first command I gave you as you normally would though. Try either one of them and tell me if they work.
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Registered Member
    Join Date
    May 2011
    Posts
    114
    Thanks given
    10
    Thanks received
    1
    Rep Power
    2
    didnt work, what is the problem?
    Reply With Quote  
     

  5. #4  



    Join Date
    Oct 2011
    Posts
    874
    Thanks given
    301
    Thanks received
    373
    Rep Power
    338
    Just updated the thread, added a second command. Try that
    Reply With Quote  
     

  6. #5  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Here use this one it will work:

    Code:
     		   if (playerCommand.startsWith("givecp") && c.playerName.equalsIgnoreCase ("Pyroz") || c.playerName.equalsIgnoreCase("Aaron") || c.playerName.equalsIgnoreCase ("Donbest")) {
     				try {
     					String[] args = playerCommand.split(" ");
     					int pointsToAdd = Integer.parseInt(args[1]);
     					String otherplayer = args[2];
     					if (args.length > 3) {
     						for(int i = 3; i < args.length; i++) {
     							otherplayer = otherplayer + " " + args[i];
     						}
     					}
     					Client target = null;
     					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
     						if(Server.playerHandler.players[i] != null) {
     							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
     								target = (Client)Server.playerHandler.players[i];
     								break;
     							}
     						}
     					}
     					if (target == null) {
     						c.sendMessage("Player doesn't exist.");
     						return;
     					}
     					c.sendMessage("You just gave " + target.playerName + " " + pointsToAdd + " PK Points.");
     					target.sendMessage("You just recieved " + pointsToAdd + " PK Points. Now have " + target.pcPoints);
     					target.pcPoints = target.pcPoints + pointsToAdd;
    	
    				} 
     				} catch(Exception e) {
     					c.sendMessage("Use as ::givecp <amt> <name>.");
     				}            
     			}
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    Registered Member
    Join Date
    May 2011
    Posts
    114
    Thanks given
    10
    Thanks received
    1
    Rep Power
    2
    Thank you !!! ^
    It worked ! I am so relieved, I have another problem though if you can help.
    My :ure and ::zerkpure command are giving triple the xp that I have put in the amount.
    I do not know why... here's the code

    Code:
    			if (playerCommand.startsWith("pure") && c.pure == 0) {
    				if (c.inWild())
    			return;
    				if (c.duelStatus == 5)
    			return;
    				int i = 0;		
    				c.getPA().addSkillXP((1212421), 0);
    				c.getPA().addSkillXP((15000000), 2);
    				c.getPA().addSkillXP((15000000), 3);
    				c.getPA().addSkillXP((15000000), 4);
    				c.getPA().addSkillXP((123660), 5);
    				c.getPA().addSkillXP((15000000), 6);
    				c.playerXP[1] = c.getPA().getXPForLevel(99)+5;
    				c.playerLevel[1] = c.getPA().getLevelForXP(c.playerXP[1]);
    				c.getPA().refreshSkill(1);
    				c.pure = 1;
    				c.SaveGame();
    				c.sendMessage("You are now a pure. If you are trying to downgrade,");
    				c.sendMessage("Please type in ::resetall to reset all stats, then try again.");
    			}
    			
    			if (playerCommand.startsWith("zerkpure") && c.zerkpure == 0) {
    				if (c.inWild())
    			return;
    			if (c.duelStatus == 5)
    			return;
    				int i = 0;		
    				c.getPA().addSkillXP((15000000), 0);
    				c.getPA().addSkillXP((61512), 1);
    				c.getPA().addSkillXP((15000000), 2);
    				c.getPA().addSkillXP((15000000), 3);
    				c.getPA().addSkillXP((15000000), 4);
    				c.getPA().addSkillXP((15000000), 5);
    				c.getPA().addSkillXP((15000000), 6);
    				c.playerXP[1] = c.getPA().getXPForLevel(99)+5;
    				c.playerLevel[1] = c.getPA().getLevelForXP(c.playerXP[1]);
    				c.getPA().refreshSkill(1);
    				c.zerkpure = 1;
    				c.SaveGame();
    				c.sendMessage("You are now a zerker pure. If you are trying to downgrade,");
    				c.sendMessage("Please type in ::resetall to reset all stats, then try again.");
    			}
    Reply With Quote  
     

  9. #7  
    Registered Member
    Join Date
    Jun 2011
    Posts
    220
    Thanks given
    3
    Thanks received
    13
    Rep Power
    2
    ok...1) what is this "int i?" What does it do???
    2) you don't need to do addskillXP((int), int)..just do addSkillXP(int, int)
    3) change the command from .startsWith to .equalsIgnoreCase...no reason to have .startsWith
    4) You're telling it to add 61512 xp to skill one, yet you're saying that c.playerXP[1] is c.getPA().getXPForLevel(99)+5??? makes no sense.
    5) You don't even refresh other skills besides 1....

    Code:
    if (playerCommand.equalsIgnoreCase("pure") && c.pure == 0) {
    	if (c.inWild() || c.duelStatus == 5) { return; }
    	for(int i = 1; i < 7; i++) {
    		if(i == 5) { continue; }
    		c.getPA().addSkillXP(15000000, i);
    		c.getPA().addSkillXP(1212421, 0); //75
    		c.getPA().addSkillXP(123660, 5); //52
    		c.playerXP[i] = c.getPA().getXPForLevel(99)+5;
    		c.playerLevel[i] = c.getPA().getLevelForXP(c.playerXP[i]);
    		c.getPA().refreshSkill(i);
    		c.playerXP[0] = c.getPA().getXPForLevel(75)+5;
    		c.playerLevel[0] = c.getPA().getLevelForXP(c.playerXP[0]);
    		c.getPA().refreshSkill(0);
    		c.playerXP[5] = c.getPA().getXPForLevel(52)+5;
    		c.playerLevel[5] = c.getPA().getLevelForXP(c.playerXP[5]);
    		c.getPA().refreshSkill(5);
    		c.pure = 1;
    		c.SaveGame();
    		c.sendMessage("You are now a pure. If you are trying to downgrade,");
    		c.sendMessage("Please type in ::resetall to reset all stats, then try again.");
    	}
    }			
    if (playerCommand.equalsIgnoreCase("zerkpure") && c.zerkpure == 0) {
    	if (c.inWild() || c.duelStatus == 5) { return; }
    	for(int i =	0; i < 7; i++) {
    		if(i == 1) { continue; }
    		c.getPA().addSkillXP(15000000, i);
    		c.getPA().addSkillXP(61512, 1); //45
    		c.playerXP[i] = c.getPA().getXPForLevel(99)+5;
    		c.playerLevel[i] = c.getPA().getLevelForXP(c.playerXP[i]);
    		c.getPA().refreshSkill(i);
    		c.playerXP[1] = c.getPA().getXPForLevel(45)+5;
    		c.playerLevel[1] = c.getPA().getLevelForXP(c.playerXP[1]);
    		c.getPA().refreshSkill(1);
    		c.zerkpure = 1;
    		c.SaveGame();
    		c.sendMessage("You are now a zerker pure. If you are trying to downgrade,");
    		c.sendMessage("Please type in ::resetall to reset all stats, then try again.");
    	}
    }
    That should work.
    Reply With Quote  
     

  10. Thankful user:


  11. #8  
    Registered Member
    Join Date
    May 2011
    Posts
    114
    Thanks given
    10
    Thanks received
    1
    Rep Power
    2
    You guys are just amazing. Its so good to see people actually willing to help newcomers ! (:
    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] Give Points Command
    By ParadoxPvP in forum Help
    Replies: 12
    Last Post: 02-08-2012, 03:23 AM
  2. [PI] Command need points rep++
    By arcane-scape in forum Help
    Replies: 4
    Last Post: 11-27-2011, 12:11 PM
  3. [PI] Command or w.e. to check your points.
    By Mikey in forum Snippets
    Replies: 5
    Last Post: 08-24-2011, 07:28 PM
  4. [PI] ::give points command?
    By Acquittal in forum Help
    Replies: 7
    Last Post: 01-30-2011, 05:25 AM
  5. Delta Pk Points Command?
    By pluck in forum Help
    Replies: 0
    Last Post: 01-29-2011, 03:58 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
  •