CapsAdmin

chat history

Mar 9th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local index = 0
  2. local history = {}
  3.  
  4. hook.Add("OnPlayerChat", "chat_history", function(ply, text)
  5.     if ply == LocalPlayer() then
  6.         table.insert(history, text)
  7.         index = math.huge
  8.     end
  9. end)
  10.  
  11. hook.Add("OnChatTab", "chat_history", function()
  12.     if input.IsKeyDown(KEY_UP) then
  13.         index = math.Clamp(index - 1, 0, #history)
  14.         return history[index]
  15.     elseif input.IsKeyDown(KEY_DOWN) then
  16.         index = math.Clamp(index + 1, 0, #history)
  17.         return history[index]
  18.     end
  19. end)
  20.  
  21. --[[
  22. hold up or down and press tab to browse your chat history. I know it's ass needing to press tab to do this, but it's the only way pretty much without using a module
  23. ]]
Advertisement
Add Comment
Please, Sign In to add comment