Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Simple net library usage example
- if SERVER then
- util.AddNetworkString( "NetLibrary ChatExample" ) -- This is required server-side for every net message you use
- local function SendMessage( str, ply )
- net.Start("NetLibrary ChatExample") -- Should match the AddNetworkString name
- net.WriteString( str )
- net.Send( ply ) -- This sends to a specific player. You can also use net.Broadcast() to send to everyone, or net.SendToServer() clientside to send to the server
- end
- end
- if CLIENT then
- local Col = {
- Tag = Color(100,255,0), Text = Color(255,255,255),
- }
- Col.Tag.Glow = true -- Make the tag glow. Glow will be ignored by default chatbox
- Col.Tag.GlowTarget = Color(100,0,255) -- Color it glows to (Optional, defaults to white)
- local Icon = "icon16/controller.png"
- local Emote = "icon16/star.png"
- net.Receive( "NetLibrary ChatExample", function(len) -- Again, should match other strings. function arguments are MessageLength, SendingPlayer (nil clientside)
- local str = net.ReadString() -- Data should be read in the same order it was written
- if not str or str=="" then return end
- chat.AddText(
- HatsChat and {"LINEICON", Icon} or "", -- Badly coded custom chatboxes may error with a non-colour table, Default chatbox will just ignore it. This line only adds the table if HatsChat is installed
- Col.Tag, "[MyAddon] ", -- Glowing colour with tag
- HatsChat and {"EMOTE", mat=Material(Emote), str=":star:", size={16,16}, matpath=Emote} or "", -- Same again, this time with an emote
- Col.Text, str -- Standard arguments
- )
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement