Skip to content

Commit

Permalink
Merge pull request #703 from bitpredator/dev
Browse files Browse the repository at this point in the history
conversion: Initial work on converting jsfour-idcard to bpt_idcard
  • Loading branch information
bitpredator authored May 18, 2024
2 parents 027d8bb + a2a2cb7 commit 2344885
Show file tree
Hide file tree
Showing 35 changed files with 13,284 additions and 12,596 deletions.
674 changes: 674 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_idcard/LICENSE

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_idcard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<h1 align='center'>bpt_idcard</a></h1>
<p align='center'><a href='https://discord.gg/ksGfNvDEfq'>Discord</a>

Copyright (C) 2024 bitpredator

## SCREENSHOTS
![screenshot](https://i.gyazo.com/645a490f474296a9c5ce2a05a16a33c9.png)
![screenshot](https://i.gyazo.com/f4c14b2efe6f0ff8c88098a4a524e8be.png)
![screenshot](https://i.gyazo.com/0aaeaa5b78cd2bef98ee9185bc5295c8.png)

## USAGE

Example on how to add a button-event since people don't want to learn:
https://pastebin.com/UPQRcAei

```lua
-- ### Event usages:

-- Look at your own ID-card
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))

-- Show your ID-card to the closest person
local player, distance = ESX.Game.GetClosestPlayer()

if distance ~= -1 and distance <= 3.0 then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
else
ESX.ShowNotification('No players nearby')
end


-- Look at your own driver license
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')

-- Show your driver license to the closest person
local player, distance = ESX.Game.GetClosestPlayer()

if distance ~= -1 and distance <= 3.0 then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
else
ESX.ShowNotification('No players nearby')
end


-- Look at your own firearms license
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')

-- Show your firearms license to the closest person
local player, distance = ESX.Game.GetClosestPlayer()

if distance ~= -1 and distance <= 3.0 then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
else
ESX.ShowNotification('No players nearby')
end

-- ### A menu (THIS IS AN EXAMPLE)
function openMenu()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'id_card_menu',
{
title = 'ID menu',
elements = {
{label = 'Check your ID', value = 'checkID'},
{label = 'Show your ID', value = 'showID'},
{label = 'Check your driver license', value = 'checkDriver'},
{label = 'Show your driver license', value = 'showDriver'},
{label = 'Check your firearms license', value = 'checkFirearms'},
{label = 'Show your firearms license', value = 'showFirearms'},
}
},
function(data, menu)
local val = data.current.value

if val == 'checkID' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
elseif val == 'checkDriver' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
elseif val == 'checkFirearms' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'weapon')
else
local player, distance = ESX.Game.GetClosestPlayer()

if distance ~= -1 and distance <= 3.0 then
if val == 'showID' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
elseif val == 'showDriver' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
elseif val == 'showFirearms' then
TriggerServerEvent('bpt_idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'weapon')
end
else
TriggerClientEvent("esx:showNotification", _source, TranslateCap("no_license_type"))
end
end
end,
function(data, menu)
menu.close()
end
)
end
```

This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.

This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.

ATTENTION:
You are not authorized to change the name of the resource and the resources within it.

If you want to contribute you can open a pull request.

You are not authorized to sell this software (this is free project).

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local open = false

-- Open ID card
RegisterNetEvent("jsfour-idcard:open")
AddEventHandler("jsfour-idcard:open", function(data, type)
RegisterNetEvent("bpt_idcard:open")
AddEventHandler("bpt_idcard:open", function(data, type)
open = true
SendNUIMessage({
action = "open",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ server_script({
"locales/*.lua",
"@oxmysql/lib/MySQL.lua",
"config.lua",
"server.lua",
"server/*.lua",
})

client_script({
"@es_extended/locale.lua",
"locales/*.lua",
"config.lua",
"client.lua",
"client/*.lua",
})

files({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*!
* Materialize v0.100.2 (http://materializecss.com)
* Copyright 2014-2017 Materialize
* MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
*/
.materialize-red {
background-color: #e51c23 !important
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@font-face {
font-family: justsignature;
src: url('../fonts/justsignature/JustSignature.woff');
}

body,
html {
width: 100%;
height: 100%;
}

p {
padding: 0;
margin: 0;
text-transform: uppercase;
color: #9e9e9e;
font-size: 12px;
}

#id-card {
position: relative;
display: none;
margin: 230px 50px 0 0;
float: right;
width: 457px;
height: 272px;
padding: 54px 17px 10px 144px;
background: url("../images/idcard.png");
}

img {
position: absolute;
left: 7px;
top: 5px;
}

#name {
font-weight: bolder;
font-size: 18px;
color: #282828;
}

#inline {
position: absolute;
top: 109px;
}

#dob {
position: absolute;
left: 0;
width: 100px;
}

#sex {
position: absolute;
left: 90px;
}

#height {
position: absolute;
left: 150px;
width: 60px;
}

#signature {
position: absolute;
bottom: 76px;
left: 152px;
color: #b1b177;
font-size: 19px;
text-transform: capitalize;
font-family: justsignature;
}

#licenses {
position: absolute;
top: 109px;
right: 33px;
width: 50px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
$(document).ready(function () {
// LUA listener
window.addEventListener('message', function (event) {
if (event.data.action == 'open') {
var type = event.data.type;
var userData = event.data.array['user'][0];
var licenseData = event.data.array['licenses'];
var sex = userData.sex;

if (type == 'driver' || type == null) {
$('img').show();
$('#name').css('color', '#282828');

if (sex.toLowerCase() == 'm') {
$('img').attr('src', 'assets/images/male.png');
$('#sex').text('male');
} else {
$('img').attr('src', 'assets/images/female.png');
$('#sex').text('female');
}

$('#name').text(userData.firstname + ' ' + userData.lastname);
$('#dob').text(userData.dateofbirth);
$('#height').text(userData.height);
$('#signature').text(userData.firstname + ' ' + userData.lastname);

if (type == 'driver') {
if (licenseData != null) {
Object.keys(licenseData).forEach(function (key) {
var type = licenseData[key].type;

if (type == 'drive_bike') {
type = 'bike';
} else if (type == 'drive_truck') {
type = 'truck';
} else if (type == 'drive') {
type = 'car';
}

if (type == 'bike') {
$('#licenses').append('<p>' + 'Bike' + '</p>');
} else if (type == 'truck') {
$('#licenses').append('<p>' + 'Truck' + '</p>');
} else if (type == 'car') {
$('#licenses').append('<p>' + 'Car' + '</p>');
}
});
}

$('#id-card').css('background', 'url(assets/images/license.png)');
} else {
$('#id-card').css('background', 'url(assets/images/idcard.png)');
}
} else if (type == 'weapon') {
$('img').hide();
$('#name').css('color', '#d9d9d9');
$('#name').text(userData.firstname + ' ' + userData.lastname);
$('#dob').text(userData.dateofbirth);
$('#signature').text(userData.firstname + ' ' + userData.lastname);

$('#id-card').css('background', 'url(assets/images/firearm.png)');
}

$('#id-card').show();
} else if (event.data.action == 'close') {
$('#name').text('');
$('#dob').text('');
$('#height').text('');
$('#signature').text('');
$('#sex').text('');
$('#id-card').hide();
$('#licenses').html('');
}
});
});
Loading

0 comments on commit 2344885

Please sign in to comment.