Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function fwrite(n, c)
- local f = fs.open(n, "w")
- f.write(c)
- f.close()
- end
- local function fread(n)
- local f = fs.open(n, "r")
- local out = f.readAll()
- f.close()
- return out
- end
- local file = "gccs"
- local optins = textutils.unserialise(fread(file))
- local function save()
- fwrite(file, textutils.serialise(optins))
- end
- local chatbox = peripheral.find "chat_box"
- while true do
- local _, sender, type, arguments = os.pullEvent "command"
- if type == "gccs-optin" then
- optins[sender] = true
- save()
- elseif type == "gccs-optout" then
- optins[sender] = nil
- save()
- end
- local text = sender .. ": \\" .. type .. " " .. table.concat(arguments, " ")
- for user in pairs(optins) do
- chatbox.tell(user, text, "\167bG\167aCCS\1677", "\1678")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement