Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. ESX = nil
  2.  
  3. RegisterNetEvent('esx:playerLoaded')
  4. AddEventHandler('esx:playerLoaded', function(xPlayer)
  5. PlayerData = xPlayer
  6. end)
  7.  
  8. AddEventHandler('chatMessage', function(source, name, msg)
  9. local command = stringsplit(msg, " ")[1];
  10.  
  11. if command == "/ooc" then
  12. CancelEvent()
  13. if Config.EnableESXIdentity then name = GetCharacterName(source) end
  14. TriggerClientEvent('chatMessage', -1, _U('ooc_prefix', name), { 128, 128, 128 }, string.sub(msg, 5))
  15. elseif command == "/twt" then
  16. CancelEvent()
  17. if Config.EnableESXIdentity then name = GetCharacterName(source) end
  18. TriggerClientEvent('chatMessage', -1, _U('twt_prefix', name), { 0, 153, 204 }, string.sub(msg, 5))
  19. elseif command == "/me" then
  20. CancelEvent()
  21. if Config.EnableESXIdentity then name = GetCharacterName(source) end
  22. TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), string.sub(msg, 4), { 255, 0, 0 })
  23. elseif command == "/news" then
  24. CancelEvent()
  25. if Config.EnableESXIdentity then name = GetCharacterName(source) end
  26. TriggerClientEvent('chatMessage', -1, _U('news_prefix', name), { 249, 166, 0 }, string.sub(msg, 6))
  27. elseif string.sub(command, 1, 1) == "/" then
  28. CancelEvent()
  29. TriggerClientEvent('chatMessage', source, '', {132, 13, 37}, _U('ooc_unknown_command', command))
  30. end
  31. end)
  32.  
  33. function stringsplit(inputstr, sep)
  34. if sep == nil then
  35. sep = "%s"
  36. end
  37. local t={} ; i=1
  38. for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  39. t[i] = str
  40. i = i + 1
  41. end
  42. return t
  43. end
  44.  
  45. function GetCharacterName(source)
  46. -- fetch identity in sync
  47. local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  48. {
  49. ['@identifier'] = GetPlayerIdentifiers(source)[1]
  50. })
  51.  
  52. if result[1] ~= nil and result[1].firstname ~= nil and result[1].lastname ~= nil then
  53. if Config.OnlyFirstname then
  54. return result[1].firstname
  55. else
  56. return result[1].firstname .. ' ' .. result[1].lastname
  57. end
  58. else
  59. return GetPlayerName(source)
  60. end
  61. end
  62.  
  63. TriggerEvent('es:addCommand', 'facebook', function(source, args, user)
  64. table.remove(args, 1)
  65. local name = getIdentity(source)
  66. TriggerClientEvent('esx:showAdvancedNotification', -1, name.firstname .. ' ' .. name.lastname, table.concat(args, " "), msg, 'CHAR_FACEBOOK', 1)
  67. local cash = xPlayer.getMoney()
  68. if cash >= 500 then
  69. xPlayer.removeMoney(500)
  70. sendNotification(source, 'You just posted something for 500$', 'success', 3500)
  71. else
  72. sendNotification(source, 'You do not have enough cash. you have: ' .. cash ..'$, needed ' .. 500 - cash)
  73. end
  74. end, {help = 'Post a facebook post, 500$'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement