-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fe4eb6
commit f796dc6
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
server-data/resources/[bpt_addons]/bpt_idcard/server/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- Open ID card | ||
ESX = exports["es_extended"]:getSharedObject() | ||
|
||
RegisterServerEvent("bpt_idcard:open") | ||
AddEventHandler("bpt_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("bpt_idcard:open", _source, array, type) | ||
else | ||
TriggerClientEvent("esx:showNotification", _source, TranslateCap("no_license_type")) | ||
end | ||
end) | ||
end | ||
end) | ||
end) |