Justus

Chat between servers

Jun 16th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. local Settings = {
  2.     Host = "127.0.0.1",
  3.     Port = 2000
  4. }
  5.  
  6. local chatSocket = sockOpen(Settings.Host, Settings.Port)
  7.  
  8. addEventHandler("onSockOpened", root, function(socket)
  9.     if socket == chatSocket then
  10.         outputDebugString("Chat socket opened!")
  11.     end
  12. end)
  13.  
  14. addEventHandler("onPlayerChat", root, function(msg, msgType)
  15.     if msgType == 0 then
  16.         local data = getPlayerName(source)..": "..msg
  17.         sockWrite(chatSocket, data.."\r\n")
  18.     end
  19. end)
  20.  
  21. addEventHandler("onSockData", root, function(socket, data)
  22.     if socket == chatSocket then
  23.         outputChatBox(data)
  24.     end
  25. end)
  26.  
  27. addEventHandler("onSockClosed", root, function(socket)
  28.     if socket == chatSocket then
  29.         outputDebugString("Chat socket closed!")
  30.     end
  31. end)
Advertisement
Add Comment
Please, Sign In to add comment