Something like this:
-- SERVER
util.AddNetworkString("my_custom_netstring")
concommand.Add("removeentity", function(ply)
pickupdrone(ply)
end)
droneinbackpack = 0
local function chatAddText(ply, tbl)
net.Start("my_custom_netstring")
net.WriteUInt(#tbl, 32)
local color = color_white
for index, data in ipairs(tbl) do
net.WriteString(data.text)
if (IsColor(data.color)) then
color = data.color
end
net.WriteColor(color)
end
net.Send(ply)
end
function pickupdrone(ply)
print( ply:GetEyeTrace().Entity.PrintName )
if ply:GetEyeTrace().Entity.PrintName == "Camera Drone" then
if droneinbackpack == 0 then
chatAddText(ply, {
{text = "Picked ", color = Color(255, 0, 0)},
{text = "up ", color = Color(0, 255, 0)},
{text = "drone", color = Color(0, 0, 255)}
})
drone = ply:GetEyeTrace().Entity
if ( SERVER ) then
drone:Remvoe()
end
end
if droneinbackpack == 1 then
print("Unpacking drone")
chatAddText(ply, {
{text = "Unpacking ", color = Color(255, 255, 0)},
{text = "drone", color = Color(0, 255, 255)}
})
end
end
end
-- CLIENT
net.Receive("my_custom_netstring", function(l)
local num = net.ReadUInt(32)
local tbl = {}
for i = 1, num do
local text = net.ReadString()
local color = net.ReadColor()
table.insert(tbl, color)
table.insert(tbl, text)
end
chat.AddText(unpack(tbl))
end)