This repository was archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathserver.lua
More file actions
45 lines (42 loc) · 1.39 KB
/
Copy pathserver.lua
File metadata and controls
45 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local ESX = nil
-- ESX
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
-- Open ID card
RegisterServerEvent('jsfour-idcard:open')
AddEventHandler('jsfour-idcard:open', function(ID, targetID, type)
local identifier = ESX.GetPlayerFromId(ID).identifier
local _source = ESX.GetPlayerFromId(targetID).source
local show = false
MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', {['@identifier'] = identifier},
function (user)
if (user[1] ~= nil) then
MySQL.Async.fetchAll('SELECT type FROM user_licenses WHERE owner = @identifier', {['@identifier'] = identifier},
function (licenses)
if type ~= nil then
for i=1, #licenses, 1 do
if type == 'driver' then
if licenses[i].type == 'drive' or licenses[i].type == 'drive_bike' or licenses[i].type == 'drive_truck' then
show = true
end
elseif type =='weapon' then
if licenses[i].type == 'weapon' then
show = true
end
end
end
else
show = true
end
if show then
local array = {
user = user,
licenses = licenses
}
TriggerClientEvent('jsfour-idcard:open', _source, array, type)
else
TriggerClientEvent('esx:showNotification', _source, "You don't have that type of license..")
end
end)
end
end)
end)