Adding Mod/Admin accounts to your Moparscape server!

    • Adding Mod/Admin accounts to your Moparscape server!

      NOTE FROM MATTSTER: I haven't actually tried this out so I don't know if it works or not.

      Purpose:
      Load data about player rights from a file.

      You need a file to store the mod and admin data in. I called mine mods.cfg. This is more practical than recompiling and restarting the server every time you add a new moderator.

      This is some pretty old code I wrote when I didn't really know much about programming, so it's pretty crappy. But it works. I'll fix it up when I have the time.

      The rest of this tutorial will be the same as the one I posted back in August 2006. I'll refine it later.

      Procedure

      Source Code

      1. public boolean loadMods(String FileName, String PName)
      2. {
      3. String line = "";
      4. String token = "";
      5. String token2 = "";
      6. String token2_2 = "";
      7. String[] token3 = new String[10];
      8. boolean EndOfFile = false;
      9. int ReadMode = 0;
      10. BufferedReader characterfile = null;
      11. try
      12. {
      13. characterfile = new BufferedReader(new FileReader("./"+FileName));
      14. }
      15. catch(FileNotFoundException fileex)
      16. {
      17. misc.println(FileName+": file not found.");
      18. return false;
      19. }
      20. try
      21. {
      22. line = characterfile.readLine();
      23. }
      24. catch(IOException ioexception)
      25. {
      26. misc.println(FileName+": error loading file.");
      27. return false;
      28. }
      29. while(EndOfFile == false && line != null)
      30. {
      31. line = line.trim();
      32. int spot = line.indexOf("=");
      33. if (spot > -1)
      34. {
      35. token = line.substring(0, spot);
      36. token = token.trim();
      37. token2 = line.substring(spot + 1);
      38. token2 = token2.trim();
      39. token2_2 = token2.replaceAll("\t\t", "\t"); //X5
      40. token3 = token2_2.split("\t");
      41. if (token.equalsIgnoreCase(PName))
      42. {
      43. playerRights = Integer.parseInt(token3[0]);
      44. }
      45. }
      46. else
      47. {
      48. if (line.equals("[ENDOFMODS]"))
      49. {
      50. try
      51. {
      52. characterfile.close();
      53. }
      54. catch(IOException ioexception) { }
      55. return true;
      56. }
      57. }
      58. try
      59. {
      60. line = characterfile.readLine();
      61. }
      62. catch(IOException ioexception1)
      63. {
      64. EndOfFile = true;
      65. }
      66. }
      67. try
      68. {
      69. characterfile.close();
      70. }
      71. catch(IOException ioexception) { }
      72. return false;
      73. }
      Display All

      You'll then need to add the mod file reader in the login procedure.

      Find the last connection.


      Source Code

      1. playerLastConnect = connectedFrom;

      After it, add the file reader for the player's name.



      Source Code

      1. loadMods("Mods.cfg",playerName);

      This will automatically make someone who is a moderator a moderator on login.

      You could even add a command so that a user could refresh their rights without even logging out and in. You would do something like this, and put it in the customCommand m

      Source Code

      1. if(command.startsWith("newmods"))
      2. {
      3. loadMods("Mods.cfg",playerName);
      4. }

      A user would just type ::newmods to have the server check if they're supposed to be a mod and then make them one if they are.


      Step 2: Usage.

      You need to organize your Mods.cfg like this.

      Source Code

      1. Aftermath_96 = 3
      2. The X Factor = 3
      3. Version = 3
      4. 00_O0o_o0 = 1
      5. zakattack395 = 1
      6. mryder73 = 1
      7. mictart3 = 2

      3 is a server owner, 1 is a silver mod, and 2 is a gold mod. You could even add a 0 to make sure a player never becomes a moderator. For that you'd add this to the end.

      Source Code

      1. somenoob = 0
      This ensures that the player somenoob will never become a mod unless you decide to change it.

      Credits: Aftermath_96
    • Re: Adding Mod/Admin accounts to your Moparscape server!

      OK I KNOW U GUYS MIGHT NOT BELIEVE ME BUT 2 CHANGE 2 ADMIN STATUS ALL U GOT 2 DO IS GO IN2 CHAR FILES THEN LOOK 4

      PLAYER RIGHTS= 0 (NOT RLY SURE IF THTZ WORD 4 WORD:eek:)

      WELL ANYWAYS CHANGE THE 0 2

      1= MOD
      2=ADMIN
      3=OWNER
      4=HIDDEN ADMIN!

      :angeldevil::o:o:eek::eek::D:D:cool::cool::wink::wink::):):rolleyes::rolleyes::hitit::hitit::drool::drool::lol::lol: