Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local id = os.getComputerID()
- function openRednet()
- local listOfSides = rs.getSides()
- listofPossibles = {}
- local counter1 = 0
- while true do
- counter1 = counter1+1
- if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
- table.insert(listofPossibles,tostring(listOfSides[counter1]))
- end
- if counter1 == 6 and table.maxn(listofPossibles) == 0 then
- return nil
- end
- if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
- rednet.open(listofPossibles[1])
- return listofPossibles[1]
- end
- end
- end
- openRednet()
- if fs.exists('clients') == false then
- fs.makeDir('clients')
- else
- end
- while true do
- cID,cName = rednet.receive()
- sleep(0.5)
- if fs.exists('clients/'..cID)then
- print('Client already installed')
- rednet.send(cID, 'done')
- else
- local file = fs.open('clients/'..cID,'w')
- file.write(cName)
- file.close()
- local file = fs.open('clients/cids','w')
- file.close()
- local file = fs.open('clients/cids','r')
- local data = file.readAll()
- file.close()
- data = textutils.unserialize(data)
- if data ~= nil then
- dataLength = #data + 1
- else
- dataLength = 1
- end
- data[dataLength] = cID
- local file = fs.open('clients/cids','w')
- file.write(textutils.serialize(data))
- print('Client Install Successful')
- rednet.send(cID, 'done')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment