Thread: [PI] Better command logging.

Results 1 to 5 of 5
  1. #1 [PI] Better command logging. 
    Registered Member
    vovik ukr's Avatar
    Join Date
    Aug 2010
    Posts
    1,240
    Thanks given
    136
    Thanks received
    187
    Rep Power
    278
    This is pi's code just edited to make it look more neater and organized

    Go to Player.java
    declare this:
    Code:
    public boolean isyelling = false;
    Than go to Commands.java.
    under
    Code:
    String playerCommand = c.getInStream().readString();
    add:

    Code:
    if (!playerCommand.startsWith("/") && !playerCommand.startsWith("yell"))
            {
                c.getPA().writeCommandLog(playerCommand);
            }
    than look for:
    Code:
    if (playerCommand.startsWith("yell")
    and under it add

    Code:
    c.isyelling = true;
    						c.getPA().writeCommandLog(playerCommand);
    Lastly go to PlayerAssitant.java and replace this with your old one:

    Code:
    		public void writeCommandLog(String command)
    	{
    		checkDateAndTime();
    		String filePath = "./Data/logs/commands/playerommands.txt";
    		String filePath1 = "./Data/logs/commands/staffommands.txt";
    		String filePath2 = "./Data/logs/commands/ownerommands.txt";
    		String filePath3 = "./Data/logs/commands/yellommands.txt";
    		BufferedWriter bw = null;
    		
    		try 
    		{				
    		if ((c.playerRights > 0 && c.playerRights < 3) && c.isyelling == false) {
    			bw = new BufferedWriter(new FileWriter(filePath1, true));
    		} else if (c.playerRights == 3 && c.isyelling == false) {
    			bw = new BufferedWriter(new FileWriter(filePath2, true));
    		} else if (c.isyelling == true) {
    			bw = new BufferedWriter(new FileWriter(filePath3, true));
    			c.isyelling = false;
    		} else if(c.playerRights == 0 && c.isyelling == false){
    			bw = new BufferedWriter(new FileWriter(filePath, true));
    		}
    			bw.write("["+c.playerName+"]: "+"["+c.date+"]"+" - "+"["+c.connectedFrom+"] "+"::"+command);
    			bw.newLine();
    			bw.flush();
    		} 
    		catch (IOException ioe) 
    		{
    			ioe.printStackTrace();
    		} 
    		finally 
    		{
    			if (bw != null)
    			{
    				try 
    				{
    					bw.close();
    				} 
    				catch (IOException ioe2) 
    				{
    				}
    			}
    		}
    	}
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Dr. Jaegon


    Join Date
    Sep 2011
    Posts
    2,132
    Thanks given
    407
    Thanks received
    441
    Rep Power
    2559
    Very nice might use this
    Reply With Quote  
     

  4. #3  
    Donator

    Thock321's Avatar
    Join Date
    Jul 2011
    Posts
    1,804
    Thanks given
    706
    Thanks received
    363
    Rep Power
    416
    Looks alright, just need to know the use of it.
    Reply With Quote  
     

  5. #4  
    強い者は生き残る
    Ashpire's Avatar
    Join Date
    Mar 2012
    Age
    27
    Posts
    2,721
    Thanks given
    914
    Thanks received
    1,897
    Rep Power
    2231
    nice bro. doesn't Mystic-effect have this
    Attached image
    Reply With Quote  
     

  6. #5  
    Registered Member
    vovik ukr's Avatar
    Join Date
    Aug 2010
    Posts
    1,240
    Thanks given
    136
    Thanks received
    187
    Rep Power
    278
    Quote Originally Posted by Psychopath View Post
    nice bro. doesn't Mystic-effect have this
    no i don't think so he might have wrote a similar one tho.


    Quote Originally Posted by thock321 View Post
    Looks alright, just need to know the use of it.
    use? it logs all the commands players do except "/" because that for clan chat. It also creates each file for normal player commands staff commands, owner commands and yell commands so it will be easier to separate the yell commands and staff abuse commands or w.e.
    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. Logging in, logging out problem
    By u22u in forum Help
    Replies: 2
    Last Post: 06-21-2012, 04:45 PM
  2. Logging out
    By pvp owner in forum Help
    Replies: 2
    Last Post: 12-04-2011, 01:17 AM
  3. [pi] not logging in!
    By haydar25 in forum Help
    Replies: 10
    Last Post: 11-25-2011, 03:52 PM
  4. [PI] logging out?
    By trayswizzle25 in forum Help
    Replies: 10
    Last Post: 11-18-2010, 11:19 PM
  5. Replies: 3
    Last Post: 08-03-2008, 06:36 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
  •