Python1320

Python1320

Dec 12th, 2010
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.83 KB | None | 0 0
  1. if SERVER then
  2.     AddCSLuaFile("autorun/joinreplace.lua")
  3.     return
  4. end
  5.  
  6. local tagcol=Color(100,100,100)
  7. local teamcol=Color(80,151,199)
  8. local white=Color(255,255,255)
  9. local green=Color(0,255,0)
  10. local red=Color(255,0,0)
  11. local gray=Color(200,200,255)
  12.  
  13. local joinmsgs=
  14. [[is joining
  15. is joining the game
  16. joining
  17. joining the game
  18. wants to play
  19. is about to enter the server
  20. is about to come to lag you
  21. is spawning
  22. clicked connect
  23. will soon be here
  24. will be spawning soon
  25. is coming
  26. would like to play
  27. would like to join
  28. is joining
  29. is connecting
  30. is connecting here
  31. is loading
  32. connected and is now loading
  33. initated a session with the server
  34. is sending UDP packets
  35. has been detected on the perimeter
  36. has an urge to join the server
  37. joining the server
  38. is joining the server
  39. sending some packets to the server
  40. is soon ingame
  41. is soon ingame, hopefully]]
  42. joinmsgs = string.Explode("\n",joinmsgs)
  43.  
  44. local discmsg=[[Found other things to do
  45. Left the server
  46. Got bored
  47. going to the bed
  48. Just left
  49. bbl
  50. disconnected
  51. parted the channel
  52. left the game
  53. BBL!
  54. Cut the wire
  55. removing gmod
  56. ragequit
  57. quit
  58. leaving
  59. My presence is not required here
  60. I can't take this anymore
  61. I'm leaving
  62. I'm packing my bags
  63. Hit the wrong button
  64. What does this button do?
  65. Oops
  66. Hit the red button
  67. EOF
  68. EndOfTransmission]]
  69. discmsg = string.Explode("\n",discmsg)
  70.  
  71. hook.Add('ChatText','JoinDisconnectReplace', function ( UserID, Name, msg, msgtype )
  72.    
  73.     if (msgtype!='joinleave') then return end
  74.    
  75.     local join=string.gmatch(tostring(msg) or "", "Player (.+) has joined the game")()
  76.     if join then
  77.    
  78.         chat.AddText(green," ● ",team.GetColor(100) or teamcol,join,white," ",table.Random(joinmsgs))
  79.    
  80.         return true
  81.    
  82.     end
  83.    
  84.     local leave
  85.     local leavemsg
  86.     for _Name,_leavemsg in string.gmatch(tostring(msg) or "", "Player (.+) left the game %((.+)%)") do
  87.         leave=_Name
  88.         leavemsg=_leavemsg      
  89.    end
  90.    
  91.     if leave then
  92.    
  93.         leavemsg=leavemsg or ""
  94.         if string.find(leavemsg,"time",1,true) then
  95.             leavemsg="Crashed!"
  96.         end
  97.        
  98.         if string.find(leavemsg,"Steam logon",1,true) then
  99.             leavemsg="Blame steam!"
  100.         end
  101.  
  102.         if string.find(leavemsg,"ERROR! Reliable snaphsot overflow.",1,true) then
  103.             leavemsg="DISCONNECTED DUE TO TOO MUCH SPAM.\n=== GLOBAL WARNING: SERVER IS OVERFLOWING. PLEASE CLEAN UP YOUR PROPS TO PREVENT FULL CRASH ==="
  104.         end
  105.         if string.find(leavemsg,"Connection closing",1,true) then
  106.             leavemsg="Reconnecting..."
  107.         end    
  108.         leavemsg=string.gsub(leavemsg,"Kicked by Console : ","")
  109.         leavemsg=string.gsub(leavemsg,"Disconnect by user%.",table.Random(discmsg))
  110.        
  111.  
  112.        
  113.  
  114.    
  115.         chat.AddText(red," ● ",team.GetColor(100) or teamcol,leave,white," left: ",gray,tostring(leavemsg))
  116.        
  117.         return true
  118.        
  119.     end
  120.    
  121.     MsgN("Unhandled join/disconnect message, dying: "..tostring(msg))
  122.    
  123.     hook.Remove('ChatText','JoinDisconnectReplace')
  124.    
  125. end)
Advertisement
Add Comment
Please, Sign In to add comment