From 53578d1af6e35a00e152d9603fa62cf0c4481568 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Mon, 4 Aug 2025 05:39:52 +0200 Subject: [PATCH] ed --- resources/[tools]/MugShotBase64/client.lua | 63 ++ .../[tools]/MugShotBase64/fxmanifest.lua | 18 + .../MugShotBase64/html/img/failSafe.png | Bin 0 -> 3261 bytes .../[tools]/MugShotBase64/html/index.html | 9 + .../MugShotBase64/html/js/body-pix@2.0 | 18 + .../html/js/models/group1-shard1of1.bin | Bin 0 -> 2598784 bytes .../html/js/models/model-stride16.json | 1 + .../[tools]/MugShotBase64/html/js/script.js | 102 +++ .../[tools]/MugShotBase64/html/js/tfjs@1.2 | 3 + .../[tools]/um-idcard/CODE_OF_CONDUCT.md | 128 ++++ resources/[tools]/um-idcard/LICENSE | 674 ++++++++++++++++++ resources/[tools]/um-idcard/README.md | 45 ++ .../um-idcard/bridge/framework/esx.lua | 69 ++ .../[tools]/um-idcard/bridge/framework/qb.lua | 72 ++ .../um-idcard/bridge/framework/qbox.lua | 96 +++ .../[tools]/um-idcard/bridge/inventory/lj.lua | 14 + .../[tools]/um-idcard/bridge/inventory/ox.lua | 13 + .../[tools]/um-idcard/bridge/inventory/ps.lua | 14 + .../[tools]/um-idcard/bridge/inventory/qb.lua | 14 + .../[tools]/um-idcard/bridge/inventory/qs.lua | 12 + resources/[tools]/um-idcard/config.lua | 32 + resources/[tools]/um-idcard/fxmanifest.lua | 40 ++ resources/[tools]/um-idcard/lang/global.js | 8 + resources/[tools]/um-idcard/main/client.lua | 86 +++ resources/[tools]/um-idcard/main/server.lua | 23 + resources/[tools]/um-idcard/main/version.lua | 1 + .../um-idcard/web/badges/examplebadge.png | Bin 0 -> 594278 bytes resources/[tools]/um-idcard/web/css/style.css | 131 ++++ resources/[tools]/um-idcard/web/flags/32.png | Bin 0 -> 156 bytes resources/[tools]/um-idcard/web/index.html | 61 ++ .../[tools]/um-idcard/web/js/fetchNui.js | 18 + resources/[tools]/um-idcard/web/js/main.js | 92 +++ 32 files changed, 1857 insertions(+) create mode 100644 resources/[tools]/MugShotBase64/client.lua create mode 100644 resources/[tools]/MugShotBase64/fxmanifest.lua create mode 100644 resources/[tools]/MugShotBase64/html/img/failSafe.png create mode 100644 resources/[tools]/MugShotBase64/html/index.html create mode 100644 resources/[tools]/MugShotBase64/html/js/body-pix@2.0 create mode 100644 resources/[tools]/MugShotBase64/html/js/models/group1-shard1of1.bin create mode 100644 resources/[tools]/MugShotBase64/html/js/models/model-stride16.json create mode 100644 resources/[tools]/MugShotBase64/html/js/script.js create mode 100644 resources/[tools]/MugShotBase64/html/js/tfjs@1.2 create mode 100644 resources/[tools]/um-idcard/CODE_OF_CONDUCT.md create mode 100644 resources/[tools]/um-idcard/LICENSE create mode 100644 resources/[tools]/um-idcard/README.md create mode 100644 resources/[tools]/um-idcard/bridge/framework/esx.lua create mode 100644 resources/[tools]/um-idcard/bridge/framework/qb.lua create mode 100644 resources/[tools]/um-idcard/bridge/framework/qbox.lua create mode 100644 resources/[tools]/um-idcard/bridge/inventory/lj.lua create mode 100644 resources/[tools]/um-idcard/bridge/inventory/ox.lua create mode 100644 resources/[tools]/um-idcard/bridge/inventory/ps.lua create mode 100644 resources/[tools]/um-idcard/bridge/inventory/qb.lua create mode 100644 resources/[tools]/um-idcard/bridge/inventory/qs.lua create mode 100644 resources/[tools]/um-idcard/config.lua create mode 100644 resources/[tools]/um-idcard/fxmanifest.lua create mode 100644 resources/[tools]/um-idcard/lang/global.js create mode 100644 resources/[tools]/um-idcard/main/client.lua create mode 100644 resources/[tools]/um-idcard/main/server.lua create mode 100644 resources/[tools]/um-idcard/main/version.lua create mode 100644 resources/[tools]/um-idcard/web/badges/examplebadge.png create mode 100644 resources/[tools]/um-idcard/web/css/style.css create mode 100644 resources/[tools]/um-idcard/web/flags/32.png create mode 100644 resources/[tools]/um-idcard/web/index.html create mode 100644 resources/[tools]/um-idcard/web/js/fetchNui.js create mode 100644 resources/[tools]/um-idcard/web/js/main.js diff --git a/resources/[tools]/MugShotBase64/client.lua b/resources/[tools]/MugShotBase64/client.lua new file mode 100644 index 000000000..a49b2f1a2 --- /dev/null +++ b/resources/[tools]/MugShotBase64/client.lua @@ -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) \ No newline at end of file diff --git a/resources/[tools]/MugShotBase64/fxmanifest.lua b/resources/[tools]/MugShotBase64/fxmanifest.lua new file mode 100644 index 000000000..5a660a784 --- /dev/null +++ b/resources/[tools]/MugShotBase64/fxmanifest.lua @@ -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", +} diff --git a/resources/[tools]/MugShotBase64/html/img/failSafe.png b/resources/[tools]/MugShotBase64/html/img/failSafe.png new file mode 100644 index 0000000000000000000000000000000000000000..a4bdeea3f924464958165568ab26c559179ca211 GIT binary patch literal 3261 zcmV;u3_|mXP)Px>cS%G+RCr$Pn{R9zjsaJ3Ei47Y)} z+6Z3l1uj!Ba97_Be5G#({``-(Sq=QtalXCOaY?Jd{(X-idHaq^jit)N!M`2HPYyhP z$v9jR03`g5+qm#>LzT8F07cVe34VIuc?|t)WYs~eDuAAC?Ktqnk1IrcQULO%??3Sj zMovzw8i-W`@TJdh$IrgI2WU`XFPg9xdC4jP6_&;KS(GeBjyz*z8!1>pEBZ`(x#*D0zS z@f5NVl&MaoGuYYF%?_y=5QKV0T>(7)%?Hu9qZ^K8!LeVdtm5x)jpCPoJX$vfbp`O!v-{zcx%jfpOEeJB z+|2p`_{EcO4#0sT?vpnejv)Yq83dGo?>u#I?E&c9-i^n<^&qT8o?!|OL3K-?&JhHw zWI+O8=~#(#2n0ZuJ{?N{+y!B%4JvcM+wY&O3xv8kfJ&c20+0^y10eA%jSqldJYAzI z;6ZUJ0MPm92Hq>w%LR1-(0g+i9{t7uw|qkx<&v;}LkQ(kfb{?}90jl!c`rcY0n_XD z*||`_D_Cp6gcC4X?;%5N;Lm#g^&vh$sv1dtT3f6N0DmSF(FO#sQQ2v;#Je|wKmf|{ zx1H#z;A!(oLfaL&?cvj-e0FdIDwMBy&+uZnZ`q_C2;fe*2P4N;hFPccF`F>+#0;$;< zL>uFt__FZ0I1>u`x&;7h62K#0@5herPL^fG_GWj+yaBW9K#FIM5WRq_xVjq?RYYEo zMR^s{HgQOfm^#1n!3177GIT-Le3FZGsRF$>b>h(n`q}Tzq;q^bGsCvisXW_GWq7G~ zZK#PrP>mS|U-A?^vLW_+~CX-WW%FE1w;@p{ z)2S4?n;MZx^Im`;B-+~;02xF7{0|Pjweq#YnjCQFwoY_+--zBWUjO|LXx_rDIy`og zIiR<*n?cCW&$^{w4S>?OT-(BgO8^6R^dXbZATyV#Z~&#HvB2o~1cpzoe9f>X0DarK z&~rm8np<1k644YsqBAlXwsoK&pXU1%vDPReo8r)8jnFs6VVWlE;!>x^`F)Opd^Q6; z7H3;IiqPV`9WdcFvZ+)W<7cPw=KGfk0A*GxnS_!v6U3Odr!>{ z=SM2cSR@ zmO@ZBMi>MFkUw8Qe!*L2)3k^y_{l#Uy8P2&KLE;Edo%CvX)?qnM8OyI$kQ~4SO;;{%5&#Mbp&CF_V-vg1>_0Vq`5hqr_}~|N(S3c3`(i_jM-d8# zp)RQ~^I4b$KFFOCV}e9$8&Xq~P&aDGh@mrG*W)p$KAXc);FN6Grok3kf(^V4IsETY zjGyK0MlDfuBPf5I#1jO1vl9xd2(IUiVaT_{r|L1JGASmUB6VgGrddQ>j2fAP+S)4g zIE%d7q=nW%LkJ3-x{0Uf)*XODPo)053IK^$BT+W?cL7XI!Z7kKfW~IBcNj$@4|5?8 z(j_*xb}4b z`MkP0fFAhJ?LA0rPN4N#Z-qyVdT)0b0H4(C^fbbn_v(yYDtYe!ve_I>CMsg=^aKV+ zY8(9cA6QoaJGZrC$4z`@C?Oc8H+iA+T2lffT!uN%7fjr!95_}0Nab=Eo%j$VH4c7O z4FEm(hXZ_6=m(IQ^;&DkGAaR7FOfy~_#hVJ-DFgZ7f3wC3x9dD5?GB#b#(ycrLUtM zx8CBpVDhv#u}ROS5Zk1o{nlQVZE}L&0lELpAnW_0gdh+ADSmWf0wbsSYE!+U?f|xT zwBeQ;cvnXI*>nM>X~8skE3U6JtikYoQ89LA7GslF0DwLB z?8G}KxuCXai~&&95ZfB59P%IXYZN(OqZeIhO0!XMDEB&w#mS0q$U+)|3`KGt& zGm}sphn2n|W`I{DfCKv;b_;a!!zo_(bsbtn2clvYC{mbW$xPmmou7e`%fra=cYv{0 z57u)p9$x!Zpr^AP5AVLy&1fc@M{0T+S|q|Ccr$yR#LQKm$!5GUf)u=UJbg5?vkx;2Rq!wlpDlP1zMs*Zlx`Z|=lvBNO-?tpwF6>gIq0&mG`(Ju?m? z@7Y=orFQ`5`FNmE;At$FpldQ>8)DEj6`Gh$21GAG-w3MfRVZ7(z>@CUx34Y; zY6g(JCkZKj@by8&<|h~cYmp1}&t*ucS*%u7$F_JKo)-?F^#Bsj+@q?nm%sp! z3+Q{{fn(hD*|y*0Q6-h#ofsyb|sUz|NaMH7zR?}ix2qz1LX9v zmtZZ}ux$&LC0206t1KlLfMwV)Ed!>(>wnQOkee5!FV+S0NCd$UZ~1L{Cm?2v5&*&~ zy6)j4O%|pJUDu&UbVT$BUU}se934E0HwNF}m#b%+-kogkq5!^n-vFLH$Qw9{{J8=H z;Ks)Qpz8!7bdC4PoMV?^i1|N3s0N^|*Pw=j2#J>`mhHe6Bf^UTkok%G7GoaU`xst+ z_2nwbm50j$NZ#9ziuCX%uX@kIJKZ3!wAH zPW0c`kG+q2pS&%HZsyD^G)?nd;B$bHp2FPd@J9fUc#4Ywpy!IFfB~Rz1V{-W-m?>W v)ADl(g0LI_zm9{?9mL^R4`KWSUsn4+{bhbzv+&}=00000NkvXXu0mjf7zhaW literal 0 HcmV?d00001 diff --git a/resources/[tools]/MugShotBase64/html/index.html b/resources/[tools]/MugShotBase64/html/index.html new file mode 100644 index 000000000..b2e283c65 --- /dev/null +++ b/resources/[tools]/MugShotBase64/html/index.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/resources/[tools]/MugShotBase64/html/js/body-pix@2.0 b/resources/[tools]/MugShotBase64/html/js/body-pix@2.0 new file mode 100644 index 000000000..fdc628b56 --- /dev/null +++ b/resources/[tools]/MugShotBase64/html/js/body-pix@2.0 @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core"),require("@tensorflow/tfjs-converter")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core","@tensorflow/tfjs-converter"],e):e(t.bodyPix={},t.tf,t.tf)}(this,function(t,e,n){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]n?n:t}function y(t,e){return{x:t.x+e.x,y:t.y+e.y}}function b(t,e,n){void 0===n&&(n=.3);for(var r=0,o=0,i=0;in&&(o+=1,r+=Math.pow(t[i].x-e.keypoints[i].position.x,2)+Math.pow(t[i].y-e.keypoints[i].position.y,2));return 0===o?r=1/0:r/=o,r}function x(t,e,n,r,o,i,a){for(var s=a[0],u=a[1],d=n(t),f=d.y*r+d.x,l=o[h*(2*f)+e],c=o[h*(2*f+1)+e],p=t.y+l,m=t.x+c,g=0;g "+f+") {\n numKpt = numKpt + 1;\n curDistSum = curDistSum + dist(x, y, poseX, poseY);\n }\n }\n if (numKpt > 0 && curDistSum / float(numKpt) < minDist) {\n minDist = curDistSum / float(numKpt);\n iMin = i;\n }\n }\n return iMin;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int nearestPose = findNearestPose(coords[0], coords[1]);\n setOutput(float(nearestPose));\n }\n "};return e.backend().compileAndRun(D,[t,S,T])}function _(){return"webgl"===e.getBackend()}function E(t,n,r,o,i,u,d,f,l,c,h,p){var g=d[0],v=d[1];return void 0===l&&(l=.2),void 0===c&&(c=8),void 0===h&&(h=.3),void 0===p&&(p=10),a(this,void 0,void 0,function(){var a,d,w,y,b;return s(this,function(s){switch(s.label){case 0:return a=r.filter(function(t){return t.score>=l}),_()?(w=e.tidy(function(){var r=k(t,n,a,o,i,u,[g,v],f,c,h,p);return a.map(function(t,n){return function(t,n){return e.tidy(function(){return t.equal(e.scalar(n)).toInt()})}(r,n)})}),[4,Promise.all(w.map(function(t){return t.data()}))]):[3,2];case 1:return d=s.sent(),w.forEach(function(t){return t.dispose()}),[3,5];case 2:return[4,t.data()];case 3:return y=s.sent(),[4,n.data()];case 4:b=s.sent(),d=function(t,e,n,r,o,i,a,s,u,d){var f=a[0],l=a[1];void 0===d&&(d=5);for(var c=n.map(function(t){return new Uint8Array(r*o).fill(0)}),h=s.top,p=s.left,g=m([r,o],[f,l],s),v=g[0],w=g[1],y=M([f,l],i)[0],b=0;b=0&&(c[_][k]=1)}}return c}(y,b,a,o,i,u,[g,v],f,c),s.label=5;case 5:return[2,d.map(function(t,e){return{data:t,pose:a[e],width:i,height:o}})]}})})}function P(t,n,r,o,i,u,d,f,l,c,h,p,g){var v=f[0],w=f[1];return void 0===c&&(c=.2),void 0===h&&(h=8),void 0===p&&(p=.3),void 0===g&&(g=10),a(this,void 0,void 0,function(){var a,f,y,b,x,E;return s(this,function(s){switch(s.label){case 0:return a=o.filter(function(t){return t.score>=c}),_()?(y=e.tidy(function(){var o=k(t,n,a,i,u,d,[v,w],l,h,p,g);return a.map(function(t,n){return function(t,n,r){return e.tidy(function(){return t.equal(e.scalar(r)).toInt().mul(n.add(1)).sub(1)})}(o,r,n)})}),[4,Promise.all(y.map(function(t){return t.data()}))]):[3,2];case 1:return f=s.sent(),y.forEach(function(t){return t.dispose()}),[3,6];case 2:return[4,t.data()];case 3:return b=s.sent(),[4,n.data()];case 4:return x=s.sent(),[4,r.data()];case 5:E=s.sent(),f=function(t,e,n,r,o,i,a,s,u,d,f){var l=s[0],c=s[1];void 0===f&&(f=5);for(var h=r.map(function(t){return new Int32Array(o*i).fill(-1)}),p=u.top,g=u.left,v=m([o,i],[l,c],u),w=v[0],y=v[1],b=M([l,c],a)[0],x=0;x=0&&(h[E][_]=n[_])}}return h}(b,x,E,a,i,u,d,[v,w],l,h),s.label=6;case 6:return[2,f.map(function(t,e){return{pose:a[e],data:t,height:i,width:u}})]}})})}function O(t){return Math.floor(t/2)}var I=function(){function t(t,e){this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=e}return t.prototype.enqueue=function(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)},t.prototype.dequeue=function(){var t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t},t.prototype.empty=function(){return-1===this.numberOfElements},t.prototype.size=function(){return this.numberOfElements+1},t.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1)},t.prototype.max=function(){return this.priorityQueue[0]},t.prototype.swim=function(t){for(;t>0&&this.less(O(t),t);)this.exchange(t,O(t)),t=O(t)},t.prototype.sink=function(t){for(;2*t<=this.numberOfElements;){var e=2*t;if(ee){d=!1;break}if(!d)break}return d}var R=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]].map(function(t){var e=t[0],n=t[1];return[p[e],p[n]]}),H=R.map(function(t){return t[1]}),T=R.map(function(t){return t[0]});function B(t,e,n,r){return{y:w(Math.round(t.y/e),0,n-1),x:w(Math.round(t.x/e),0,r-1)}}function F(t,e,n,r,o,i,a,s){void 0===s&&(s=2);for(var u=r.shape,d=u[0],f=u[1],l=function(t,e,n){var r=n.shape[2]/2;return{y:n.get(e.y,e.x,t),x:n.get(e.y,e.x,r+t)}}(t,B(e.position,i,d,f),a),h=y(e.position,l),p=0;p=0;--h){var p=H[h],m=T[h];u[p]&&!u[m]&&(u[m]=F(h,u[p],m,e,n,r,i))}for(h=0;h=G,function(){return"inputResolution must be a string or number between "+G+" and "+J+", but was "+t}),t}(t);return[U(o*a,n),U(i*a,n)]}function $(t,n,r,o,i){var a=n[0],s=n[1],u=r[0],d=r[1],f=o[0],l=f[0],c=f[1],h=o[1],p=h[0],m=h[1];return void 0===i&&(i=!1),e.tidy(function(){var n=t.resizeBilinear([u,d],!0);return i&&(n=n.sigmoid()),function(t,n,r){var o=n[0],i=n[1],a=r[0],s=a[0],u=a[1],d=r[1],f=d[0],l=d[1];return e.tidy(function(){return e.image.cropAndResize(t.expandDims(),[[s/(o+s+u-1),f/(i+f+l-1),(s+o-1)/(o+s+u-1),(f+i-1)/(i+f+l-1)]],[0],[o,i]).squeeze([0])})}(n,[a,s],[[l,c],[p,m]])})}function tt(t,n){var r=n[0],o=n[1],i=Q(t),a=i[0],s=i[1],u=o/r,d=[0,0,0,0],f=d[0],l=d[1],c=d[2],h=d[3];return s/a1)throw new Error("segmentationThreshold "+e+". Should be in range [0.0, 1.0]");if(n<=0)throw new Error("Invalid maxDetections "+n+". Should be > 0");if(r<0||r>1)throw new Error("Invalid scoreThreshold "+r+". Should be in range [0.0, 1.0]");if(o<=0)throw new Error("Invalid nmsRadius "+o+".")}function ct(t){var e=t.segmentationThreshold,n=t.maxDetections,r=t.scoreThreshold,o=t.nmsRadius,i=t.minKeypointScore,a=t.refineSteps;if(e<0||e>1)throw new Error("segmentationThreshold "+e+". Should be in range [0.0, 1.0]");if(n<=0)throw new Error("Invalid maxDetections "+n+". Should be > 0");if(r<0||r>1)throw new Error("Invalid scoreThreshold "+r+". Should be in range [0.0, 1.0]");if(o<=0)throw new Error("Invalid nmsRadius "+o+".");if(i<0||i>1)throw new Error("Invalid minKeypointScore "+i+".Should be in range [0.0, 1.0]");if(a<=0||a>20)throw new Error("Invalid refineSteps "+a+".Should be in range [1, 20]")}var ht=function(){function t(t){this.baseModel=t}return t.prototype.predictForPersonSegmentation=function(t){var e=this.baseModel.predict(t);return{segmentLogits:e.segmentation,heatmapScores:e.heatmapScores,offsets:e.offsets,displacementFwd:e.displacementFwd,displacementBwd:e.displacementBwd}},t.prototype.predictForPersonSegmentationAndPart=function(t){var e=this.baseModel.predict(t);return{segmentLogits:e.segmentation,partHeatmapLogits:e.partHeatmaps,heatmapScores:e.heatmapScores,offsets:e.offsets,displacementFwd:e.displacementFwd,displacementBwd:e.displacementBwd}},t.prototype.predictForMultiPersonInstanceSegmentationAndPart=function(t){var e=this.baseModel.predict(t);return{segmentLogits:e.segmentation,longOffsets:e.longOffsets,heatmapScores:e.heatmapScores,offsets:e.offsets,displacementFwd:e.displacementFwd,displacementBwd:e.displacementBwd,partHeatmaps:e.partHeatmaps}},t.prototype.segmentPersonActivation=function(t,n,r){var o=this;void 0===r&&(r=.5);var i=Q(t),a=i[0],s=i[1],u=Z(n,this.baseModel.outputStride,[a,s]),f=tt(t,u),l=f.resized,c=f.padding,h=e.tidy(function(){var t=o.predictForPersonSegmentation(l),e=t.segmentLogits,n=t.heatmapScores,i=t.offsets,u=t.displacementFwd,f=t.displacementBwd,h=l.shape,p=h[0],m=h[1];return{segmentation:d($(e,[a,s],[p,m],[[c.top,c.bottom],[c.left,c.right]],!0).squeeze(),r),heatmapScores:n,offsets:i,displacementFwd:u,displacementBwd:f}}),p=h.segmentation,m=h.heatmapScores,g=h.offsets,v=h.displacementFwd,w=h.displacementBwd;return l.dispose(),{segmentation:p,heatmapScores:m,offsets:g,displacementFwd:v,displacementBwd:w,padding:c,internalResolutionHeightAndWidth:u}},t.prototype.segmentPerson=function(t,e){return void 0===e&&(e=dt),a(this,void 0,void 0,function(){var n,r,o,a,u,d,f,l,c,h,p,m,g,v,w,y,b,x;return s(this,function(s){switch(s.label){case 0:return lt(e=i({},dt,e)),n=this.segmentPersonActivation(t,e.internalResolution,e.segmentationThreshold),r=n.segmentation,o=n.heatmapScores,a=n.offsets,u=n.displacementFwd,d=n.displacementBwd,f=n.padding,l=n.internalResolutionHeightAndWidth,c=r.shape,h=c[0],p=c[1],[4,r.data()];case 1:return m=s.sent(),r.dispose(),[4,et([o,a,u,d])];case 2:return g=s.sent(),v=g[0],w=g[1],y=g[2],b=g[3],x=rt(x=C(v,w,y,b,this.baseModel.outputStride,e.maxDetections,e.scoreThreshold,e.nmsRadius),[h,p],l,f,!1),o.dispose(),a.dispose(),u.dispose(),d.dispose(),[2,{height:h,width:p,data:m,allPoses:x}]}})})},t.prototype.segmentMultiPerson=function(t,n){return void 0===n&&(n=ft),a(this,void 0,void 0,function(){var r,o,a,u,f,l,c,h,p,m,g,v,w,y,b,x,S,M,k,_,P,O=this;return s(this,function(s){switch(s.label){case 0:return ct(n=i({},ft,n)),r=Q(t),o=r[0],a=r[1],u=Z(n.internalResolution,this.baseModel.outputStride,[o,a]),f=tt(t,u),l=f.resized,c=f.padding,h=e.tidy(function(){var t,e=O.predictForMultiPersonInstanceSegmentationAndPart(l),r=e.segmentLogits,i=e.longOffsets,s=e.heatmapScores,f=e.offsets,h=e.displacementFwd,p=e.displacementBwd;return t=i,{segmentation:d($(r,[o,a],u,[[c.top,c.bottom],[c.left,c.right]],!0).squeeze(),n.segmentationThreshold),longOffsets:t,heatmapScoresRaw:s,offsetsRaw:f,displacementFwdRaw:h,displacementBwdRaw:p}}),p=h.segmentation,m=h.longOffsets,g=h.heatmapScoresRaw,v=h.offsetsRaw,w=h.displacementFwdRaw,y=h.displacementBwdRaw,[4,et([g,v,w,y])];case 1:return b=s.sent(),x=b[0],S=b[1],M=b[2],k=b[3],_=rt(_=C(x,S,M,k,this.baseModel.outputStride,n.maxDetections,n.scoreThreshold,n.nmsRadius),[o,a],u,c,!1),[4,E(p,m,_,o,a,this.baseModel.outputStride,u,c,n.scoreThreshold,n.refineSteps,n.minKeypointScore,n.maxDetections)];case 2:return P=s.sent(),l.dispose(),p.dispose(),m.dispose(),g.dispose(),v.dispose(),w.dispose(),y.dispose(),[2,P]}})})},t.prototype.segmentPersonPartsActivation=function(t,n,r){var o=this;void 0===r&&(r=.5);var i=Q(t),a=i[0],s=i[1],f=Z(n,this.baseModel.outputStride,[a,s]),l=tt(t,f),c=l.resized,h=l.padding,p=e.tidy(function(){var t=o.predictForPersonSegmentationAndPart(c),n=t.segmentLogits,i=t.partHeatmapLogits,f=t.heatmapScores,l=t.offsets,p=t.displacementFwd,m=t.displacementBwd,g=c.shape,v=g[0],w=g[1],y=$(n,[a,s],[v,w],[[h.top,h.bottom],[h.left,h.right]],!0),b=$(i,[a,s],[v,w],[[h.top,h.bottom],[h.left,h.right]],!0);return{partSegmentation:function(t,n){var r=n.shape,o=r[0],i=r[1],a=r[2];return e.tidy(function(){var r,s,d=u(n),f=e.range(0,a,1,"int32").expandDims(1),l=d.matMul(f).toInt().reshape([o,i]).add(e.scalar(1,"int32"));return(r=l,s=t,r.mul(s)).sub(e.scalar(1,"int32"))})}(d(y.squeeze(),r),b),heatmapScores:f,offsets:l,displacementFwd:p,displacementBwd:m}}),m=p.partSegmentation,g=p.heatmapScores,v=p.offsets,w=p.displacementFwd,y=p.displacementBwd;return c.dispose(),{partSegmentation:m,heatmapScores:g,offsets:v,displacementFwd:w,displacementBwd:y,padding:h,internalResolutionHeightAndWidth:f}},t.prototype.segmentPersonParts=function(t,e){return void 0===e&&(e=dt),a(this,void 0,void 0,function(){var n,r,o,a,u,d,f,l,c,h,p,m,g,v,w,y,b,x;return s(this,function(s){switch(s.label){case 0:return lt(e=i({},dt,e)),n=this.segmentPersonPartsActivation(t,e.internalResolution,e.segmentationThreshold),r=n.partSegmentation,o=n.heatmapScores,a=n.offsets,u=n.displacementFwd,d=n.displacementBwd,f=n.padding,l=n.internalResolutionHeightAndWidth,c=r.shape,h=c[0],p=c[1],[4,r.data()];case 1:return m=s.sent(),r.dispose(),[4,et([o,a,u,d])];case 2:return g=s.sent(),v=g[0],w=g[1],y=g[2],b=g[3],x=rt(x=C(v,w,y,b,this.baseModel.outputStride,e.maxDetections,e.scoreThreshold,e.nmsRadius),[h,p],l,f,!1),o.dispose(),a.dispose(),u.dispose(),d.dispose(),[2,{height:h,width:p,data:m,allPoses:x}]}})})},t.prototype.segmentMultiPersonParts=function(t,n){return void 0===n&&(n=ft),a(this,void 0,void 0,function(){var r,o,a,f,l,c,h,p,m,g,v,w,y,b,x,S,M,k,_,E,O,I,A=this;return s(this,function(s){switch(s.label){case 0:return ct(n=i({},ft,n)),r=Q(t),o=r[0],a=r[1],f=Z(n.internalResolution,this.baseModel.outputStride,[o,a]),l=tt(t,f),c=l.resized,h=l.padding,p=e.tidy(function(){var t=A.predictForMultiPersonInstanceSegmentationAndPart(c),r=t.segmentLogits,i=t.longOffsets,s=t.heatmapScores,l=t.offsets,p=t.displacementFwd,m=t.displacementBwd,g=t.partHeatmaps,v=$(r,[o,a],f,[[h.top,h.bottom],[h.left,h.right]],!0),w=$(g,[o,a],f,[[h.top,h.bottom],[h.left,h.right]],!0),y=i;return{segmentation:d(v.squeeze(),n.segmentationThreshold),longOffsets:y,heatmapScoresRaw:s,offsetsRaw:l,displacementFwdRaw:p,displacementBwdRaw:m,partSegmentation:function(t){var n=t.shape,r=n[0],o=n[1],i=n[2];return e.tidy(function(){var n=u(t),a=e.range(0,i,1,"int32").expandDims(1);return n.matMul(a).toInt().reshape([r,o])})}(w)}}),m=p.segmentation,g=p.longOffsets,v=p.heatmapScoresRaw,w=p.offsetsRaw,y=p.displacementFwdRaw,b=p.displacementBwdRaw,x=p.partSegmentation,[4,et([v,w,y,b])];case 1:return S=s.sent(),M=S[0],k=S[1],_=S[2],E=S[3],O=rt(O=C(M,k,_,E,this.baseModel.outputStride,n.maxDetections,n.scoreThreshold,n.nmsRadius),[o,a],f,h,!1),[4,P(m,g,x,O,o,a,this.baseModel.outputStride,f,h,n.scoreThreshold,n.refineSteps,n.minKeypointScore,n.maxDetections)];case 2:return I=s.sent(),c.dispose(),m.dispose(),g.dispose(),v.dispose(),w.dispose(),y.dispose(),b.dispose(),x.dispose(),[2,I]}})})},t.prototype.dispose=function(){this.baseModel.dispose()},t}();function pt(t){return a(this,void 0,void 0,function(){var r,o,i,a,u,d;return s(this,function(s){switch(s.label){case 0:if(r=t.outputStride,o=t.quantBytes,i=t.multiplier,null==e)throw new Error("Cannot find TensorFlow.js. If you are using a + + diff --git a/resources/[tools]/um-idcard/web/js/fetchNui.js b/resources/[tools]/um-idcard/web/js/fetchNui.js new file mode 100644 index 000000000..cf08e8b88 --- /dev/null +++ b/resources/[tools]/um-idcard/web/js/fetchNui.js @@ -0,0 +1,18 @@ +const resource = GetParentResourceName(); + +export async function fetchNui(eventName, data) { + try { + const resp = await fetch(`https://${resource}/${eventName}`, { + method: 'post', + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: JSON.stringify(data), + }); + + return await resp.json(); + } catch (error) { + console.error(error); + } + } + \ No newline at end of file diff --git a/resources/[tools]/um-idcard/web/js/main.js b/resources/[tools]/um-idcard/web/js/main.js new file mode 100644 index 000000000..6bcddc74e --- /dev/null +++ b/resources/[tools]/um-idcard/web/js/main.js @@ -0,0 +1,92 @@ +import { fetchNui } from './fetchNui.js'; +import { Global } from '../../lang/global.js'; + +let config; + +/** + * Get element by id + * @param id {string} + **/ +const getElementById = (id) => document.getElementById(id); + +/** + * Set visibility + * @param visibility {string} + **/ +const setVisibility = (visibility) => getElementById('um-idcard').style.visibility = visibility; + +/** + * Set visibility of badge + * @param badge {string|Object|null} + **/ +const setBadgeVisibility = (badge) => { + const badgeElement = getElementById('badge'); + if (!badge || badge === 'none') { + badgeElement.style.display = 'none'; + return; + } + getElementById('badgeimg').src = `badges/${badge.img}.png`; + getElementById('badgegrade').textContent = badge.grade; + badgeElement.style.display = 'flex'; +}; + +const closeFunction = () => { + getElementById('um-idcard').classList.remove('animate__animated', 'animate__fadeInLeft', 'animate__faster'); + setVisibility('hidden'); + setBadgeVisibility('none'); + fetchNui('closeIdCard'); +}; + +/** + * Open id card + * @param playerData {Object} + **/ +const openIdCard = (playerData) => { + const license = config.Licenses[playerData.cardtype]; + const elements = { + lastname: playerData.lastname, + name: playerData.firstname, + sign: `${playerData.lastname} ${playerData.firstname}`, + dob: playerData.birthdate, + sex: playerData.sex, + nationality: playerData.nationality, + cardtype: license.header, + }; + + Object.entries(elements).forEach(([key, value]) => { + getElementById(key).textContent = value; + }); + + getElementById('mugshot').src = playerData.mugShot; + getElementById('smallmugshot').src = playerData.mugShot; + getElementById('um-idcard').style.backgroundColor = license.background; + getElementById('um-idcard').classList.add('animate__animated', 'animate__fadeInLeft', 'animate__faster'); + setBadgeVisibility(playerData.badge); + setVisibility('visible'); + autoClose(); +}; + +const autoClose = () => { + if (!config.IdCardSettings.autoClose.status) return; + setTimeout(closeFunction, config.IdCardSettings.autoClose.time); +}; + +window.addEventListener('message', (event) => { + const { type, playerData, configData } = event.data; + if (type === 'playerData') { + openIdCard(playerData); + } else if (type === 'configData') { + config = configData; + } +}); + +window.addEventListener('load', () => { + Object.entries(Global).forEach(([key, value]) => { + getElementById(key).textContent = value; + }); +}); + +document.addEventListener('keydown', (e) => { + if (e.key !== config.IdCardSettings.closeKey) return; + closeFunction(); +});