-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
40 lines (40 loc) · 1.19 KB
/
server.lua
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
-- Open ID card
RegisterServerEvent('jsfour-idcard:open')
AddEventHandler('jsfour-idcard:open', function(targetID, type, playerData)
local _source = source
local identifier = playerData.identifier
local playerInfo = playerData.playerInfo
local show = false
if (playerInfo ~= 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 = {playerInfo},
licenses = licenses
}
TriggerClientEvent('jsfour-idcard:open', targetID, array, type)
else --for debug only, should never go into this
TriggerClientEvent('ox_lib:notify', _source, {
type = 'error',
description = "You don't have that type of license.."
})
end
end)
end
end)