Basically what I have been trying to do is make text chat similar to dark rp. What i mean by that is when you type, only people in a radius will recieve it. I did make network functions for sending players messages. I just dont know how to put it all together.
Thanks in advance.
Client:
[lua]
net.Start("PlayerChat")
net.WriteString(str)
net.SendToServer()
[/lua]
Server:
[lua]net.Receive("PlayerChat", function(len, ply)
if not ply:Alive() then return end
local str = net.ReadString()
local cmd, arg = str:match("^([/!]%S+)%s*(.-)$")
if cmd then
-- handle chat commands or something
return
end
local rec = {}
for k, v in pairs(ents.FindInSphere(ply:GetPos(), 256)) do
if v:IsPlayer() then
rec[#rec + 1] = v
end
end
net.Start("nChat")
net.WriteEntity(ply)
net.WriteString(str)
net.Send(rec)
end)
[/lua]
Client:
[lua]
net.Receive("PlayerChat", function(len)
local ply = net.ReadEntity()
local str = net.ReadString()
chat.AddText(team.GetColor(ply:Team()), ply:Nick(), Color(255, 255, 255), ": " .. str)
end)
[/lua]
I cant tell, but will this remove a player from the table if hes not in the sphere?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] is already returning just the entities in a sphere around him.
Oh Okay
It does not work.
For one its a stupid way to do it, that's probably half the problem. Below is the best way.
[url]http://wiki.garrysmod.com/page/GM/PlayerCanSeePlayersChat[/url]
Sorry, you need to Log In to post a reply to this thread.