fix(qb-core): post-update recovery + centralizare notify 17mov_Hud
Restaurat jobs.lua din git (Quasar fork a suprascris joburile 17mov). Adăugat item map în items.lua (lipsea, rupt rv-maphold). Setat licences.driver = false în config.lua. Override QBCore.Functions.Notify + QBCore:Notify event → 17mov_Hud:ShowNotification (toate notificările merg automat prin 17mov_Hud).
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
local id = 0
|
||||
local MugshotsCache = {}
|
||||
local Answers = {}
|
||||
|
||||
function GetMugShotBase64(Ped,Tasparent)
|
||||
if not Ped then return "" end
|
||||
id = id + 1
|
||||
|
||||
local Handle = RegisterPedheadshot(Ped)
|
||||
|
||||
local timer = 2000
|
||||
while ((not Handle or not IsPedheadshotReady(Handle) or not IsPedheadshotValid(Handle)) and timer > 0) do
|
||||
Citizen.Wait(10)
|
||||
timer = timer - 10
|
||||
end
|
||||
|
||||
local MugShotTxd = 'none'
|
||||
if (IsPedheadshotReady(Handle) and IsPedheadshotValid(Handle)) then
|
||||
MugshotsCache[id] = Handle
|
||||
MugShotTxd = GetPedheadshotTxdString(Handle)
|
||||
end
|
||||
|
||||
SendNUIMessage({
|
||||
type = 'convert',
|
||||
pMugShotTxd = MugShotTxd,
|
||||
removeImageBackGround = Tasparent or false,
|
||||
id = id,
|
||||
})
|
||||
|
||||
local p = promise.new()
|
||||
Answers[id] = p
|
||||
|
||||
return Citizen.Await(p)
|
||||
end
|
||||
exports("GetMugShotBase64", GetMugShotBase64)
|
||||
|
||||
RegisterNUICallback('Answer', function(data)
|
||||
if MugshotsCache[data.Id] then
|
||||
UnregisterPedheadshot(MugshotsCache[data.Id])
|
||||
MugshotsCache[data.Id] = nil
|
||||
end
|
||||
Answers[data.Id]:resolve(data.Answer)
|
||||
Answers[data.Id] = nil
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if (GetCurrentResourceName() ~= resourceName) then
|
||||
return
|
||||
end
|
||||
for k,v in pairs(MugshotsCache) do
|
||||
UnregisterPedheadshot(v)
|
||||
end
|
||||
MugshotsCache = {}
|
||||
id = 0
|
||||
end)
|
||||
|
||||
RegisterCommand("base64mugshotNormal",function(source,args,rawCommand)
|
||||
print(GetMugShotBase64(GetPlayerPed(-1),false))
|
||||
end,false)
|
||||
|
||||
RegisterCommand("base64mugshotTrasParent",function(source,args,rawCommand)
|
||||
print(GetMugShotBase64(GetPlayerPed(-1),true))
|
||||
end,false)
|
||||
@@ -0,0 +1,18 @@
|
||||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
name "MugShotBase64"
|
||||
description 'A script can convert peds mugshot image to Base64 encoding to save that as save and manage that'
|
||||
author "BaziForYou#9907"
|
||||
|
||||
ui_page 'html/index.html'
|
||||
|
||||
files {
|
||||
"html/js/*",
|
||||
"html/js/models/*",
|
||||
"html/img/*",
|
||||
"html/index.html",
|
||||
}
|
||||
client_script {
|
||||
"client.lua",
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,9 @@
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="js/tfjs@1.2"></script>
|
||||
<script src="js/body-pix@2.0"></script>
|
||||
<script defer src="js/script.js"></script>
|
||||
</head>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,102 @@
|
||||
|
||||
async function getBase64Image(src, removeImageBackGround, callback, outputFormat) {
|
||||
const img = new Image();
|
||||
img.crossOrigin = 'Anonymous';
|
||||
img.addEventListener("load", () => loadFunc(), false);
|
||||
async function loadFunc() {
|
||||
const canvas = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
var convertingCanvas = canvas;
|
||||
if (removeImageBackGround) {
|
||||
var selectedSize = 320
|
||||
canvas.height = selectedSize;
|
||||
canvas.width = selectedSize;
|
||||
ctx.drawImage(img, 0, 0, selectedSize, selectedSize);
|
||||
await removeBackGround(canvas);
|
||||
const canvas2 = document.createElement('canvas');
|
||||
const ctx2 = canvas2.getContext('2d');
|
||||
canvas2.height = 64;
|
||||
canvas2.width = 64;
|
||||
ctx2.drawImage(canvas, 0, 0, selectedSize, selectedSize, 0, 0, img.naturalHeight, img.naturalHeight);
|
||||
convertingCanvas = canvas2;
|
||||
} else {
|
||||
canvas.height = img.naturalHeight;
|
||||
canvas.width = img.naturalWidth;
|
||||
ctx.drawImage(img, 0, 0);
|
||||
}
|
||||
var dataURL = convertingCanvas.toDataURL(outputFormat);
|
||||
canvas.remove();
|
||||
convertingCanvas.remove();
|
||||
img.remove();
|
||||
callback(dataURL);
|
||||
};
|
||||
|
||||
img.src = src;
|
||||
if (img.complete || img.complete === undefined) {
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAkCAIAAACIS8SLAAAAKklEQVRIie3NMQEAAAgDILV/55nBww8K0Enq2XwHDofD4XA4HA6Hw+E4Wwq6A0U+bfCEAAAAAElFTkSuQmCC";
|
||||
img.src = src;
|
||||
}
|
||||
}
|
||||
|
||||
async function Convert(pMugShotTxd, removeImageBackGround, id) {
|
||||
var tempUrl = `https://nui-img/${pMugShotTxd}/${pMugShotTxd}?t=${String(Math.round(new Date().getTime() / 1000))}`;
|
||||
if (pMugShotTxd == 'none') {
|
||||
tempUrl = './img/failSafe.png';
|
||||
}
|
||||
getBase64Image(tempUrl, removeImageBackGround, function(dataUrl) {
|
||||
$.post(`https://${GetParentResourceName()}/Answer`, JSON.stringify({
|
||||
Answer: dataUrl,
|
||||
Id: id,
|
||||
}));
|
||||
})
|
||||
}
|
||||
|
||||
// https://www.youtube.com/watch?v=GV6LSAYzEgc
|
||||
async function removeBackGround(sentCanvas) {
|
||||
const canvas = sentCanvas;
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Loading the model
|
||||
const net = await bodyPix.load({
|
||||
architecture: 'MobileNetV1',
|
||||
outputStride: 16,
|
||||
multiplier: 0.75,
|
||||
quantBytes: 2,
|
||||
modelUrl: "./js/models/model-stride16.json"
|
||||
});
|
||||
|
||||
// Segmentation
|
||||
const { data:map } = await net.segmentPerson(canvas, {
|
||||
internalResolution: 'medium',
|
||||
});
|
||||
|
||||
// Extracting image data
|
||||
const { data:imgData } = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Creating new image data
|
||||
const newImg = ctx.createImageData(canvas.width, canvas.height);
|
||||
const newImgData = newImg.data;
|
||||
|
||||
for (var i=0; i<map.length; i++) {
|
||||
//The data array stores four values for each pixel
|
||||
const [r, g, b, a] = [imgData[i*4], imgData[i*4+1], imgData[i*4+2], imgData[i*4+3]];
|
||||
[
|
||||
newImgData[i*4],
|
||||
newImgData[i*4+1],
|
||||
newImgData[i*4+2],
|
||||
newImgData[i*4+3]
|
||||
] = !map[i] ? [255, 255, 255, 0] : [r, g, b, a];
|
||||
}
|
||||
|
||||
// Draw the new image back to canvas
|
||||
ctx.putImageData(newImg, 0, 0);
|
||||
}
|
||||
|
||||
window.addEventListener("message", (e) => GotMessage(e), false);
|
||||
async function GotMessage(e) {
|
||||
var msg = e.data
|
||||
if (msg.type == 'convert') {
|
||||
Convert(msg.pMugShotTxd, msg.removeImageBackGround, msg.id);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user