Thread: [PI] SOF Giving Spins Command [PI]

Results 1 to 5 of 5
  1. #1 [PI] SOF Giving Spins Command [PI] 
    AleronPS


    Join Date
    Dec 2017
    Posts
    93
    Thanks given
    99
    Thanks received
    10
    Rep Power
    73
    Hello people!

    I have a Question, it may be explained already but i can't find a post..
    My Command for giving SOF Spins looks like this:

    Code:
    	if (playerCommand.startsWith("givespins") && c.playerRights == 8) {
    	    try {
    		String[] args = playerCommand.split("-");
    		int amount = Integer.parseInt(args[1]);
    		String otherplayer = args[2];
    		Client c2 = null;
    		for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    		    if(PlayerHandler.players[i] != null) {
    			if(PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
    			    c2 = (Client)PlayerHandler.players[i];
    			    break;
    			}
    		    }
    		}
    		if (c2 == null) {
    		    c.sendMessage("Player doesn't exist.");
    		    return;
    		}
    		c.sendMessage("You have just given " + amount + " SOF spins.");
    		c2.sendMessage("You have just been given " + amount + " SOF spins." );	
    		c2.spinsLe += amount;	
    	    } catch(Exception e) {
    		c.sendMessage("::givespins-AMOUNT-PLAYERNAME");
    		c.sendMessage("Do not just give these OUT need to donate for them! OR DEMOTE -teemo-");
    	    }            
    	}
    Is it wrong, or why doesn't it work Eclipse shows no warning, but the Spins are not given when i use the Command.

    Thanks in advance!
    Yours Sincerely,
    Eliyahu | Aleron

    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Why not debug and find out? You know there are more reasons for a piece of code not to work other than it having errors/warnings (warnings aren't equal to errors and will very rarely be the reason why your code doesn't work).
    Ensure that the code's even being reached..
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Oct 2011
    Posts
    2,084
    Thanks given
    0
    Thanks received
    1,043
    Rep Power
    3608
    most-likely a line or two isn't being called. insert "system.out.println" somewhere along the lines and pinpoint exactly where that occurs.
    Reply With Quote  
     

  4. #4  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Check if the code is even being send.
    If it is being send then it might be this part which give you trouble:
    Code:
    			if(PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
    			    c2 = (Client)PlayerHandler.players[i];
    			    break;
    			}


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  5. #5  
    Extreme Donator


    Join Date
    Aug 2016
    Posts
    597
    Thanks given
    109
    Thanks received
    96
    Rep Power
    254
    Are you player rights 8? Also that for loop seems a little extreme...I don't think you should be looping through the entire max amount of players your server can hold probably just the ones online? Are any of the messages being sent? Player not online or sending spins?
    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 [PI]
    By i Leo i in forum Help
    Replies: 2
    Last Post: 07-23-2014, 10:22 PM
  2. [PI] Give Points Command [PI]
    By i Leo i in forum Requests
    Replies: 0
    Last Post: 07-21-2014, 07:15 AM
  3. [PI] Give Points Command [PI]
    By i Leo i in forum Requests
    Replies: 1
    Last Post: 07-21-2014, 06:42 AM
  4. [PI] Simple Give Rights Command [PI]
    By Impervious in forum Help
    Replies: 7
    Last Post: 06-26-2011, 02:40 AM
  5. [PI] How to make Commands? [PI]
    By Amirtje12 in forum Help
    Replies: 4
    Last Post: 08-20-2010, 12:46 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
  •