Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cmdb=peripheral.wrap("left")
- local advp=peripheral.wrap("right")
- local set=infutil.readPrefs("_cps") or {
- greeting="Hello $p!",
- }
- local player={}
- local jet={}
- setmetatable(player,{
- __index=function(s,n)
- return advp.getPlayerByName(n)
- end
- })
- local function prt(txt,plr)
- if plr then
- cmdb.setCommand("/tell "..plr.." "..tostring(txt))
- else
- cmdb.setCommand("/say "..tostring(txt))
- end
- cmdb.runCommand()
- end
- snet.open()
- while true do
- local p={os.pullEvent()}
- if p[1]=="chat_message" then
- local tW = {}
- for match in string.gmatch(p[3],"[^ \t]+") do
- table.insert(tW,match)
- end
- setmetatable(tW,{__index=function() return "" end})
- if tW[1]=="!rs" then
- local state
- if tW[3]=="1" or string.lower(tW[3])=="true" or string.lower(tW[3])=="on" then
- state=true
- elseif tW[3]=="0" or string.lower(tW[3])=="false" or string.lower(tW[3])=="off" then
- state=false
- end
- local s,err=pcall(rs.setOutput,tW[2],state)
- if not s then
- prt((err or "Unknown error"),p[2])
- end
- elseif tW[1]=="ping" then
- prt("pong")
- elseif tW[1]=="!reload" then
- prt("Reloading...")
- sleep(1)
- os.reboot()
- elseif tW[1]=="!set" then
- if tW[2]=="greeting" then
- local st={}
- for k,v in pairs(tW) do
- if k>2 then
- table.insert(st,v)
- end
- end
- set.greeting=table.concat(st," ")
- prt("Greeting set!")
- else
- prt("No such var.")
- end
- infutil.savePrefs("_cps",set)
- elseif tW[1]=="!heal" then
- local pl
- if tW[2]=="" then
- pl=p[2]
- else
- pl=tW[2]
- end
- pl=player[pl]
- if not pcall(pl.getHealth) then
- prt("Error healing player.")
- else
- pl.heal(20)
- end
- elseif tW[1]=="!play" then
- local pl
- local snd
- if tW[3]=="" then
- snd=2
- pl=player[p[2]]
- else
- snd=3
- pl=player[tW[2]]
- end
- snd=table.concat({unpack(tW,snd)}," ")
- if not pcall(pl.getHealth) then
- prt("Error locating "..tW[2])
- else
- local x,y,z=pl.asEntity().getPosition()
- local err,dat=pcall(advp.getWorld(pl.asEntity().getWorldID()).playSound,snd,x,y,z,1,1)
- if not err then
- prt((dat or "Unknown error"),p[2])
- end
- end
- elseif tW[1]=="!calc" then
- prt(({pcall(setfenv(loadstring("return "..table.concat({unpack(tW,2)}," ")),math))})[2],p[2])
- elseif tW[1]=="!explode" then
- local pl
- if tW[2]=="" then
- pl=player[p[2]]
- else
- pl=player[tW[2]]
- end
- if not pcall(pl.getHealth) then
- prt("Error exploding "..tW[2])
- else
- local x,y,z=pl.asEntity().getPosition()
- advp.getWorld(pl.asEntity().getWorldID()).explode(x,y,z,4,false,false)
- pl.damage(20)
- end
- elseif tW[1]=="!disk" then
- snet.open()
- local st={}
- for k,v in pairs(tW) do
- if k>2 then
- table.insert(st,v)
- end
- end
- st=table.concat(st," ")
- local err,dat
- if tW[2]=="play" then
- err,dat=pcall(rednet.broadcast,infutil.compress("diskplay",st))
- elseif tW[2]=="stop" then
- err,dat=pcall(rednet.broadcast,infutil.compress("diskstop"))
- end
- if not err then
- prt((dat or "Unknown error"),p[2])
- end
- elseif tW[1]=="!jet" then
- prt("GTFO MANDRAKE")
- --[[if tW[2]=="" or tW[3]=="" or (tonumber(tW[4])==nil and tW[4]~="") then
- prt("Usage: !jet <player> <distance> [deley]")
- end
- for l1=1,tonumber(tW[3]) do
- os.queueEvent("chat_message",p[2],"!explode "..tW[2])
- if tW[4]~="" then
- sleep(tonumber(tW[4]))
- end
- end]]
- end
- elseif p[1]=="player_login" then
- prt(({string.gsub(set.greeting,"$p",p[2])})[1])
- elseif p[1]=="rednet_message" then
- os.queueEvent("chat_message",p[2],p[3])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement