Advertisement
Codeblocks

Untitled

Jul 30th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. --Client
  2. netmsg.Listen("TestMsg", function()
  3.     local whatever = netmsg.ReadString()
  4.     local s = netmsg.ReadShort()
  5.     local l = netmsg.ReadLong()
  6.     System:Print(("RECEIVED TESTMSG WOOO! String: %s | Short: %d | Long: %d"):format(whatever, s, l))
  7.     local fl = netmsg.ReadFloat()
  8.     System:Print(string.format("Float: %f", fl))
  9.     local v3 = netmsg.ReadVec3()
  10.     System:Print(string.format("Vec3: %f | %f | %f", v3.x, v3.y, v3.z))
  11. end)
  12.  
  13. --Server
  14. netmsg.Register("TestMsg") --Works if you forget this, but at a very minor performance penalty because it has to add to the masg name-to-short stack.
  15. concommand.Register("testmsg", function()
  16.     netmsg.Start("TestMsg")
  17.         netmsg.WriteString("Hi")
  18.         netmsg.WriteShort(-23)
  19.         netmsg.WriteLong(12344321)
  20.         netmsg.WriteFloat(32.7)
  21.         netmsg.WriteVec3(Vec3(1.2, 3.4, 5.6))
  22.     netmsg.Broadcast()
  23. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement