--[[
	MOD/lua/clua.lua [#984 (#1022), 1359846175]
	Ollie | STEAM_0:0:30709335 <85.23.158.207:27006> | [26.01.14 12:41:56PM]
	===BadFile===
]]

if SERVER then

	util.AddNetworkString("RunLuaString")
	util.AddNetworkString("RunLuaFailed")

	hook.Add("PlayerSay","CheckLC",function(ply,text)
		if text:sub(1,3) == "!lc" and (ply:IsSuperAdmin()or ply:IsAdmin()) then
			net.Start("RunLuaString")
				net.WriteString(text:sub(4,text:len()))
			net.Send(player.GetAll())
		end
	end)

	net.Receive("RunLuaFailed",function()
		local err = net.ReadString()
		net.Start("RunLuaString")
			net.WriteString("chat.AddText(Color(250,50,50),\"CLua:"..err.."\")")
		net.Send(player.GetAll())
	end)
		
else

    net.Receive("RunLuaString",function()
    
		this = LocalPlayer():GetEyeTraceNoCursor().Entity
		there = LocalPlayer():GetEyeTraceNoCursor().HitPos
	
        local code = net.ReadString()
        local status, err = pcall(CompileString(code,"FriendBuild",false))
        if status == false then
            net.Start("RunLuaFailed")
                net.WriteString(err)
            net.SendToServer()
        end
    
    end)

end
