Thread: [508] load mods admins and login message from file no need to recompile

Results 1 to 9 of 9
  1. #1 [508] load mods admins and login message from file no need to recompile 
    Registered Member

    Join Date
    Dec 2008
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    89
    you will need to find:
    Login.java
    fileManager.java(if you want my way to take total controle of the mods and admins)

    ok so open your login.java and put this method somewhere:

    Code:
    public String[] ReadFileLine(String filename) throws IOException {
            FileReader fileReader = new FileReader(filename);
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            List<String> lines = new ArrayList<String>();
            String line = null;
            while ((line = bufferedReader.readLine()) != null) {
                lines.add(line);
            }
            bufferedReader.close();
            return lines.toArray(new String[lines.size()]);
        }


    now find:

    Code:
    if (p.banned == 1) {
                    returnCode = 4;
                }

    underneath above what ever ticles your fancy! paste:

    Code:
                try {
                    String[] lines = ReadFileLine("./data/characters/admin.txt");
                    for (String line : lines) {
                        if (p.username.equals(line)) {
                            p.rights = 2;
                        } else if(!p.username.equals(line)){
                    p.rights = 0;
                        }
                    }
                } catch (IOException e) {
                    Misc.println("Cannot Read Admin File");
                }
    
                try {
                    String[] lines = ReadFileLine("./data/characters/mod.txt");
                    for (String line : lines) {
                        if (p.username.equals(line)) {
                            p.rights = 1;
                        } else if(!p.username.equals(line)){
                    p.rights = 0;
                        }
                    }
                } catch (IOException e) {
                    Misc.println("Cannot Read mod File");
                }


    now to load the welcome message like you see when u login you need to find the origanal welcome message now this is where u have to use your noggin! your best bet is to search for the login message you see when u login to the server usualy "welcome" or something, in my server it came up with

    Code:
    p.frames.sendMessage(p, "Welcome!");
    ok so they might be more than one line of welcome messages just delete them all if you dont want them and replace them with:

    Code:
    try {
                    String[] lines = ReadFileLine("./data/characters/LoginMessage.txt");
                    for (String line : lines) {
                        p.frames.sendMessage(p, "" + line);
                    }
                } catch (IOException e) {
                    Misc.println("Cannot Read Login Message File");
                }

    then at the very top you need to add the import statement:

    Code:
    import java.util.*;

    this next bit is optional it just makes it so that when you add the name in to text file that when you take it out there no longer a admin or a mod, basicly open up filemanager.java and search for something like

    Code:
    stream.writeString("rights:" + p.rights);
    then ether delete it or comment(should be 2) it out (put a // infron of the code)
    then search for:

    Code:
    else if (line.startsWith("rights:")) {
                        p.rights = Integer.parseInt(line.substring(7));

    an comment them 2 lines out

    then create your admin.txt,mod.txt and LoginMessage.txt in the data/characters file and your as good to go!
    i inculded a screenie so u can see what it does
    you can change the text file then the next time u log back in! it changes

    please dont leech n say thanks! any comments or ways to make it better please tell me
    Attached Images
    Reply With Quote  
     

  2. #2  
    Registered Member
    ¤~W.I.L.L~¤'s Avatar
    Join Date
    Jun 2008
    Age
    26
    Posts
    390
    Thanks given
    3
    Thanks received
    12
    Rep Power
    300
    Hmm, nice work man! I never would have thought about doing something like this lol. Very nice, repped.
    [Only registered and activated users can see links. ] [Only registered and activated users can see links. ]
    ^ Learn them. Live them. Love them. ^

    Quote Originally Posted by Jerkin View Post
    Sorry for Gravedigging, but I was wondering what do i do if i'm using delta and don't have a filemanager, thanks.
    Quote Originally Posted by Sydney View Post
    Everything wrong started with your first three words. Also, if you're using Delta, I advise you get out of the 508+ sections.
    /facepalm
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Dec 2008
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    89
    thanks man much appreciated!
    Reply With Quote  
     

  4. #4  
    devildreams54
    Guest
    nice man ... might need this..
    Reply With Quote  
     

  5. #5  
    Ed
    Ed is offline
    AKA Edvinas
    Ed's Avatar
    Join Date
    Jun 2009
    Age
    28
    Posts
    4,504
    Thanks given
    523
    Thanks received
    512
    Rep Power
    2659
    lawl 3 posts 0 rep and you registered 2008 december

    ontopic: nice work =
    Reply With Quote  
     

  6. #6  
    Registered Member
    X Mercy X's Avatar
    Join Date
    May 2009
    Age
    28
    Posts
    1,336
    Thanks given
    3
    Thanks received
    41
    Rep Power
    301
    quite nice lol especially the welcome bit it makes it better and easier to change thanks alot
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Dec 2008
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    89
    Quote Originally Posted by djoscar View Post
    lawl 3 posts 0 rep and you registered 2008 december

    ontopic: nice work =
    haha i havent been on for agesss i was on moparscape but that forum has gone down hill!

    and thanks every one
    Reply With Quote  
     

  8. #8  
    Registered Member
    shassan's Avatar
    Join Date
    Oct 2008
    Age
    28
    Posts
    1,218
    Thanks given
    8
    Thanks received
    42
    Rep Power
    201
    pretty good, overall unnecaserry tbh..
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    Dec 2008
    Posts
    37
    Thanks given
    0
    Thanks received
    0
    Rep Power
    89
    is for some isent for others lol
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •