Advertisement
wadsonlucas

Untitled

Dec 13th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. local ESX = nil
  2. -- ESX
  3. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  4.  
  5. -- Open ID card
  6. RegisterServerEvent('jsfour-idcard:open')
  7. AddEventHandler('jsfour-idcard:open', function(ID, targetID, type)
  8. local identifier = ESX.GetPlayerFromId(ID).identifier
  9. local _source = ESX.GetPlayerFromId(targetID).source
  10. local show = false
  11.  
  12. MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height, lastdigits FROM users WHERE identifier = @identifier', {['@identifier'] = identifier},
  13. function (result)
  14. if (result[1] ~= nil) then
  15. playerData = {firstname = result[1].firstname, lastname = result[1].lastname, dateofbirth = result[1].dateofbirth, sex = result[1].sex, height = result[1].height, lastdigits = result[1].lastdigits}
  16. TriggerClientEvent('jsfour-idcard:open', _source, playerData)
  17. end
  18. MySQL.Async.fetchAll('SELECT type FROM user_licenses WHERE owner = @identifier', {['@identifier'] = identifier},
  19. function (licenses)
  20. if type ~= nil then
  21. for i=1, #licenses, 1 do
  22. if type == 'driver' then
  23. if licenses[i].type == 'drive' or licenses[i].type == 'drive_bike' or licenses[i].type == 'drive_truck' then
  24. show = true
  25. end
  26. elseif type =='weapon' then
  27. if licenses[i].type == 'weapon' then
  28. show = true
  29. end
  30. end
  31. end
  32. else
  33. show = true
  34. end
  35.  
  36. if show then
  37. local array = {
  38. user = user,
  39. licenses = licenses
  40. }
  41. TriggerClientEvent('jsfour-idcard:open', _source, array, type)
  42. else
  43. TriggerClientEvent('esx:showNotification', _source, "You don't have that type of license..")
  44. end
  45. end)
  46. end
  47. end)
  48. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement