Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- require("json")
- require("oosocks")
- local socket = OOSock(IPPROTO_UDP)
- local receiving = false
- socket:SetCallback(function(self, type, id, error, data, address, port)
- if type == SCKCALL_SEND and error == SCKERR_OK and not receiving then
- receiving = true
- socket:ReceiveDatagram()
- print("Sent first chat message")
- elseif type == SCKCALL_REC_DATAGRAM then
- if error == SCKERR_OK then
- hook.Call("RemotePlayerSay", nil, Json.Decode(data))
- self:ReceiveDatagram()
- else
- Error("ERROR")
- end
- end
- end)
- hook.Add("PlayerSay", "chat", function(player, text)
- socket:Send(Json.Encode({nick = player:Nick(), text = text}), "morten.im", 8080)
- end)
- hook.Add("RemotePlayerSay", "blah", function(data)
- umsg.Start("RemotePlayerSay")
- umsg.String(glon.encode(data)) -- :s
- umsg.End()
- end)
- end
- if CLIENT then
- usermessage.Hook("RemotePlayerSay", function(umr)
- local data = glon.decode(umr:ReadString())
- chat.AddText("[", data.server.id, "] ", Color(100,100,100), data.nick, ,": " data.text)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment