[Tut] [317] Chat, CMD, Yell ... Logs!

Results 1 to 9 of 9
  1. #1
    Laravel Core Programmer Jangan is offline
    DeveloperRank
    Jul 2007 Join Date
    Dubai, UAELocation
    2,113Posts

    [Tut] [317] Chat, CMD, Yell ... Logs!

    this is taken from an old site... its over a 6 months old tutorial with load of bugs, so i took it and fixed all the bugs in it and here i am giving it away to you guys =)

    Purpose : To add a really good logging system

    Difficulty : 1/10

    Assumed Knowledge : Copy/Paste

    Server Base : Tested (works for all)

    Classes Modified : client.java

    Procedure
    Step 1 : Open client.java and add these voids:

    PHP Code:
    public void ChatLog (String text) {

          
    BufferedWriter bw null;

          try {
             
    bw = new BufferedWriter(new FileWriter("logs/chatlogs.txt"true));
         
    bw.write(playerName+": "+text);
         
    bw.newLine();
         
    bw.flush();
          } catch (
    IOException ioe) {
         
    ioe.printStackTrace();
          } finally {
         if (
    bw != null) try {
            
    bw.close();
         } catch (
    IOException ioe2) {
          
    misc.println("[Chat Logging Failed!]");
         }
          }

       }

     public 
    void YellLog (String text) {

          
    BufferedWriter bw null;

          try {
             
    bw = new BufferedWriter(new FileWriter("logs/yellogs.txt"true));
         
    bw.write(playerName+": "+text);
         
    bw.newLine();
         
    bw.flush();
          } catch (
    IOException ioe) {
         
    ioe.printStackTrace();
          } finally {
         if (
    bw != null) try {
            
    bw.close();
         } catch (
    IOException ioe2) {
        
    misc.println("[Yell Logging Failed]");
         }
          }

       }

      public 
    void CmdLog (String cmd) {

          
    BufferedWriter bw null;

          try {
             
    bw = new BufferedWriter(new FileWriter("logs/commandlogs.txt"true));
         
    bw.write(playerName+": "+cmd);
         
    bw.newLine();
         
    bw.flush();
          } catch (
    IOException ioe) {
         
    ioe.printStackTrace();
          } finally {
         if (
    bw != null) try {
            
    bw.close();
         } catch (
    IOException ioe2) {
        
    misc.println("[CMD Logging Failed]");
         }
          }

       } 


    Step 2
    :
    search for
    PHP Code:
    if (command.startsWith("yell") && command.length() > 5
    and below or whatever it is on your server add this:
    PHP Code:
     PlayerHandler.messageToAll playerName+": "+command.substring(5); 
         
    YellLog(command.substring(5)); 
    then search for case 4: and under:

    PHP Code:
     inStream.readBytes_reverseA(chatTextchatTextSize0);
    chatTextUpdateRequired true
    add this:
    PHP Code:
          ChatLog(playerchat); 
    then search for case 103: and under customCommand(playerCommand); add this:
    PHP Code:
    CmdLog(playerCommand); 
    Step 3 : make 3 txt files called commandlogs yellogs and serverchatlogs in the logs folder if you don't have a logs folder make one and your done save and compile


  2. #2
    Account Upgraded | Title Enabled! Raul_haro is offline
    MemberRank
    Jul 2007 Join Date
    the pits of hellLocation
    176Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    GREAT tut man although it's not originally yours great job on the edits *applaud*

  3. #3
    Laravel Core Programmer Jangan is offline
    DeveloperRank
    Jul 2007 Join Date
    Dubai, UAELocation
    2,113Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    i did make a log like that before.. its pretty easy actually =) but yeah i just got a made one already, and fixed it up no one reported any bugs so far hehe tested on 4 svrs and all work

    *NOTE* if you have a big svr like mine, i dont recommand to have a "chat Log" because that will just lag your svr if you have 80 people on talking a lot lol! your log would go to like 5mb an hour =P

  4. #4
    Account Upgraded | Title Enabled! Spinny is offline
    MemberRank
    Jul 2007 Join Date
    CanadaLocation
    393Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    This Guide Doesn't Tell You WHERE To Add The Stuff..

  5. #5
    Laravel Core Programmer Jangan is offline
    DeveloperRank
    Jul 2007 Join Date
    Dubai, UAELocation
    2,113Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    Quote Originally Posted by Spinny View Post
    This Guide Doesn't Tell You WHERE To Add The Stuff..
    All the info is right there =S
    Last edited by Jangan; 06-10-07 at 12:15 AM.

  6. #6
    Novice pigiot is offline
    MemberRank
    Oct 2007 Join Date
    1Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    i get this error when compiling...

    PHP Code:
    client.java:10687cannot find symbol
    symbol  
    variable playerchat
    location
    : class client
                    ChatLog
    (playerchat);
                            ^
    Notestream.java uses or overrides a deprecated API.
    NoteRecompile with -Xlint:deprecation for details.
    1 error
    Press any key to 
    continue . . . 
    Can someone help me?

  7. #7
    Apprentice DontThink is offline
    MemberRank
    Oct 2007 Join Date
    WA, AustraliaLocation
    22Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    Thanks for this Jangan, much appreciated.

  8. #8
    Infraction Banned OMG.Matt is offline
    MemberRank
    Jul 2007 Join Date
    108Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    hmm looks good but im not going to try it lol ... ill just keep it how it is

    but yer looks good *claps*

  9. #9
    Ex-Mod bitblaster is offline
    MemberRank
    Nov 2004 Join Date
    UNHANDLED EXCEPLocation
    2,614Posts

    Re: [TuT] Chat, CMD, Yell ... Logs!

    will move to knowledge base.



Advertisement