OK, here is the whole, full, client software.
Spoiler
-- CLIENT SOFTWARE
relayID=0
--clear screen function (lazyness)
function clear()
term.clear()
term.setCursorPos(1,1)
end
--fortress user menu
function Fortress()
while true do
clear()
print ("Logged on as: Fortress")
print ("Enter A Number To Perform The Action")
print ("Type 'exit' to log out")
print ("")
print ("1. Toggle Waterfall")
print ("2. Toggle Waterfall Lights")
print ("3. Basement Door")
print ("4. TNT Store Room Door")
print ("5. Back Corridor")
print ("")
write ("Option: ")
option = read ()
if option == "back" then
login()
end
if option == "1" then
rednet.send(relayID, "toggle_waterfall")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Waterfall Is " .. responce)
end
sleep(2)
elseif option == "2" then
rednet.send(relayID, "toggle_waterfall_lights")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Waterfall Lights Are " .. responce)
end
sleep(2)
elseif option == "3" then
rednet.send(relayID, "basement_door")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Basement Door Is " .. responce)
end
sleep(2)
elseif option == "4" then
rednet.send(relayID, "TNT_store")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("TNT Room Door Is " .. responce)
end
sleep(2)
elseif option == "5" then
rednet.send(relayID, "admin_area")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Back Corridor " .. responce)
end
sleep(2)
end
end
end
--factory user menu
function Factory()
while true do
clear()
print ("Logged on as: Factory")
print ("Enter A Number To Perform The Action")
print ("Type 'exit' to log out")
print ("")
print ("1. Power Plant Engines")
print ("2. Quarry")
print ("3. Refinary")
print ("4. Oil Pumps")
print ("5. Water Pumps")
print ("")
write ("Option: ")
option = read ()
if option == "exit" then
login()
end
if option == "1" then
rednet.send(relayID, "power_plant_engines")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Power Plant Engines Are " .. responce)
end
sleep(2)
elseif option == "2" then
rednet.send(relayID, "quarry")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Quarry Is " .. responce)
end
sleep(2)
elseif option == "3" then
rednet.send(relayID, "refinary")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Refinary Is " .. responce)
end
sleep(2)
elseif option == "4" then
rednet.send(relayID, "oil_pump")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Oil Pumps are " .. responce)
end
sleep(2)
elseif option == "5" then
rednet.send(relayID, "water_pump")
local senderID, responce = rednet.receive(2)
sleep(0.2)
clear()
if responce == nil then
print("Server Sent No Responce!")
print("Perhaps it's busy?")
else
print("Water Pumps are " .. responce)
end
sleep(2)
end
end
end
--arena user menu
function Arena()
clear()
print ("NOT AVALABLE")
sleep(2)
os.reboot()
end
--banking user menu
function Bank()
clear()
print ("NOT AVALABLE")
sleep(2)
os.reboot()
end
--main menu for admins
function AdminMenu()
while true do
clear()
print ("Logged on as: Admin")
print ("Enter A Number To Perform The Action")
print ("Type exit to log off")
print ("")
print ("1. Fortress")
print ("2. Factory")
print ("3. Arena")
print ("4. Bank")
print ("")
write ("Option: ")
option = read ()
if option == "exit" then
print ("Logging Off.")
sleep(2)
os.shutdown()
end
if option == "1" then
Fortress()
elseif option == "2" then
Factory()
elseif option == "3" then
Arena()
elseif option == "4" then
Bank()
end --end if
end --end while loop
end
--Login function
function login()
--check if the server is avalable
while true do
clear()
sp = textutils.slowPrint
sp("Connecting To Mainframe...")
rednet.broadcast("relay") --check if relay server is on
relayid, responce = rednet.receive(2) --wait for responce from server
sleep(2)
if responce == nil then --if the variable "responce" is "nil"
term.setCursorPos(27,1)
sp("Connection Failed.") --append to the end of "connecting to mainframe..."
sp("Error 1: Failed To Connect To A Local Relay Server")
sp("Try again later or notify the admin: JamiePhonic")
print("")
sleep(1)
sp("Shutting Down: 5") --Print "shutting down: 5"
sleep(1) --sleep for a second
term.setCursorPos(1,4) --set cursor pos to line 4, character 1
print("Shutting Down: 4") --repeat, subrtacting 1 from the timer each time
sleep(1)
term.setCursorPos(1,4)
print("Shutting Down: 3")
sleep(1)
term.setCursorPos(1,4)
print("Shutting Down: 2")
sleep(1)
term.setCursorPos(1,4)
print("Shutting Down: 1")
sleep(1)
os.shutdown() --shut the system down
else --if the variable "responce" is not nil,
term.setCursorPos(27,1)
sp("Connected!") --append to the end of "connecting to mainframe..."
print("")
sleep(2)
end --end if
--request/validate Password
tries = 5 --set the number of tries
write ("password: ")
for triescnt = 1,tries,1 do
password = read ()
rednet.send(relayID, "CheckPass")
local senderID, confirm = rednet.receive(2)
sleep(0.2)
if confirm == nil then
print("Server Failed To Reply")
else
rednet.send(relayID, password)
local senderID, responce = rednet.receive(2)
if responce == ("admin") then --if responce = admin
print("")
print("Welcome Admin!")
sleep(2)
AdminMenu()
break
elseif responce == ("fortress") then --if responce = user
print("")
print("Welcome to the Fortress!")
sleep(2)
Fortress()
break
elseif responce == ("factory") then --if responce = user
print("")
print("Welcome to the factory!")
sleep(2)
Factory()
break
elseif responce == ("arena") then --if responce = user
print("")
print("Welcome to the arena!")
sleep(2)
Arena()
break
elseif responce == ("bank") then --if responce = user
print("")
print("Welcome to the bank!")
sleep(2)
Bank()
break
else --otherwise
term.setCursorPos(1,3)
print ("Access Denied! Server responded with: ",responce)
print ("you have ",tries-triescnt," Tries left")
print ("")
term.clearLine(5)
write ("password: ")
end --end function call
if triescnt == tries then --if tries=triescnt
print ("Access Denied!") --display denied message
sleep(1)
os.shutdown() --shutdown the system
end --end password tries loop
end --end responce check if
end --end for loop
end --end while
end --end function
--Program Starts! detect if a modem is attached, if it is, enable it
if peripheral.getType("top") == "modem" then
rednet.open("top")
login()
elseif peripheral.getType("back") == "modem" then
rednet.open("back")
login()
elseif peripheral.getType("left") == "modem" then
rednet.open("left")
login()
elseif peripheral.getType("right") == "modem" then
rednet.open("right")
login()
elseif peripheral.getType("bottom") == "modem" then
rednet.open("bottom")
login()
else
sp = textutils.slowPrint
clear()
print("Please Connect A Modem And Try Again.")
print("")
sleep(1)
sp("Shutting Down: 5") --Print "shutting down: 5"
sleep(1) --sleep for half a second
term.setCursorPos(1,3) --set cursor pos to line 4, character 1
print("Shutting Down: 4") --repeat, subrtacting 1 from the timer each time
sleep(1)
term.setCursorPos(1,3)
print("Shutting Down: 3")
sleep(1)
term.setCursorPos(1,3)
print("Shutting Down: 2")
sleep(1)
term.setCursorPos(1,3)
print("Shutting Down: 1")
sleep(1)
os.shutdown() --shut the system down
end
i would appreciate it if you at least looked at it before you replied, i know its a mess and its not the cleanest code, but for a server that rarely sees 5 players and is rebooted (the whole machine) almost every night, it does the job.