Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local avp=peripheral.wrap("right")
- local cmd=peripheral.wrap("left")
- if not fs.isDir("commandsList") then fs.delete("commandsList") fs.makeDir("commandsList") end
- local opList={MudkipTheEpic=true}
- local function checkExists(command)
- return (fs.exists("CommandsList/"..command) and not fs.isDir("CommandsList/"..command) and (string.sub(fs.combine("CommandsList/", command),1,13)=="CommandsList/" or fs.combine("",command)==("" or "/")))
- end
- local function tellPlayer(player,text)
- cmd.setCommand("tell "..player.." "..text)
- return cmd.runCommand()
- end
- while true do
- local _,username,chatmessage=os.pullEvent("chat_message")--or raw
- print(username.." said \""..chatmessage.."\".")
- local command=nil
- local commandList={}
- string.gsub(chatmessage,"([^%s]+)",function(a) if not command then command=a else table.insert(commandList,a) end end)
- if opList[username] and checkExists(command) then
- pcall(function() shell.run("CommandsList/"..command,username,unpack(commandList)) end)
- elseif not opList[username] and checkExists(command) then
- tellPlayer(username,"You are not permitted to use this command.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment