Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local users = {}
- users["anon"] = {}
- users["anon"]["pass"] = "testPass"
- users["anon"]["rank"] = "owner"
- users["danny"] = {}
- users["danny"]["pass"] = "jimmy69"
- users["danny"]["rank"] = "owner"
- users["akemi"] = {}
- users["akemi"]["pass"] = "password"
- users["akemi"]["rank"] = "admin"
- local ranks = {}
- ranks["owner"] = {}
- ranks["admin"] = {}
- ranks["mod"] = {}
- ranks["user"] = {}
- function split(pString, pPattern)
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- rednet.open("top")
- while true do
- senderID,message = rednet.receive(1000)
- if message == "userServer" then
- rednet.send(senderID,"19")
- else
- local tab = split(message," ")
- local username = tab[2]
- local pass = tab[3]
- local rank = tab[4]
- local cmd = tab[1]
- if cmd == "auth" then
- print(username)
- if users[username] then
- if users[username]["pass"] == pass then
- print("Correct Details")
- local usrRank = users[username]["rank"]
- if string.find(rank,usrRank) then
- rednet.send(senderID,"Authed")
- else
- rednet.send(senderID,"Not authed for this area")
- end
- else
- print("Incorrect Details")
- rednet.send(senderID,"Incorrect Pass")
- end
- else
- print("No User")
- rednet.send(senderID,"Unknown User")
- end
- end
- end
- print("Message: "..message)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement