Don't like ads? PRO users don't see any ads ;-)
Guest

startup

By: a guest on May 26th, 2012  |  syntax: Lua  |  size: 26.52 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- TOMOYO I
  2. -- SERVER
  3. -- Developed by Dotsonface / qwzx11 (qwzx11 is my minecraft username)
  4. -- V1.0.1
  5.  
  6. --[[
  7.  
  8. Version History:
  9. 0.2b Pre-Release B
  10. 1.0.0 Initial Release
  11. 1.0.1 Single Configuration Mode
  12.  
  13. Usage:
  14. You will be asked where your modem is located, if not specified the computer will not be able to make a connection. Then once that is completed, You will
  15. be asked what mode to set the server on, there are 2 modes: Private, and Public. Public works currently and private is very outdated and will be fixed later.
  16.  
  17. Server Modes:
  18.  
  19. Public ::
  20. --->User Finding Mode
  21.         --->Waiting for users
  22.         --->User is found
  23.         --->Go to Find Prompt
  24. --->Find Prompt
  25.         --->Ask for permission to wait for more users.
  26.         --- Y = Go to User Finding Mode
  27.         --- N = Go to Server Mode
  28. --->Server Mode
  29.         --->Display chat
  30.         --- W = Go to User Finding Mode
  31.         --- C = Go to Command Mode
  32.         --- CTRL+T = Terminate
  33. --->Command Mode
  34.         --->Act as an administrative mode.
  35.         --- help = Brings up list of commands
  36.         --- help *command* = Brings up description of how to use command
  37.         --- list = Lists all users currently online and their computer id's
  38.         --- server = Go to Server Mode
  39.         --- wait = Go to User Finding Mode
  40.  
  41. --]]
  42.  
  43. term.clear()
  44. term.setCursorPos(1, 1)
  45. print("Tomoyo Server I v1.0.1 - Config")
  46.  
  47. print("Where is your wireless modem located?")
  48. local rednet_location
  49. rednet_location = io.read()
  50.  
  51. if rednet_location == "left" then
  52.         print("Connected")
  53. elseif rednet_location == "right" then
  54.         print("Connected")
  55. elseif rendet_location == "back" then
  56.         print("Connected")
  57. else
  58.         print("NOT VALID")
  59. end
  60.  
  61. term.clear()
  62. rednet.open(rednet_location) -- Open Internet
  63.  
  64. local mode
  65. local server_name
  66. local user1id
  67. local user2id
  68. local user3id
  69. local user4id
  70. local user5id
  71. local user1
  72. local user2
  73. local user3
  74. local user4
  75. local user5
  76. local banned1id
  77. local banned2id
  78. local banned3id
  79. local banned4id
  80. local banned5id
  81.  
  82. print("Name server.")
  83. server_name = io.read()
  84.  
  85. term.clear()
  86.  
  87. user1id = ""
  88. user2id = ""
  89. user3id = ""
  90. user4id = ""
  91. user5id = ""
  92. user1 = ""
  93. user2 = ""
  94. user3 = ""
  95. user4 = ""
  96. user5 = ""
  97.  
  98. function select_mode ()
  99.  
  100.         print("Please select your mode.")
  101.         mode = io.read()
  102.  
  103.         if mode == "help" then
  104.                 print("Mode List: ")
  105.                 print("private")
  106.                 print("public")
  107.                 print("public ignore") -- NEW
  108.                 select_mode()
  109.         elseif mode == "private" then
  110.                 print("Select User 1.")
  111.                 user1id = io.read()
  112.                 print("Select User 2.")
  113.                 user2id = io.read()
  114.                
  115.                 user1id = tonumber(user1id)
  116.                 user2id = tonumber(user2id)
  117.                 timeline=0
  118.                 server()
  119.         elseif mode == "public" then
  120.                 print("Opening...")
  121.                 timeline=0
  122.                 auto_answer=0
  123.                 users_wait=1
  124.                 server_public()
  125.         elseif mode == "public ignore" then
  126.                 print("Opening...")
  127.                 print("How many users to wait for?")
  128.                 users_wait = tonumber(io.read())
  129.                 if users_wait >= 5 then
  130.                         users_wait = 5
  131.                 end
  132.                 os.sleep(1)
  133.                 print("Waiting for users to connect!")
  134.                 os.sleep(2)
  135.                 term.clear()
  136.                 term.setCursorPos(1, 1)
  137.                 print("Tomoyo Server I v1.0.1 - User-Finding Mode")
  138.                 timeline=0
  139.                 auto_answer = 1
  140.                 server_public()
  141.         else
  142.                 print("Invalid mode, type 'help' for a list of modes.")
  143.                 os.sleep(1)
  144.                 select_mode()
  145.         end
  146.        
  147. end
  148.  
  149.  
  150.  
  151.  -- Private Server v1.0.1
  152. function server ()
  153.  
  154.         while timeline == 0 do
  155.                 action, senderID, text = os.pullEvent()
  156.                 if action == "rednet_message" then
  157.                         if senderID == user1id then
  158.                                 if user1 ~= "" then
  159.                                         rednet.send(senderID, "006")
  160.                                         print("Returned: In User-Finding Mode.")
  161.                                 else
  162.                                 user1 = text
  163.                                 rednet.send(senderID, "001")
  164.                                 if user2 ~= "" then
  165.                                         timeline = 1
  166.                                 else
  167.                                         print("Waiting on other user.")
  168.                                 end
  169.                                 end
  170.                         elseif senderID == user2id then
  171.                                 if user2 ~= "" then
  172.                                         rednet.send(senderID, "006")
  173.                                         print("Returned: In User-Finding Mode.")
  174.                                 else
  175.                                 user2 = text
  176.                                 rednet.send(senderID, "001")
  177.                                 if user1 ~= "" then
  178.                                         timeline = 1
  179.                                 else
  180.                                         print("Waiting on other user.")
  181.                                 end
  182.                                 end
  183.                         else
  184.                                 rednet.send(senderID, "004")
  185.                                 print("Returned: Access Denied!")
  186.                         end
  187.                 elseif action == "char" then
  188.                         if senderID == "s" or senderID == "S" then
  189.                                 print("Skipping to server!")
  190.                                 os.sleep(1)
  191.                                 term.clear()
  192.                                 timeline = 1
  193.                         elseif senderID == "c" or senderID == "C" then
  194.                                 print("Going to console!")
  195.                                 os.sleep(1)
  196.                                 term.clear()
  197.                                 print("Tomoyo Server I V1.0.0")
  198.                                 timeline = 2
  199.                         end
  200.                 end
  201.         end
  202.        
  203.         while timeline == 1 do
  204.         action, senderID, text = os.pullEvent()
  205.         if action == "rednet_message" then
  206.                 if senderID == user1id then
  207.                         rednet.send(user1id, "001")
  208.                         print(user1 .. ": " .. text)
  209.                         rednet.send(user2id, user1 .. ": " .. text)
  210.                 elseif senderID == user2id then
  211.                         rednet.send(user2id, "001")
  212.                         print(user2 .. ": " .. text)
  213.                         rednet.send(user1id, user2 .. ": " .. text)
  214.                 else
  215.                         rednet.send(senderID, "004")
  216.                 end
  217.         elseif action == "char" then
  218.                 if senderID == "r" or senderID == "R" then
  219.                         print("Resetting!")
  220.                         user1id = ""
  221.                         user2id = ""
  222.                         user1 = ""
  223.                         user2 = ""
  224.                         select_mode()
  225.                 elseif senderID == "c" or senderID == "C" then
  226.                         print("Administrative Mode")
  227.                         os.sleep(3)
  228.                         term.clear()
  229.                         term.setCursorPos(1, 1)
  230.                         print("Tomoyo Server I V1.0.0")
  231.                         timeline=2
  232.                 end
  233.         end
  234.         end
  235.        
  236.         while timeline == 2 do
  237.                 command = io.read()
  238.                 if command == "help" then
  239.                         print("reset   list   switch   save   help   server   reset_names   version")
  240.                 elseif command == "version" then -- Version 1.0.1
  241.                         print("Tomoyo Server I v1.0.1")
  242.                 elseif command == "reset" then
  243.                         print("Resetting!")
  244.                         user1id = ""
  245.                         user2id = ""
  246.                         user1 = ""
  247.                         user2 = ""
  248.                         select_mode()
  249.                 elseif command == "list" then
  250.                         print("Computer ID: " .. user1id .. " registered with username: " .. user1)
  251.                         print("Computer ID: " .. user2id .. " registered with username: " .. user2)
  252.                 elseif command == "switch" then
  253.                         print("Select User 1")
  254.                         user1id = tonumber(io.read())
  255.                         print("Select User 2")
  256.                         user2id = tonumber(io.read())
  257.                         if user1id ~= "" then
  258.                                 print("User 1 test: Success!")
  259.                         else
  260.                                 print("User 1 test: Failure!")
  261.                         end
  262.                         if user2id ~= "" then
  263.                                 print("User 2 test: Success!")
  264.                         else
  265.                                 print("User 2 test: Failure!")
  266.                         end
  267.                 elseif command == "save" then
  268.                         print("Test 1...")
  269.                         rednet.broadcast("001")
  270.                         os.sleep(1)
  271.                         print("Test 2...")
  272.                         rednet.broadcast("001")
  273.                         os.sleep(1)
  274.                         print("Test 3...")
  275.                         rednet.broadcast("001")
  276.                         os.sleep(1)
  277.                         print("Test 4...")
  278.                         rednet.broadcast("001")
  279.                         os.sleep(1)
  280.                         print("Test 5...")
  281.                         rednet.broadcast("001")
  282.                         print("Completed!")
  283.                 elseif command == "server" then
  284.                         print("Running main server!")
  285.                         os.sleep(3)
  286.                         term.clear()
  287.                         term.setCursorPos(1, 1)
  288.                         timeline=1
  289.                 elseif command == "reset_names" then
  290.                         print("Resetting names...")
  291.                         user1 = ""
  292.                         user2 = ""
  293.                         print("Waiting for user input...")
  294.                         timeline=0
  295.                 elseif command == "help reset" then
  296.                         print("Resets the entire server, to beginning to select mode.")
  297.                 elseif command == "help list" then
  298.                         print("Lists the connected users.")
  299.                 elseif command == "help save" then
  300.                         print("A safety measure to prevent computers from freezing.")
  301.                 elseif command == "help switch" then
  302.                         print("Allows you to reselect who can connect to the server.")
  303.                 elseif command == "help server" then
  304.                         print("Returns to the main server.")
  305.                 elseif command == "help reset_names" then      
  306.                         print("Waits for the users to change their names.")
  307.                 else
  308.                         print("Invalid command.")
  309.                 end
  310.         end
  311.        
  312.        
  313.         server()
  314. end
  315.  
  316. -- MOST RECENT VERSION
  317. function server_public ()
  318.        
  319.         -- USER FINDING MODE
  320.         while timeline==0 do
  321.                 action, senderID, text = os.pullEvent()
  322.                 if action == "rednet_message" then
  323.                         if user1id == "" then
  324.                                 -- Tomoyo Security Block V1.0.0 :: Banned List
  325.                                 if senderID == banned1id then
  326.                                         rednet.send(senderID, "008")
  327.                                         if blockmessage ~= "Y" then
  328.                                                 print("BLOCKED")
  329.                                                 blockmessage = "Y"
  330.                                         end
  331.                                 elseif senderID == banned2id then
  332.                                         rednet.send(senderID, "008")
  333.                                         if blockmessage ~= "Y" then
  334.                                                 print("BLOCKED")
  335.                                                 blockmessage = "Y"
  336.                                         end
  337.                                 elseif senderID == banned3id then
  338.                                         rednet.send(senderID, "008")
  339.                                         if blockmessage ~= "Y" then
  340.                                                 print("BLOCKED")
  341.                                                 blockmessage = "Y"
  342.                                         end
  343.                                 elseif senderID == banned4id then
  344.                                         rednet.send(senderID, "008")
  345.                                         if blockmessage ~= "Y" then
  346.                                                 print("BLOCKED")
  347.                                                 blockmessage = "Y"
  348.                                         end
  349.                                 elseif senderID == banned5id then
  350.                                         rednet.send(senderID, "008")
  351.                                         if blockmessage ~= "Y" then
  352.                                                 print("BLOCKED")
  353.                                                 blockmessage = "Y"
  354.                                         end
  355.                                 else
  356.                                         user1id = senderID
  357.                                         user1 = text
  358.                                         print(text .. " has logged in with computer id " .. senderID)
  359.                                         rednet.send(senderID, "001")
  360.                                         if auto_answer == 0 then
  361.                                                 timeline=1
  362.                                         else
  363.                                                 if users_wait == 1 then
  364.                                                         print("Main server mode!")
  365.                                                         timeline=2
  366.                                                 end
  367.                                         end    
  368.                                 end
  369.                         elseif user2id == "" then
  370.                                 if senderID == user1id then
  371.                                         rednet.send(user1id, "006")
  372.                                 elseif senderID == user3id then
  373.                                         rednet.send(user3id, "006")
  374.                                 elseif senderID == user4id then
  375.                                         rednet.send(user4id, "006")
  376.                                 elseif senderID == user5id then
  377.                                         rednet.send(user5id, "006")
  378.                                 else
  379.                                 -- Tomoyo Security Block V1.0.0 :: Banned List
  380.                                 if senderID == banned1id then
  381.                                         rednet.send(senderID, "008")
  382.                                         if blockmessage ~= "Y" then
  383.                                                 print("BLOCKED")
  384.                                                 blockmessage = "Y"
  385.                                         end
  386.                                 elseif senderID == banned2id then
  387.                                         rednet.send(senderID, "008")
  388.                                         if blockmessage ~= "Y" then
  389.                                                 print("BLOCKED")
  390.                                                 blockmessage = "Y"
  391.                                         end
  392.                                 elseif senderID == banned3id then
  393.                                         rednet.send(senderID, "008")
  394.                                         if blockmessage ~= "Y" then
  395.                                                 print("BLOCKED")
  396.                                                 blockmessage = "Y"
  397.                                         end
  398.                                 elseif senderID == banned4id then
  399.                                         rednet.send(senderID, "008")
  400.                                         if blockmessage ~= "Y" then
  401.                                                 print("BLOCKED")
  402.                                                 blockmessage = "Y"
  403.                                         end
  404.                                 elseif senderID == banned5id then
  405.                                         rednet.send(senderID, "008")
  406.                                         if blockmessage ~= "Y" then
  407.                                                 print("BLOCKED")
  408.                                                 blockmessage = "Y"
  409.                                         end
  410.                                 else
  411.                                         user2id = senderID
  412.                                         user2 = text
  413.                                         print(text .. " has logged in with computer id " .. senderID)
  414.                                         rednet.send(senderID, "001")
  415.                                         if auto_answer == 0 then
  416.                                                 timeline=1
  417.                                         else
  418.                                                 if users_wait == 2 then
  419.                                                         print("Main server mode!")
  420.                                                         timeline=2
  421.                                                 end
  422.                                         end    
  423.                                 end
  424.                                 end
  425.                         elseif user3id == "" then
  426.                                 if senderID == user1id then
  427.                                         rednet.send(user1id, "006")
  428.                                 elseif senderID == user2id then
  429.                                         rednet.send(user2id, "006")
  430.                                 elseif senderID == user4id then
  431.                                         rednet.send(user4id, "006")
  432.                                 elseif senderID == user5id then
  433.                                         rednet.send(user5id, "006")
  434.                                 else
  435.                                 -- Tomoyo Security Block V1.0.0 :: Banned List
  436.                                 if senderID == banned1id then
  437.                                         rednet.send(senderID, "008")
  438.                                         if blockmessage ~= "Y" then
  439.                                                 print("BLOCKED")
  440.                                                 blockmessage = "Y"
  441.                                         end
  442.                                 elseif senderID == banned2id then
  443.                                         rednet.send(senderID, "008")
  444.                                         if blockmessage ~= "Y" then
  445.                                                 print("BLOCKED")
  446.                                                 blockmessage = "Y"
  447.                                         end
  448.                                 elseif senderID == banned3id then
  449.                                         rednet.send(senderID, "008")
  450.                                         if blockmessage ~= "Y" then
  451.                                                 print("BLOCKED")
  452.                                                 blockmessage = "Y"
  453.                                         end
  454.                                 elseif senderID == banned4id then
  455.                                         rednet.send(senderID, "008")
  456.                                         if blockmessage ~= "Y" then
  457.                                                 print("BLOCKED")
  458.                                                 blockmessage = "Y"
  459.                                         end
  460.                                 elseif senderID == banned5id then
  461.                                         rednet.send(senderID, "008")
  462.                                         if blockmessage ~= "Y" then
  463.                                                 print("BLOCKED")
  464.                                                 blockmessage = "Y"
  465.                                         end
  466.                                 else
  467.                                         user3id = senderID
  468.                                         user3 = text
  469.                                         print(text .. " has logged in with computer id " .. senderID)
  470.                                         rednet.send(senderID, "001")
  471.                                         if auto_answer == 0 then
  472.                                                 timeline=1
  473.                                         else
  474.                                                 if users_wait == 3 then
  475.                                                         print("Main server mode!")
  476.                                                         timeline=2
  477.                                                 end
  478.                                         end    
  479.                                 end
  480.                                 end
  481.                         elseif user4id == "" then
  482.                                 if senderID == user1id then
  483.                                         rednet.send(user1id, "006")
  484.                                 elseif senderID == user2id then
  485.                                         rednet.send(user2id, "006")
  486.                                 elseif senderID == user3id then
  487.                                         rednet.send(user3id, "006")
  488.                                 elseif senderID == user5id then
  489.                                         rednet.send(user5id, "006")
  490.                                 else
  491.                                 -- Tomoyo Security Block V1.0.0 :: Banned List
  492.                                 if senderID == banned1id then
  493.                                         rednet.send(senderID, "008")
  494.                                         if blockmessage ~= "Y" then
  495.                                                 print("BLOCKED")
  496.                                                 blockmessage = "Y"
  497.                                         end
  498.                                 elseif senderID == banned2id then
  499.                                         rednet.send(senderID, "008")
  500.                                         if blockmessage ~= "Y" then
  501.                                                 print("BLOCKED")
  502.                                                 blockmessage = "Y"
  503.                                         end
  504.                                 elseif senderID == banned3id then
  505.                                         rednet.send(senderID, "008")
  506.                                         if blockmessage ~= "Y" then
  507.                                                 print("BLOCKED")
  508.                                                 blockmessage = "Y"
  509.                                         end
  510.                                 elseif senderID == banned4id then
  511.                                         rednet.send(senderID, "008")
  512.                                         if blockmessage ~= "Y" then
  513.                                                 print("BLOCKED")
  514.                                                 blockmessage = "Y"
  515.                                         end
  516.                                 elseif senderID == banned5id then
  517.                                         rednet.send(senderID, "008")
  518.                                         if blockmessage ~= "Y" then
  519.                                                 print("BLOCKED")
  520.                                                 blockmessage = "Y"
  521.                                         end
  522.                                 else
  523.                                         user4id = senderID
  524.                                         user4 = text
  525.                                         print(text .. " has logged in with computer id " .. senderID)
  526.                                         rednet.send(senderID, "001")
  527.                                         if auto_answer == 0 then
  528.                                                 timeline=1
  529.                                         else
  530.                                                 if users_wait == 4 then
  531.                                                         print("Main server mode!")
  532.                                                         timeline=2
  533.                                                 end
  534.                                         end    
  535.                                 end
  536.                                 end
  537.                         elseif user5id == "" then
  538.                                 if senderID == user1id then
  539.                                         rednet.send(user1id, "006")
  540.                                 elseif senderID == user2id then
  541.                                         rednet.send(user2id, "006")
  542.                                 elseif senderID == user3id then
  543.                                         rednet.send(user3id, "006")
  544.                                 elseif senderID == user4id then
  545.                                         rednet.send(user4id, "006")
  546.                                 else
  547.                                 -- Tomoyo Security Block V1.0.0 :: Banned List
  548.                                 if senderID == banned1id then
  549.                                         rednet.send(senderID, "008")
  550.                                         if blockmessage ~= "Y" then
  551.                                                 print("BLOCKED")
  552.                                                 blockmessage = "Y"
  553.                                         end
  554.                                 elseif senderID == banned2id then
  555.                                         rednet.send(senderID, "008")
  556.                                         if blockmessage ~= "Y" then
  557.                                                 print("BLOCKED")
  558.                                                 blockmessage = "Y"
  559.                                         end
  560.                                 elseif senderID == banned3id then
  561.                                         rednet.send(senderID, "008")
  562.                                         if blockmessage ~= "Y" then
  563.                                                 print("BLOCKED")
  564.                                                 blockmessage = "Y"
  565.                                         end
  566.                                 elseif senderID == banned4id then
  567.                                         rednet.send(senderID, "008")
  568.                                         if blockmessage ~= "Y" then
  569.                                                 print("BLOCKED")
  570.                                                 blockmessage = "Y"
  571.                                         end
  572.                                 elseif senderID == banned5id then
  573.                                         rednet.send(senderID, "008")
  574.                                         if blockmessage ~= "Y" then
  575.                                                 print("BLOCKED")
  576.                                                 blockmessage = "Y"
  577.                                         end
  578.                                 else
  579.                                         user1id = senderID
  580.                                         user1 = text
  581.                                         print(text .. " has logged in with computer id " .. senderID)
  582.                                         rednet.send(senderID, "001")
  583.                                         print("Out of user slots.")
  584.                                         print("Running main server!")
  585.                                         os.sleep(2)
  586.                                         term.clear()
  587.                                         term.setCursorPos(1,1)
  588.                                         print("Tomoyo Server I v1.0.1 - Main Server Mode")
  589.                                         timeline = 2
  590.                                 end
  591.                                 end
  592.                         else
  593.                                 print("Returned: Critical Error")
  594.                                 rednet.send(senderID, "010")
  595.                                 timeline=1
  596.                         end
  597.                 end
  598.         end
  599.        
  600.         -- WAIT PROMPT MODE
  601.         while timeline==1 do
  602.                 print("Wait for more users?")
  603.                 command = io.read()
  604.                 if command == "help" then
  605.                         print("try y/n, y being Yes and n being No.")
  606.                 elseif command == "y" then
  607.                         print("Waiting for more users.")
  608.                         os.sleep(1)
  609.                         term.clear()
  610.                         timeline=0
  611.                 elseif command == "n" then
  612.                         if user2id == "" then
  613.                                 print("Must wait for more users, only 1 user is logged in with id: " .. user1id .. " and name: " .. user1 .. ".")
  614.                         else
  615.                                 print("Running main server!")
  616.                                 os.sleep(1)
  617.                                 term.clear()
  618.                                 timeline=2
  619.                         end
  620.                 else
  621.                         print("Invalid command, type help for some help.")
  622.                 end
  623.         end
  624.        
  625.         -- SERVER MODE
  626.         while timeline==2 do
  627.                 action, senderID, text = os.pullEvent()
  628.                 if action == "rednet_message" then
  629.                         if senderID == user1id then
  630.                                 if text == "LOGOFF" then
  631.                                         print("User 1 has logged off.")
  632.                                         user1id = ""
  633.                                         user1 = ""
  634.                                        
  635.                                         -- User Log Off Fix v1.0.0
  636.                                         if user2id ~= "" then
  637.                                                 user1id = user2id
  638.                                                 user1 = user2
  639.                                                 if user3id ~= "" then
  640.                                                         user2id = user3id
  641.                                                         user2 = user3
  642.                                                         if user4id ~= "" then
  643.                                                                 user3id = user4id
  644.                                                                 user3 = user4
  645.                                                                 if user5id ~= "" then
  646.                                                                         user4id = user5id
  647.                                                                         user4 = user5
  648.                                                                         user5id = ""
  649.                                                                         user5 = ""
  650.                                                                 else
  651.                                                                         user4id = ""
  652.                                                                         user4 = ""
  653.                                                                 end
  654.                                                         else
  655.                                                                 user3id = ""
  656.                                                                 user3 = ""
  657.                                                         end
  658.                                                 else
  659.                                                         user2id = ""
  660.                                                         user2 = ""
  661.                                                 end
  662.                                         else
  663.                                                 print("Waiting for more users.")
  664.                                                 timeline = 0
  665.                                         end
  666.                                        
  667.                                         if auto_answer == 0 then
  668.                                                 print("Do you wish to wait for more users?")
  669.                                                 command = io.read()
  670.                                                 if command == "y" then
  671.                                                         print("Waiting for more users.")
  672.                                                         os.sleep(1)
  673.                                                         term.clear()
  674.                                                         timeline=0
  675.                                                 elseif command == "n" then
  676.                                                         print("No action taken.")
  677.                                                 else
  678.                                                         print("No action taken.")
  679.                                                 end
  680.                                         else
  681.                                                 print("No action taken.")
  682.                                         end
  683.                                 else
  684.                                         print(user1 .. ": " .. text)
  685.                                         rednet.send(senderID, "001")
  686.                                         if user1id ~= "" then
  687.                                                 rednet.send(user1id, user1 .. ": " .. text)
  688.                                         end
  689.                                         if user2id ~= "" then
  690.                                                 rednet.send(user2id, user1 .. ": " .. text)
  691.                                         end
  692.                                         if user3id ~= "" then
  693.                                                 rednet.send(user3id, user1 .. ": " .. text)
  694.                                         end
  695.                                         if user4id ~= "" then
  696.                                                 rednet.send(user4id, user1 .. ": " .. text)
  697.                                         end
  698.                                         if user5id ~= "" then
  699.                                                 rednet.send(user5id, user1 .. ": " .. text)
  700.                                         end
  701.                                 end
  702.                         elseif senderID == user2id then
  703.                                 if text == "LOGOFF" then
  704.                                         print("User 2 has logged off.")
  705.                                         user2id = ""
  706.                                         user2 = ""
  707.                                        
  708.                                         -- User Log Off Fix v1.0.0
  709.                                         if user3id ~= "" then
  710.                                                 user2id = user3id
  711.                                                 user2 = user3
  712.                                                 if user4id ~= "" then
  713.                                                         user3id = user4id
  714.                                                         user3 = user4
  715.                                                         if user5id ~= "" then
  716.                                                                 user4id = user5id
  717.                                                                 user4 = user5
  718.                                                                 user5id = ""
  719.                                                                 user5 = ""
  720.                                                         else
  721.                                                                 user4id = ""
  722.                                                                 user4 = ""
  723.                                                         end
  724.                                                 else
  725.                                                         user3id = ""
  726.                                                         user3 = ""
  727.                                                 end
  728.                                         end
  729.                                        
  730.                                         if auto_answer == 0 then
  731.                                                 print("Do you wish to wait for more users?")
  732.                                                 command = io.read()
  733.                                                 if command == "y" then
  734.                                                         print("Waiting for more users.")
  735.                                                         os.sleep(1)
  736.                                                         term.clear()
  737.                                                         timeline=0
  738.                                                 elseif command == "n" then
  739.                                                         print("No action taken.")
  740.                                                 else
  741.                                                         print("No action taken.")
  742.                                                 end
  743.                                         else
  744.                                                 print("No action taken.")
  745.                                         end
  746.                                 else
  747.                                         print(user2 .. ": " .. text)
  748.                                         rednet.send(senderID, "001")
  749.                                         if user1id ~= "" then
  750.                                                 rednet.send(user1id, user2 .. ": " .. text)
  751.                                         end
  752.                                         if user2id ~= "" then
  753.                                                 rednet.send(user2id, user2 .. ": " .. text)
  754.                                         end
  755.                                         if user3id ~= "" then
  756.                                                 rednet.send(user3id, user2 .. ": " .. text)
  757.                                         end
  758.                                         if user4id ~= "" then
  759.                                                 rednet.send(user4id, user2 .. ": " .. text)
  760.                                         end
  761.                                         if user5id ~= "" then
  762.                                                 rednet.send(user5id, user2 .. ": " .. text)
  763.                                         end
  764.                                 end
  765.                         elseif senderID == user3id then
  766.                                 if text == "LOGOFF" then
  767.                                         print("User 3 has logged off.")
  768.                                         user3id = ""
  769.                                         user3 = ""
  770.                                        
  771.                                         -- User Log Off Fix v1.0.0
  772.                                         if user4id ~= "" then
  773.                                                 user3id = user4id
  774.                                                 user3 = user4
  775.                                                 if user5id ~= "" then
  776.                                                         user4id = user5id
  777.                                                         user4 = user5
  778.                                                         user5id = ""
  779.                                                         user5 = ""
  780.                                                 else
  781.                                                         user4id = ""
  782.                                                         user4 = ""
  783.                                                 end
  784.                                         end
  785.                                        
  786.                                         if auto_answer == 0 then
  787.                                                 print("Do you wish to wait for more users?")
  788.                                                 command = io.read()
  789.                                                 if command == "y" then
  790.                                                         print("Waiting for more users.")
  791.                                                         os.sleep(1)
  792.                                                         term.clear()
  793.                                                         timeline=0
  794.                                                 elseif command == "n" then
  795.                                                         print("No action taken.")
  796.                                                 else
  797.                                                         print("No action taken.")
  798.                                                 end
  799.                                         else
  800.                                                 print("No action taken.")
  801.                                         end
  802.                                 else
  803.                                         print(user3 .. ": " .. text)
  804.                                         rednet.send(senderID, "001")
  805.                                         if user1id ~= "" then
  806.                                                 rednet.send(user1id, user3 .. ": " .. text)
  807.                                         end
  808.                                         if user2id ~= "" then
  809.                                                 rednet.send(user2id, user3 .. ": " .. text)
  810.                                         end
  811.                                         if user3id ~= "" then
  812.                                                 rednet.send(user3id, user3 .. ": " .. text)
  813.                                         end
  814.                                         if user4id ~= "" then
  815.                                                 rednet.send(user4id, user3 .. ": " .. text)
  816.                                         end
  817.                                         if user5id ~= "" then
  818.                                                 rednet.send(user5id, user3 .. ": " .. text)
  819.                                         end
  820.                                 end
  821.                         elseif senderID == user4id then
  822.                                 if text == "LOGOFF" then
  823.                                         print("User 4 has logged off.")
  824.                                         user4id = ""
  825.                                         user4 = ""
  826.                                        
  827.                                         -- User Log Off Fix v1.0.0
  828.                                         if user5id ~= "" then
  829.                                                 user4id = user5id
  830.                                                 user4 = user5
  831.                                                 user5id = ""
  832.                                                 user5 = ""
  833.                                         end
  834.                                        
  835.                                         if auto_answer == 0 then
  836.                                                 print("Do you wish to wait for more users?")
  837.                                                 command = io.read()
  838.                                                 if command == "y" then
  839.                                                         print("Waiting for more users.")
  840.                                                         os.sleep(1)
  841.                                                         term.clear()
  842.                                                         timeline=0
  843.                                                 elseif command == "n" then
  844.                                                         print("No action taken.")
  845.                                                 else
  846.                                                         print("No action taken.")
  847.                                                 end
  848.                                         else
  849.                                                 print("No action taken.")
  850.                                         end
  851.                                 else
  852.                                         print(user4 .. ": " .. text)
  853.                                         rednet.send(senderID, "001")
  854.                                         if user1id ~= "" then
  855.                                                 rednet.send(user1id, user4 .. ": " .. text)
  856.                                         end
  857.                                         if user2id ~= "" then
  858.                                                 rednet.send(user2id, user4 .. ": " .. text)
  859.                                         end
  860.                                         if user3id ~= "" then
  861.                                                 rednet.send(user3id, user4 .. ": " .. text)
  862.                                         end
  863.                                         if user4id ~= "" then
  864.                                                 rednet.send(user4id, user4 .. ": " .. text)
  865.                                         end
  866.                                         if user5id ~= "" then
  867.                                                 rednet.send(user5id, user4 .. ": " .. text)
  868.                                         end
  869.                                 end
  870.                         elseif senderID == user5id then
  871.                                 if text == "LOGOFF" then
  872.                                         print("User 5 has logged off.")
  873.                                         user5id = ""
  874.                                         user5 = ""
  875.                                         if auto_answer == 0 then
  876.                                                 print("Do you wish to wait for more users?")
  877.                                                 command = io.read()
  878.                                                 if command == "y" then
  879.                                                         print("Waiting for more users.")
  880.                                                         os.sleep(1)
  881.                                                         term.clear()
  882.                                                         timeline=0
  883.                                                 elseif command == "n" then
  884.                                                         print("No action taken.")
  885.                                                 else
  886.                                                         print("No action taken.")
  887.                                                 end
  888.                                         else
  889.                                                 print("No action taken.")
  890.                                         end
  891.                                 else
  892.                                         print(user5 .. ": " .. text)
  893.                                         rednet.send(senderID, "001")
  894.                                         if user1id ~= "" then
  895.                                                 rednet.send(user1id, user5 .. ": " .. text)
  896.                                         end
  897.                                         if user2id ~= "" then
  898.                                                 rednet.send(user2id, user5 .. ": " .. text)
  899.                                         end
  900.                                         if user3id ~= "" then
  901.                                                 rednet.send(user3id, user5 .. ": " .. text)
  902.                                         end
  903.                                         if user4id ~= "" then
  904.                                                 rednet.send(user4id, user5 .. ": " .. text)
  905.                                         end
  906.                                         if user5id ~= "" then
  907.                                                 rednet.send(user5id, user5 .. ": " .. text)
  908.                                         end
  909.                                 end
  910.                         else
  911.                                 rednet.send(senderID, "007")
  912.                                 print("Someone tried to connect without being logged on, do you wait to wait for log-in information?")
  913.                                 if auto_answer == 0 then
  914.                                         command = io.read()
  915.                                         if command == "y" then
  916.                                                 print("Waiting for more users...")
  917.                                                 os.sleep(1)
  918.                                                 term.clear()
  919.                                                 timeline=0
  920.                                         elseif command == "n" then
  921.                                                 print("Taking no action.")
  922.                                         else
  923.                                                 print("Taking no action.")
  924.                                         end
  925.                                 else
  926.                                         print("Auto Answer: No")
  927.                                 end
  928.                         end
  929.                 elseif action == "char" then
  930.                         if senderID == "c" then
  931.                                 print("Administrative mode...")
  932.                                 print("While in this mode, no one can connect to the server!")
  933.                                 os.sleep(3)
  934.                                 term.clear()
  935.                                 term.setCursorPos(1, 1)
  936.                                 print("Tomoyo Server I v1.0.0")
  937.                                 timeline=3
  938.                         elseif senderID == "w" then
  939.                                 print("Waiting for more users.")
  940.                                 os.sleep(1)
  941.                                 term.clear()
  942.                                 timeline=0
  943.                         else
  944.                                 print("Key:" .. senderID .. " was pressed.")
  945.                         end
  946.                 end
  947.         end
  948.        
  949.         -- COMMAND PROMPT MODE
  950.         while timeline==3 do
  951.                 command = io.read()
  952.                 if command == "help" then
  953.                         print("wait   server   help   list   ban   banlist   version")
  954.                 elseif command == "version" then -- Version 1.0.1
  955.                         print("Tomoyo Server I v1.0.1")
  956.                 elseif command == "server" then
  957.                         print("Main server mode...")
  958.                         os.sleep(3)
  959.                         term.clear()
  960.                         timeline=2
  961.                 elseif command == "ban" then
  962.                         if ban1id ~= "" then   
  963.                                 if ban2id ~= "" then
  964.                                         if ban3id ~= "" then
  965.                                                 if ban4id ~= "" then
  966.                                                         if ban5id ~= "" then
  967.                                                                 print("Cannot ban anymore computers.")
  968.                                                         else
  969.                                                                 print("Type in the computer ID to ban.")
  970.                                                                 ban5id = tonumber(io.read())
  971.                                                         end
  972.                                                 else
  973.                                                         print("Type in the computer ID to ban.")
  974.                                                         ban4id = tonumber(io.read())
  975.                                                 end
  976.                                         else
  977.                                                 print("Type in the computer ID to ban.")
  978.                                                 ban3id = tonumber(io.read())
  979.                                         end
  980.                                 else
  981.                                         print("Type in the computer ID to ban.")
  982.                                         ban2id = tonumber(io.read())
  983.                                 end
  984.                         else
  985.                                 print("Type in the computer ID to ban.")
  986.                                 ban1id = tonumber(io.read())
  987.                         end
  988.                 elseif command == "banlist" then
  989.                         if ban1id ~= "" then
  990.                                 print("Computer ID: " .. ban1id .. " is banned.")
  991.                         end
  992.                         if ban2id ~= "" then
  993.                                 print("Computer ID: " .. ban2id .. " is banned.")
  994.                         end
  995.                         if ban3id ~= "" then
  996.                                 print("Computer ID: " .. ban3id .. " is banned.")
  997.                         end
  998.                         if ban4id ~= "" then
  999.                                 print("Computer ID: " .. ban4id .. " is banned.")
  1000.                         end
  1001.                         if ban5id ~= "" then
  1002.                                 print("Computer ID: " .. ban5id .. " is banned.")
  1003.                         end
  1004.                 elseif command == "wait" then
  1005.                         print("Waiting for more users...")
  1006.                         os.sleep(3)
  1007.                         term.clear()
  1008.                         timeline=0
  1009.                 elseif command == "list" then
  1010.                         if user1id ~= "" then
  1011.                                 print("Computer " .. user1id .. " logged in with username " .. user1 .. ".")
  1012.                         end
  1013.                         if user2id ~= "" then
  1014.                                 print("Computer " .. user2id .. " logged in with username " .. user2 .. ".")
  1015.                         end
  1016.                         if user3id ~= "" then
  1017.                                 print("Computer " .. user3id .. " logged in with username " .. user3 .. ".")
  1018.                         end
  1019.                         if user4id ~= "" then
  1020.                                 print("Computer " .. user4id .. " logged in with username " .. user4 .. ".")
  1021.                         end
  1022.                         if user5id ~= "" then
  1023.                                 print("Computer " .. user5id .. " logged in with username " .. user5 .. ".")
  1024.                         end
  1025.                 elseif command == "help list" then
  1026.                         print("Lists all the users connected to the server.")
  1027.                 elseif command == "help wait" then
  1028.                         print("Activates User-Finding Mode.")
  1029.                 elseif command == "help server" then
  1030.                         print("Returns to the main server.")
  1031.                 elseif command == "help ban" then -- Version 1.0.0
  1032.                         print("Prevents a user from connecting to the server.")
  1033.                 elseif command == "help banlist" then  -- Version 1.0.0
  1034.                         print("Lists all banned players.")
  1035.                 else
  1036.                         print("Unknown method error.")
  1037.                 end
  1038.         end
  1039.        
  1040.         server_public()
  1041.        
  1042. end
  1043.  
  1044. select_mode()