This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
1vannn's profile picture

[Work in Progress] "Server Police System"

Started by 1vannn, 08 June 2013 - 02:24 PM
1vannn #1
Posted 08 June 2013 - 04:24 PM
This has been a project that I've been trying to work on for awhile, but have not had a ton of time to work on it. Anyways, this is the source code. Hopefully, by the end of this week, I'll have this finished and connecting to the MySQL database. Leave your feedback, or suggestions, and feel free to edit this yourself and post it below.


--[[
Todo List
- Fix admin login variables
- HTTP stuff
]]
-- Police -- Written by Ivan
-- Administrative
-- Variables
serverAdmin = "Ivan" -- if name doesnt exist in database, then put email here
serverURL, username = "http://cake.comoj.com/minecraft/police.php" -- You wouldn't think I'd give the real URL out?
bugURl = "http://cake.comoj.com/bugs.php"
-- functions
function clear()
term.clear()
term.setCursorPos(1,1)
end
function header()
print("Server Police v1.0")
print("---------------------------------------")
end
function reset()
clear()
header()
end
-- body
end
-- Start
clear()
textutils.slowPrint("Connecting to database")
if http == false then
clear()
print("HTTP is required.")
end
reset()
print("1.) File a new report")
print("2.) View current open reports")
print("3.) Superuser Login")
term.setCursorPos(1,18)
print("---------------------------------------")
write("Option: ")
op = read("*n")
if op == 1 then
reset()
write("Name of Accused: ")
name = read()
reset()
write("Crime: ")
crime = read()
reset()
write("Notes: ")
notes = read()
reset()
write("Staff Member: ")
staff = read()
reset()
print("Report has been filed.")
-- sending to database
sleep(1)
os.reboot()
elseif op == 2 then
-- view open cases
elseif op == 3 then
reset()
write("Username: ")
user = read()
reset()
write("Password: ")
pass = read("*")
-- send to server
if content == true then
  reset()
  print("1. Delete a case")
  print("2. Email Admin")
  print("3. Report a bug")
  print("4. Go back")
  term.setCursorPos(1,18)
  print("---------------------------------------")
  write("Option: ")
  op2 = read()
  if op2 == 1 then
   reset()
   write("Case ID to delete: ")
   id = read()
   -- send to server
   sleep(5)
   os.reboot()
  elseif op2 == 2 then
   reset()
   write("Name: ")
   name = read()
   -- Needs to be fixed.
   if name ~= "Viper" or name ~= "Ivan" or name ~= "Eric" or name ~= "Leader" or name ~= "Adam" then
    reset()
    print("User not allowed.")
    sleep(5)
    os.reboot()
   else
    -- send to server admin
    sleep(1)
    os.reboot()
   end
  elseif op2 == 3 then
  
  end
else
  reset()
  print("User not allowed.")
  sleep(5)
  os.reboot()
end
end
superaxander #2
Posted 12 June 2013 - 09:18 AM
Please use pastebin and indent your code. Also please make the usernames/passwords changeable without changing the code. Or at least put some variables at the top.