Advertisement
Guest User

OFFICER246's "chat_client.lua"

a guest
Sep 7th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. local chatInputActive = false
  2. local chatInputActivating = false
  3.  
  4. RegisterNetEvent('chatMessage')
  5.  
  6. AddEventHandler('chatMessage', function(name, color, message)
  7. SendNUIMessage({
  8. name = name,
  9. color = color,
  10. message = message
  11. })
  12. end)
  13.  
  14. RegisterNUICallback('chatResult', function(data, cb)
  15. chatInputActive = false
  16.  
  17. SetNuiFocus(false)
  18.  
  19. if data.message then
  20. local id = PlayerId()
  21.  
  22. --local r, g, b = GetPlayerRgbColour(id, _i, _i, _i)
  23. local r, g, b = 0, 0x99, 255
  24.  
  25. TriggerServerEvent('chatMessageEntered', GetPlayerName(id), { r, g, b }, data.message)
  26. end
  27.  
  28. cb('ok')
  29. end)
  30.  
  31. Citizen.CreateThread(function()
  32. SetTextChatEnabled(false)
  33.  
  34. while true do
  35. Wait(0)
  36.  
  37. if not chatInputActive then
  38. if IsControlPressed(0, 245) --[[ INPUT_MP_TEXT_CHAT_ALL ]] then
  39. chatInputActive = true
  40. chatInputActivating = true
  41.  
  42. SendNUIMessage({
  43. meta = 'openChatBox'
  44. })
  45. end
  46. end
  47.  
  48. if chatInputActivating then
  49. if not IsControlPressed(0, 245) then
  50. SetNuiFocus(true)
  51.  
  52. chatInputActivating = false
  53. end
  54. end
  55. end
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement