Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 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 FROM users WHERE identifier = @identifier', {['@identifier'] = identifier},
  13.     function (user)
  14.         if (user[1] ~= nil) then
  15.             MySQL.Async.fetchAll('SELECT type FROM user_licenses WHERE owner = @identifier', {['@identifier'] = identifier},
  16.             function (licenses)
  17.             print(table.unpack(licenses))
  18.                 if type ~= nil then
  19.                     for i=1, #licenses, 1 do
  20.                         if type == 'driver' then
  21.                             if licenses[i].type == 'drive' or licenses[i].type == 'drive_bike' or licenses[i].type == 'drive_truck' then
  22.                                 print("driver license found")
  23.                                 show = true
  24.                             end
  25.                         elseif type =='weapon' then
  26.                             if licenses[i].type == 'weapon' then
  27.                                 print("weapon license found")
  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