From 87d3636c12ca3b38d4da4d2c5234ac61d2e3c81a Mon Sep 17 00:00:00 2001 From: BerkieBb <82737367+BerkieBb@users.noreply.github.com> Date: Mon, 27 Jun 2022 18:10:00 +0200 Subject: [PATCH 01/19] feat(server/commands): multiple permission support and fix argsrequired --- server/commands.lua | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/server/commands.lua b/server/commands.lua index fdcf590..99ef0f0 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -13,17 +13,43 @@ end) -- Register & Refresh Commands -function QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission) +function QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...) local restricted = true -- Default to restricted for all commands if not permission then permission = 'user' end -- some commands don't pass permission level if permission == 'user' then restricted = false end -- allow all users to use command - RegisterCommand(name, callback, restricted) -- Register command within fivem - if not QBCore.Commands.IgnoreList[permission] then -- only create aces for extra perm levels - ExecuteCommand(('add_ace qbcore.%s command.%s allow'):format(permission, name)) + + RegisterCommand(name, function(source, args, rawCommand) -- Register command within fivem + if argsrequired and #args < #arguments then + return TriggerClientEvent('chat:addMessage', source, { + color = {255, 0, 0}, + multiline = true, + args = {"System", Lang:t("error.missing_args2")} + }) + end + callback(source, args, rawCommand) + end, restricted) + + local extraPerms = ... and table.pack(...) or nil + if extraPerms then + extraPerms[extraPerms.n + 1] = permission -- The `n` field is the number of arguments in the packed table + extraPerms.n += 1 + permission = extraPerms + for i = 1, permission.n do + if not QBCore.Commands.IgnoreList[permission[i]] then -- only create aces for extra perm levels + ExecuteCommand(('add_ace qbcore.%s command.%s allow'):format(permission[i], name)) + end + end + permission.n = nil + else + permission = tostring(permission:lower()) + if not QBCore.Commands.IgnoreList[permission] then -- only create aces for extra perm levels + ExecuteCommand(('add_ace qbcore.%s command.%s allow'):format(permission, name)) + end end + QBCore.Commands.List[name:lower()] = { name = name:lower(), - permission = tostring(permission:lower()), + permission = permission, help = help, arguments = arguments, argsrequired = argsrequired, From 4d0c1bcfcdebcf07761c85810238b697f1d1f120 Mon Sep 17 00:00:00 2001 From: efe <51517714+aw3rque@users.noreply.github.com> Date: Mon, 11 Jul 2022 19:56:46 +0300 Subject: [PATCH 02/19] Update tr.lua --- locale/tr.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/locale/tr.lua b/locale/tr.lua index b66ab2c..92bbe1f 100644 --- a/locale/tr.lua +++ b/locale/tr.lua @@ -1,13 +1,16 @@ local Translations = { error = { - not_online = 'Oyuncu çevrimiçi değil', - wrong_format = 'Yanlış birim', - missing_args = 'Her argüman girilmedi (x, y, z)', - missing_args2 = 'Tüm argümanlar doldurulmalıdır!', - no_access = 'Bu komuta erişim yok', - company_too_poor = 'İşvereniniz bozuk', - item_not_exist = 'Öğe mevcut değil', - too_heavy = 'Envanter çok dolu' + not_online = 'Oyuncu çevrimiçi değil.', + wrong_format = 'Yanlış format.', + missing_args = 'Hiçbir argüman girilmedi. (x, y, z)', + missing_args2 = 'Tüm argümanlar doldurulmalıdır.', + no_access = 'Bu komuta erişimin yok.', + company_too_poor = 'İşvereninizin hiç parası yok.', + item_not_exist = 'Eşya mevcut değil', + too_heavy = 'Envanter çok dolu', + duplicate_license = 'Çoğaltılan Rockstar lisans bulundu!', + no_valid_license = 'Rockstar lisans bulunamadı.', + not_whitelisted = 'Bu sunucuda whitelistin yok.' }, success = {}, info = { @@ -15,7 +18,10 @@ local Translations = { job_info = 'İş: %{value} | Seviye: %{value2} | Görev: %{value3}', gang_info = 'Çete: %{value} | Seviye: %{value2}', on_duty = 'Şimdi görev başındasın!', - off_duty = 'Şimdi görevden alındın!' + off_duty = 'Şimdi görevden alındın!', + checking_ban = 'Merhaba %s. Banlı mısın diye kontrol ediyoruz.', + join_server = 'Merhaba %s. {Server Name} adlı sunucumuza hoş geldin.', + checking_whitelisted = 'Merhaba %s. Giriş iznin var mı diye kontrol ediyoruz.' } } From 28d17860e62cadb676100b167cac9d440a2eb238 Mon Sep 17 00:00:00 2001 From: efe <51517714+aw3rque@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:01:19 +0300 Subject: [PATCH 03/19] Update tr.lua --- locale/tr.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/tr.lua b/locale/tr.lua index 92bbe1f..581b472 100644 --- a/locale/tr.lua +++ b/locale/tr.lua @@ -5,8 +5,8 @@ local Translations = { missing_args = 'Hiçbir argüman girilmedi. (x, y, z)', missing_args2 = 'Tüm argümanlar doldurulmalıdır.', no_access = 'Bu komuta erişimin yok.', - company_too_poor = 'İşvereninizin hiç parası yok.', - item_not_exist = 'Eşya mevcut değil', + company_too_poor = 'Şirketin hiç parası yok.', + item_not_exist = 'Eşya mevcut değil.', too_heavy = 'Envanter çok dolu', duplicate_license = 'Çoğaltılan Rockstar lisans bulundu!', no_valid_license = 'Rockstar lisans bulunamadı.', From 403f2e666bc4298eb7cdcb65fdf100f2a0df94c0 Mon Sep 17 00:00:00 2001 From: efe <51517714+aw3rque@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:03:09 +0300 Subject: [PATCH 04/19] Update tr.lua --- locale/tr.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/tr.lua b/locale/tr.lua index 581b472..66be9e7 100644 --- a/locale/tr.lua +++ b/locale/tr.lua @@ -8,8 +8,8 @@ local Translations = { company_too_poor = 'Şirketin hiç parası yok.', item_not_exist = 'Eşya mevcut değil.', too_heavy = 'Envanter çok dolu', - duplicate_license = 'Çoğaltılan Rockstar lisans bulundu!', - no_valid_license = 'Rockstar lisans bulunamadı.', + duplicate_license = 'Aynı rockstar lisansı şu an sunucuda!', + no_valid_license = 'Geçerli rockstar lisans bulunamadı.', not_whitelisted = 'Bu sunucuda whitelistin yok.' }, success = {}, From e64437444eba658ecdea67d5950fa3d4a1670434 Mon Sep 17 00:00:00 2001 From: efe <51517714+aw3rque@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:10:04 +0300 Subject: [PATCH 05/19] Update tr.lua --- locale/tr.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/tr.lua b/locale/tr.lua index 66be9e7..51e50d7 100644 --- a/locale/tr.lua +++ b/locale/tr.lua @@ -8,20 +8,20 @@ local Translations = { company_too_poor = 'Şirketin hiç parası yok.', item_not_exist = 'Eşya mevcut değil.', too_heavy = 'Envanter çok dolu', - duplicate_license = 'Aynı rockstar lisansı şu an sunucuda!', - no_valid_license = 'Geçerli rockstar lisans bulunamadı.', + duplicate_license = 'Aynı rockstar lisansı zaten şu an sunucuda!', + no_valid_license = 'Geçerli bir rockstar lisans bulunamadı.', not_whitelisted = 'Bu sunucuda whitelistin yok.' }, success = {}, info = { - received_paycheck = 'Maaş çekinizi aldınız $%{value}', + received_paycheck = '$%{value} tutarında bir maaş çeki aldın.', job_info = 'İş: %{value} | Seviye: %{value2} | Görev: %{value3}', gang_info = 'Çete: %{value} | Seviye: %{value2}', - on_duty = 'Şimdi görev başındasın!', - off_duty = 'Şimdi görevden alındın!', + on_duty = 'Mesaiye girdin.', + off_duty = 'Mesaiden çıktın.', checking_ban = 'Merhaba %s. Banlı mısın diye kontrol ediyoruz.', join_server = 'Merhaba %s. {Server Name} adlı sunucumuza hoş geldin.', - checking_whitelisted = 'Merhaba %s. Giriş iznin var mı diye kontrol ediyoruz.' + checking_whitelisted = 'Merhaba %s. Whitelist\'in var mı diye kontrol ediyoruz.' } } From 7fab401ed239405bf86cf4cf28553045f0934bdc Mon Sep 17 00:00:00 2001 From: David Malchin Date: Mon, 18 Jul 2022 23:45:46 +0300 Subject: [PATCH 06/19] Fix Styling (#758) * style: ensure consistent indentation * style: add spacing * style: add newlines * style: simplify html * fix: update javascript indent size in contribution guidelines --- .github/contributing.md | 2 +- client/events.lua | 16 ++-- config.lua | 6 +- fxmanifest.lua | 50 +++++------ html/css/drawtext.css | 9 +- html/css/style.css | 12 +-- html/index.html | 44 ++-------- html/js/drawtext.js | 186 ++++++++++++++++++++-------------------- server/debug.lua | 4 +- server/events.lua | 28 +++--- server/exports.lua | 18 +++- server/functions.lua | 6 +- server/player.lua | 18 ++-- 13 files changed, 197 insertions(+), 202 deletions(-) diff --git a/.github/contributing.md b/.github/contributing.md index 21fb806..832c0c9 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -197,5 +197,5 @@ All lua code should be done using all the best practices of proper lua using the ### JavaScript Styleguide -- Use 4 Space indentation +- Use 2 Space indentation - Don't repeat yourself.. if you're using the same operations in many different places convert them into a function with flexible variables. diff --git a/client/events.lua b/client/events.lua index ec2ece8..aae8979 100644 --- a/client/events.lua +++ b/client/events.lua @@ -36,7 +36,7 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function() local blipMarker = GetFirstBlipInfoId(8) if not DoesBlipExist(blipMarker) then - QBCore.Functions.Notify('No Waypoint Set.', "error",5000) + QBCore.Functions.Notify('No Waypoint Set.', "error", 5000) return 'marker' end @@ -107,12 +107,12 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function() -- If we can't find the coords, set the coords to the old ones. -- We don't unpack them before since they aren't in a loop and only called once. SetPedCoordsKeepVehicle(ped, oldCoords['x'], oldCoords['y'], oldCoords['z'] - 1.0) - QBCore.Functions.Notify('Error While Teleporting.', "error",5000) + QBCore.Functions.Notify('Error While Teleporting.', "error", 5000) end -- If Z coord was found, set coords in found coords. SetPedCoordsKeepVehicle(ped, x, y, groundZ) - QBCore.Functions.Notify('Teleported To Waypoint.', "success",5000) + QBCore.Functions.Notify('Teleported To Waypoint.', "success", 5000) end) -- Vehicle Commands @@ -196,16 +196,16 @@ end) local function Draw3DText(coords, str) local onScreen, worldX, worldY = World3dToScreen2d(coords.x, coords.y, coords.z) - local camCoords = GetGameplayCamCoord() - local scale = 200 / (GetGameplayCamFov() * #(camCoords - coords)) + local camCoords = GetGameplayCamCoord() + local scale = 200 / (GetGameplayCamFov() * #(camCoords - coords)) if onScreen then SetTextScale(1.0, 0.5 * scale) SetTextFont(4) SetTextColour(255, 255, 255, 255) SetTextEdge(2, 0, 0, 0, 150) - SetTextProportional(1) - SetTextOutline() - SetTextCentre(1) + SetTextProportional(1) + SetTextOutline() + SetTextCentre(1) BeginTextCommandDisplayText("STRING") AddTextComponentSubstringPlayerName(str) EndTextCommandDisplayText(worldX, worldY) diff --git a/config.lua b/config.lua index 6941fe4..781b3db 100644 --- a/config.lua +++ b/config.lua @@ -6,8 +6,8 @@ QBConfig.UpdateInterval = 5 -- how often to update player data in minutes QBConfig.StatusInterval = 5000 -- how often to check hunger/thirst status in milliseconds QBConfig.Money = {} -QBConfig.Money.MoneyTypes = {['cash'] = 500, ['bank'] = 5000, ['crypto'] = 0} -- ['type'] = startamount - Add or remove money types for your server (for ex. ['blackmoney'] = 0), remember once added it will not be removed from the database! -QBConfig.Money.DontAllowMinus = {'cash', 'crypto'} -- Money that is not allowed going in minus +QBConfig.Money.MoneyTypes = { ['cash'] = 500, ['bank'] = 5000, ['crypto'] = 0 } -- ['type'] = startamount - Add or remove money types for your server (for ex. ['blackmoney'] = 0), remember once added it will not be removed from the database! +QBConfig.Money.DontAllowMinus = { 'cash', 'crypto' } -- Money that is not allowed going in minus QBConfig.Money.PayCheckTimeOut = 10 -- The time in minutes that it will give the paycheck QBConfig.Money.PayCheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management @@ -30,7 +30,7 @@ QBConfig.Server.WhitelistPermission = 'admin' -- Permission that's able to enter QBConfig.Server.PVP = true -- Enable or disable pvp on the server (Ability to shoot other players) QBConfig.Server.Discord = "" -- Discord invite link QBConfig.Server.CheckDuplicateLicense = true -- Check for duplicate rockstar license on join -QBConfig.Server.Permissions = {'god', 'admin', 'mod'} -- Add as many groups as you want here after creating them in your server.cfg +QBConfig.Server.Permissions = { 'god', 'admin', 'mod' } -- Add as many groups as you want here after creating them in your server.cfg QBConfig.Notify = {} diff --git a/fxmanifest.lua b/fxmanifest.lua index 21a8fde..0df4b92 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -5,43 +5,43 @@ description 'QB-Core' version '1.1.0' shared_scripts { - 'config.lua', + 'config.lua', 'shared/locale.lua', - 'locale/en.lua', -- replace with desired language - 'shared/main.lua', - 'shared/items.lua', - 'shared/jobs.lua', - 'shared/vehicles.lua', - 'shared/gangs.lua', - 'shared/weapons.lua' + 'locale/en.lua', -- replace with desired language + 'shared/main.lua', + 'shared/items.lua', + 'shared/jobs.lua', + 'shared/vehicles.lua', + 'shared/gangs.lua', + 'shared/weapons.lua' } client_scripts { - 'client/main.lua', - 'client/functions.lua', - 'client/loops.lua', - 'client/events.lua', - 'client/drawtext.lua' + 'client/main.lua', + 'client/functions.lua', + 'client/loops.lua', + 'client/events.lua', + 'client/drawtext.lua' } server_scripts { - '@oxmysql/lib/MySQL.lua', - 'server/main.lua', - 'server/functions.lua', - 'server/player.lua', - 'server/events.lua', - 'server/commands.lua', - 'server/exports.lua', - 'server/debug.lua' + '@oxmysql/lib/MySQL.lua', + 'server/main.lua', + 'server/functions.lua', + 'server/player.lua', + 'server/events.lua', + 'server/commands.lua', + 'server/exports.lua', + 'server/debug.lua' } ui_page 'html/index.html' files { - 'html/index.html', - 'html/css/style.css', - 'html/css/drawtext.css', - 'html/js/*.js' + 'html/index.html', + 'html/css/style.css', + 'html/css/drawtext.css', + 'html/js/*.js' } dependency 'oxmysql' diff --git a/html/css/drawtext.css b/html/css/drawtext.css index d4769a6..36832d5 100644 --- a/html/css/drawtext.css +++ b/html/css/drawtext.css @@ -1,4 +1,5 @@ @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;500&display=swap"); + :root { --primary-bg: rgba(23, 23, 23, 90%); --active-bg: #dc143c; @@ -15,6 +16,7 @@ font-family: "Poppins", sans-serif !important; font-weight: 300; } + .text { position: absolute; background: var(--primary-bg); @@ -47,11 +49,13 @@ left: 45vw; top: -100px; } + .top.show { transition: 0.5s; top: 10px; opacity: 1; } + .top.hide { transition: 0.5s; top: -100px; @@ -62,11 +66,13 @@ top: 50%; right: -100px; } + .right.show { transition: 0.5s; right: 10px; opacity: 1; } + .right.hide { transition: 0.5s; right: -100px; @@ -83,8 +89,9 @@ left: 10px; opacity: 1; } + .left.hide { transition: 0.5s; left: -100px; opacity: 0; -} +} \ No newline at end of file diff --git a/html/css/style.css b/html/css/style.css index 5842d7a..357b04e 100644 --- a/html/css/style.css +++ b/html/css/style.css @@ -10,7 +10,7 @@ html::-webkit-scrollbar { border-left: 0.5rem solid #20bb44; font-size: 1.5vh; } - + .primary { background-color: rgba(23, 23, 23, 90%); border-radius: 10px; @@ -18,7 +18,7 @@ html::-webkit-scrollbar { border-left: 5px solid #1c75d2; font-size: 1.5vh; } - + .error { background-color: rgba(23, 23, 23, 90%); border-radius: 10px; @@ -26,7 +26,7 @@ html::-webkit-scrollbar { border-left: 5px solid #c10114; font-size: 1.5vh; } - + .police { background-color: rgba(23, 23, 23, 90%); border-radius: 10px; @@ -34,7 +34,7 @@ html::-webkit-scrollbar { border-left: 5px solid #2197f2; font-size: 1.5vh; } - + .ambulance { background-color: rgba(23, 23, 23, 90%); border-radius: 10px; @@ -42,7 +42,7 @@ html::-webkit-scrollbar { border-left: 5px solid #f44236; font-size: 1.5vh; } - + } .success { @@ -78,4 +78,4 @@ html::-webkit-scrollbar { border-radius: 10px; box-shadow: 0rem 0rem 0.1rem 0.05rem #000000; border-left: 5px solid #f44236; -} +} \ No newline at end of file diff --git a/html/index.html b/html/index.html index a229080..ee1875f 100644 --- a/html/index.html +++ b/html/index.html @@ -1,46 +1,20 @@ - - - - - - - + + + + + + + -
+
- + \ No newline at end of file diff --git a/html/js/drawtext.js b/html/js/drawtext.js index 282d522..975d6e1 100644 --- a/html/js/drawtext.js +++ b/html/js/drawtext.js @@ -1,124 +1,124 @@ let direction = null; const drawText = async (textData) => { - const text = document.getElementById("text"); - let {position} = textData; - switch (textData.position) { - case "left": - addClass(text, position); - direction = "left"; - break; - case "top": - addClass(text, position); - direction = "top"; - break; - case "right": - addClass(text, position); - direction = "right"; - break; - default: - addClass(text, "left"); - direction = "left"; - break; - } + const text = document.getElementById("text"); + let {position} = textData; + switch (textData.position) { + case "left": + addClass(text, position); + direction = "left"; + break; + case "top": + addClass(text, position); + direction = "top"; + break; + case "right": + addClass(text, position); + direction = "right"; + break; + default: + addClass(text, "left"); + direction = "left"; + break; + } - text.innerHTML = textData.text; - document.getElementById("drawtext-container").style.display = "block"; - await sleep(100); - addClass(text, "show"); + text.innerHTML = textData.text; + document.getElementById("drawtext-container").style.display = "block"; + await sleep(100); + addClass(text, "show"); }; const changeText = async (textData) => { - const text = document.getElementById("text"); - let {position} = textData; + const text = document.getElementById("text"); + let {position} = textData; - removeClass(text, "show"); - addClass(text, "pressed"); - addClass(text, "hide"); + removeClass(text, "show"); + addClass(text, "pressed"); + addClass(text, "hide"); - await sleep(500); + await sleep(500); + removeClass(text, "left"); + removeClass(text, "right"); + removeClass(text, "top"); + removeClass(text, "bottom"); + removeClass(text, "hide"); + removeClass(text, "pressed"); + + switch (textData.position) { + case "left": + addClass(text, position); + direction = "left"; + break; + case "top": + addClass(text, position); + direction = "top"; + break; + case "right": + addClass(text, position); + direction = "right"; + break; + default: + addClass(text, "left"); + direction = "left"; + break; + } + text.innerHTML = textData.text; + + await sleep(100); + text.classList.add("show"); +}; + +const hideText = async () => { + const text = document.getElementById("text"); + removeClass(text, "show"); + addClass(text, "hide"); + + setTimeout(() => { removeClass(text, "left"); removeClass(text, "right"); removeClass(text, "top"); removeClass(text, "bottom"); removeClass(text, "hide"); removeClass(text, "pressed"); - - switch (textData.position) { - case "left": - addClass(text, position); - direction = "left"; - break; - case "top": - addClass(text, position); - direction = "top"; - break; - case "right": - addClass(text, position); - direction = "right"; - break; - default: - addClass(text, "left"); - direction = "left"; - break; - } - text.innerHTML = textData.text; - - await sleep(100); - text.classList.add("show"); -}; - -const hideText = async () => { - const text = document.getElementById("text"); - removeClass(text, "show"); - addClass(text, "hide"); - - setTimeout(() => { - removeClass(text, "left"); - removeClass(text, "right"); - removeClass(text, "top"); - removeClass(text, "bottom"); - removeClass(text, "hide"); - removeClass(text, "pressed"); - document.getElementById("drawtext-container").style.display = "none"; - }, 1000); + document.getElementById("drawtext-container").style.display = "none"; + }, 1000); }; const keyPressed = () => { - const text = document.getElementById("text"); - addClass(text, "pressed"); + const text = document.getElementById("text"); + addClass(text, "pressed"); }; window.addEventListener("message", (event) => { - const data = event.data; - const action = data.action; - const textData = data.data; - switch (action) { - case "DRAW_TEXT": - return drawText(textData); - case "CHANGE_TEXT": - return changeText(textData); - case "HIDE_TEXT": - return hideText(); - case "KEY_PRESSED": - return keyPressed(); - default: - return; - } + const data = event.data; + const action = data.action; + const textData = data.data; + switch (action) { + case "DRAW_TEXT": + return drawText(textData); + case "CHANGE_TEXT": + return changeText(textData); + case "HIDE_TEXT": + return hideText(); + case "KEY_PRESSED": + return keyPressed(); + default: + return; + } }); const sleep = (ms) => { - return new Promise((resolve) => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); }; const removeClass = (element, name) => { - if (element.classList.contains(name)) { - element.classList.remove(name); - } + if (element.classList.contains(name)) { + element.classList.remove(name); + } }; const addClass = (element, name) => { - if (!element.classList.contains(name)) { - element.classList.add(name); - } + if (!element.classList.contains(name)) { + element.classList.add(name); + } }; diff --git a/server/debug.lua b/server/debug.lua index 9b4b3b2..ecfba64 100644 --- a/server/debug.lua +++ b/server/debug.lua @@ -37,9 +37,9 @@ function QBCore.Debug(tbl, indent) end function QBCore.ShowError(resource, msg) - print('\x1b[31m['..resource..':ERROR]\x1b[0m '..msg) + print('\x1b[31m[' .. resource .. ':ERROR]\x1b[0m ' .. msg) end function QBCore.ShowSuccess(resource, msg) - print('\x1b[32m['..resource..':LOG]\x1b[0m '..msg) + print('\x1b[32m[' .. resource .. ':LOG]\x1b[0m ' .. msg) end diff --git a/server/events.lua b/server/events.lua index 9294c18..ee8adfa 100644 --- a/server/events.lua +++ b/server/events.lua @@ -216,31 +216,31 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am local Player = QBCore.Functions.GetPlayer(source) if not Player then return cb(false) end local isTable = type(items) == 'table' - local isArray = isTable and table.type(items) == 'array' or false - local totalItems = #items - local count = 0 + local isArray = isTable and table.type(items) == 'array' or false + local totalItems = #items + local count = 0 local kvIndex = 2 - if isTable and not isArray then + if isTable and not isArray then totalItems = 0 for _ in pairs(items) do totalItems += 1 end kvIndex = 1 end if isTable then - for k, v in pairs(items) do - local itemKV = {k, v} - local item = Player.Functions.GetItemByName(itemKV[kvIndex]) + for k, v in pairs(items) do + local itemKV = {k, v} + local item = Player.Functions.GetItemByName(itemKV[kvIndex]) if item and ((amount and item.amount >= amount) or (not amount and not isArray and item.amount >= v) or (not amount and isArray)) then count += 1 end - end - if count == totalItems then - retval = true - end - else -- Single item as string - local item = Player.Functions.GetItemByName(items) + end + if count == totalItems then + retval = true + end + else -- Single item as string + local item = Player.Functions.GetItemByName(items) if item and not amount or (item and amount and item.amount >= amount) then retval = true end - end + end cb(retval) end) diff --git a/server/exports.lua b/server/exports.lua index 521ebcf..f369d73 100644 --- a/server/exports.lua +++ b/server/exports.lua @@ -10,10 +10,11 @@ local function AddJob(jobName, job) QBCore.Shared.Jobs[jobName] = job - TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1,'Jobs', jobName, job) + TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Jobs', jobName, job) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.AddJob = AddJob exports('AddJob', AddJob) @@ -46,6 +47,7 @@ local function AddJobs(jobs) TriggerEvent('QBCore:Server:UpdateObject') return true, message, nil end + QBCore.Functions.AddJobs = AddJobs exports('AddJobs', AddJobs) @@ -65,6 +67,7 @@ local function RemoveJob(jobName) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.RemoveJob = RemoveJob exports('RemoveJob', RemoveJob) @@ -84,6 +87,7 @@ local function UpdateJob(jobName, job) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.UpdateJob = UpdateJob exports('UpdateJob', UpdateJob) @@ -103,6 +107,7 @@ local function AddItem(itemName, item) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.AddItem = AddItem exports('AddItem', AddItem) @@ -119,6 +124,7 @@ local function UpdateItem(itemName, item) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.UpdateItem = UpdateItem exports('UpdateItem', UpdateItem) @@ -151,6 +157,7 @@ local function AddItems(items) TriggerEvent('QBCore:Server:UpdateObject') return true, message, nil end + QBCore.Functions.AddItems = AddItems exports('AddItems', AddItems) @@ -170,6 +177,7 @@ local function RemoveItem(itemName) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.RemoveItem = RemoveItem exports('RemoveItem', RemoveItem) @@ -189,6 +197,7 @@ local function AddGang(gangName, gang) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.AddGang = AddGang exports('AddGang', AddGang) @@ -221,6 +230,7 @@ local function AddGangs(gangs) TriggerEvent('QBCore:Server:UpdateObject') return true, message, nil end + QBCore.Functions.AddGangs = AddGangs exports('AddGangs', AddGangs) @@ -240,6 +250,7 @@ local function RemoveGang(gangName) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.RemoveGang = RemoveGang exports('RemoveGang', RemoveGang) @@ -259,6 +270,7 @@ local function UpdateGang(gangName, gang) TriggerEvent('QBCore:Server:UpdateObject') return true, "success" end + QBCore.Functions.UpdateGang = UpdateGang exports('UpdateGang', UpdateGang) @@ -269,6 +281,7 @@ local function GetCoreVersion(InvokingResource) end return resourceVersion end + QBCore.Functions.GetCoreVersion = GetCoreVersion exports('GetCoreVersion', GetCoreVersion) @@ -284,6 +297,7 @@ local function ExploitBan(playerId, origin) 'Anti Cheat' }) DropPlayer(playerId, "You have been banned for cheating. Check our Discord for more information: " .. QBCore.Config.Server.Discord) - TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name.." has been banned for exploiting "..origin, true) + TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name .. " has been banned for exploiting " .. origin, true) end + exports('ExploitBan', ExploitBan) diff --git a/server/functions.lua b/server/functions.lua index fd42d2d..eb2097a 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -374,11 +374,11 @@ function QBCore.Functions.HasItem(source, items, amount) local Player = QBCore.Functions.GetPlayer(source) if not Player then return false end local isTable = type(items) == 'table' - local isArray = isTable and table.type(items) == 'array' or false - local totalItems = #items + local isArray = isTable and table.type(items) == 'array' or false + local totalItems = #items local count = 0 local kvIndex = 2 - if isTable and not isArray then + if isTable and not isArray then totalItems = 0 for _ in pairs(items) do totalItems += 1 end kvIndex = 1 diff --git a/server/player.lua b/server/player.lua index 2449574..bf3c8a1 100644 --- a/server/player.lua +++ b/server/player.lua @@ -600,19 +600,19 @@ function QBCore.Player.DeleteCharacter(source, citizenid) local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid }) if license == result then local query = "DELETE FROM %s WHERE citizenid = ?" - local tableCount = #playertables - local queries = table.create(tableCount, 0) + local tableCount = #playertables + local queries = table.create(tableCount, 0) - for i = 1, tableCount do - local v = playertables[i] - queries[i] = {query = query:format(v.table), values = { citizenid }} - end + for i = 1, tableCount do + local v = playertables[i] + queries[i] = {query = query:format(v.table), values = { citizenid }} + end MySQL.transaction(queries, function(result2) - if result2 then - TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..') + if result2 then + TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..') end - end) + end) else DropPlayer(source, 'You Have Been Kicked For Exploitation') TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', GetPlayerName(source) .. ' Has Been Dropped For Character Deletion Exploit', true) From 304654b340b75dc83736ad3dd393f897ac112575 Mon Sep 17 00:00:00 2001 From: nzkfc Date: Wed, 20 Jul 2022 20:49:39 +1200 Subject: [PATCH 07/19] Update vehicles.lua 'sportsclassic' to 'sportsclassics' (#759) * Update vehicles.lua * Update vehicles.lua --- shared/vehicles.lua | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/shared/vehicles.lua b/shared/vehicles.lua index 79e9afc..35eb213 100644 --- a/shared/vehicles.lua +++ b/shared/vehicles.lua @@ -1236,7 +1236,7 @@ QBShared.Vehicles = { ['brand'] = 'Vapid', ['model'] = 'peyote2', ['price'] = 40000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `peyote2`, ['shop'] = 'pdm', }, @@ -3095,7 +3095,7 @@ QBShared.Vehicles = { ['brand'] = 'Imponte', ['model'] = 'deluxo', ['price'] = 55000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `deluxo`, ['shop'] = 'pdm', }, @@ -3104,7 +3104,7 @@ QBShared.Vehicles = { ['brand'] = 'Weeny', ['model'] = 'dynasty', ['price'] = 25000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `dynasty`, ['shop'] = 'pdm', }, @@ -3149,7 +3149,7 @@ QBShared.Vehicles = { ['brand'] = 'Dewbauchee', ['model'] = 'jb700', ['price'] = 240000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `jb700`, ['shop'] = 'pdm', }, @@ -3158,7 +3158,7 @@ QBShared.Vehicles = { ['brand'] = 'Dewbauchee', ['model'] = 'jb7002', ['price'] = 40000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `jb7002`, ['shop'] = 'pdm', }, @@ -3194,7 +3194,7 @@ QBShared.Vehicles = { ['brand'] = 'Lampadati', ['model'] = 'michelli', ['price'] = 30000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `michelli`, ['shop'] = 'pdm', }, @@ -3212,7 +3212,7 @@ QBShared.Vehicles = { ['brand'] = 'Vulcar', ['model'] = 'nebula', ['price'] = 22000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `nebula`, ['shop'] = 'pdm', }, @@ -3221,7 +3221,7 @@ QBShared.Vehicles = { ['brand'] = 'Vapid', ['model'] = 'peyote', ['price'] = 23500, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `peyote`, ['shop'] = 'pdm', }, @@ -3230,7 +3230,7 @@ QBShared.Vehicles = { ['brand'] = 'Vapid', ['model'] = 'peyote3', ['price'] = 48000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `peyote3`, ['shop'] = 'pdm', }, @@ -3257,7 +3257,7 @@ QBShared.Vehicles = { ['brand'] = 'Vapid', ['model'] = 'retinue', ['price'] = 32000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `retinue`, ['shop'] = 'pdm', }, @@ -3266,7 +3266,7 @@ QBShared.Vehicles = { ['brand'] = 'Vapid', ['model'] = 'retinue2', ['price'] = 38000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `retinue2`, ['shop'] = 'pdm', }, @@ -3275,7 +3275,7 @@ QBShared.Vehicles = { ['brand'] = 'Annis', ['model'] = 'savestra', ['price'] = 67000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `savestra`, ['shop'] = 'pdm', }, @@ -3284,7 +3284,7 @@ QBShared.Vehicles = { ['brand'] = 'Grotti', ['model'] = 'stinger', ['price'] = 39500, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `stinger`, ['shop'] = 'pdm', }, @@ -3302,7 +3302,7 @@ QBShared.Vehicles = { ['brand'] = 'Ocelot', ['model'] = 'stromberg', ['price'] = 80000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `stromberg`, ['shop'] = 'pdm', }, @@ -3311,7 +3311,7 @@ QBShared.Vehicles = { ['brand'] = 'Ocelot', ['model'] = 'swinger', ['price'] = 221000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `swinger`, ['shop'] = 'pdm', }, @@ -3329,7 +3329,7 @@ QBShared.Vehicles = { ['brand'] = 'Declasse', ['model'] = 'tornado', ['price'] = 21000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `tornado`, ['shop'] = 'pdm', }, @@ -3338,7 +3338,7 @@ QBShared.Vehicles = { ['brand'] = 'Declasse', ['model'] = 'tornado2', ['price'] = 22000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `tornado2`, ['shop'] = 'pdm', }, @@ -3347,7 +3347,7 @@ QBShared.Vehicles = { ['brand'] = 'Declasse', ['model'] = 'tornado5', ['price'] = 22000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `tornado5`, ['shop'] = 'pdm', }, @@ -3356,7 +3356,7 @@ QBShared.Vehicles = { ['brand'] = 'Grotti', ['model'] = 'turismo2', ['price'] = 170000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `turismo2`, ['shop'] = 'pdm', }, @@ -3365,7 +3365,7 @@ QBShared.Vehicles = { ['brand'] = 'Lampadati', ['model'] = 'viseris', ['price'] = 210000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `viseris`, ['shop'] = 'pdm', }, @@ -3392,7 +3392,7 @@ QBShared.Vehicles = { ['brand'] = 'Übermacht', ['model'] = 'zion3', ['price'] = 45000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `zion3`, ['shop'] = 'pdm', }, @@ -3401,7 +3401,7 @@ QBShared.Vehicles = { ['brand'] = 'Rune', ['model'] = 'cheburek', ['price'] = 7000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `cheburek`, ['shop'] = 'pdm', }, @@ -3410,7 +3410,7 @@ QBShared.Vehicles = { ['brand'] = 'Pegassi', ['model'] = 'toreador', ['price'] = 50000, - ['category'] = 'sportsclassic', + ['category'] = 'sportsclassics', ['hash'] = `toreador`, ['shop'] = 'pdm', }, From 72223bd19670fb2284ee01704ae021a4749d1844 Mon Sep 17 00:00:00 2001 From: RadhwaneDZ <71345996+RadhwaneDZ@users.noreply.github.com> Date: Wed, 20 Jul 2022 15:17:38 +0100 Subject: [PATCH 08/19] Update ar.lua --- locale/ar.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/locale/ar.lua b/locale/ar.lua index 11b32af..d324072 100644 --- a/locale/ar.lua +++ b/locale/ar.lua @@ -7,7 +7,10 @@ local Translations = { no_access = 'لا يمكن الوصول إلى هذا الأمر', company_too_poor = 'مسؤول الوظيفة لا يمكلك مال كاف-ي', item_not_exist = 'عنصر غير موجود', - too_heavy = 'لا يوجد مساحة في جقيبتك' + too_heavy = 'لا يوجد مساحة في جقيبتك', + duplicate_license = 'وجدنا ترخيص روكستار مكرر او موجود مسبقا', + no_valid_license = 'ترخيص روكستار غير صحيح', + not_whitelisted = 'عضويتك غير مفعلة في هذا السيرفر' }, success = {}, info = { @@ -15,7 +18,10 @@ local Translations = { job_info = '%{value} | %{value2} | %{value3}', gang_info = '%{value} | %{value2}', on_duty = 'انت الان خارج الخدمة', - off_duty = 'انت الان في الخدمة' + off_duty = 'انت الان في الخدمة', + checking_ban = 'نحن نتحقق اذا كنت محجوب من السيرفر. %s مرحبا', + join_server = '{Server Name} قي %s مرحبا', + checking_whitelisted = 'نتحقق ما اذا كان مسموح لك بالدخول %s مرحبا ' } } From e41ba89f872a96acb013ea61d2419af64837e69c Mon Sep 17 00:00:00 2001 From: David Malchin Date: Sat, 16 Jul 2022 21:04:31 +0300 Subject: [PATCH 09/19] Update Russian locale --- locale/ru.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/locale/ru.lua b/locale/ru.lua index cd702d7..4fa5f34 100644 --- a/locale/ru.lua +++ b/locale/ru.lua @@ -2,20 +2,26 @@ local Translations = { error = { not_online = 'Игрок не в сети', wrong_format = 'Неверный формат', - missing_args = 'Введены не все аргументы (x, y, z)', + missing_args = 'Не все аргументы были заполнены (x, y, z)', missing_args2 = 'Все аргументы должны быть заполнены!', no_access = 'Нет доступа к этой команде', - company_too_poor = 'Ваш работодатель разорился', - item_not_exist = 'Элемент не существует', - too_heavy = 'Инвентарь слишком полон' + company_too_poor = 'Ваш работодатель без денег', + item_not_exist = 'Вещь не существует', + too_heavy = 'Инвентарь слишком полный', + duplicate_license = 'Найден дубликат лицензии Rockstar', + no_valid_license = 'Не найдена действующая лицензия Rockstar', + not_whitelisted = 'Вы не в белом списке этого сервера' }, success = {}, info = { received_paycheck = 'Вы получили зарплату в размере $%{value}', - job_info = 'Задание: %{значение} | Оценка: %{value2} | Обязанность: %{value3}', - gang_info = 'Банда: %{значение} | Оценка: %{value2}', + job_info = 'Задание: %{value} | Оценка: %{value2} | Дежурство: %{value3}', + gang_info = 'Банда: %{value} | Оценка: %{value2}', on_duty = 'Вы сейчас на дежурстве!', - off_duty = 'Вы сейчас не дежурный!' + off_duty = 'Вы сейчас не дежурный!', + checking_ban = 'Привет %s. Мы проверяем если вы забанены.', + join_server = 'Добро пожаловать %s в {Server Name}.', + checking_whitelisted = 'Привет %s. Мы проверяем если вы в белом списке.' } } From 215094281d5aa59fe5c6ad3ab00c72f4e76b2279 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Sat, 16 Jul 2022 21:04:37 +0300 Subject: [PATCH 10/19] Update Hebrew locale --- locale/he.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/locale/he.lua b/locale/he.lua index 5a983b2..da28017 100644 --- a/locale/he.lua +++ b/locale/he.lua @@ -2,20 +2,26 @@ local Translations = { error = { not_online = 'שחקן לא מחובר', wrong_format = 'פורמט שגוי', - missing_args = 'יש לכתוב את הפקודה לפי מה שכתוב (x, y, z)', - missing_args2 = 'יש למלא את כל המידע המבוקש', - no_access = 'אין לך גישה לפקודה זו', - company_too_poor = 'העסק שלך שבור', - item_not_exist = 'אייטם לא נמצא', - too_heavy = 'אינבנטורי מלא' + missing_args = '(x, y, z) לא כל פרמטר הוזן', + missing_args2 = '!יש להזין את כל הפרמטרים', + no_access = 'אין גישה לפקודה זו', + company_too_poor = 'המעסיק שלך עני מידי', + item_not_exist = 'פריט לא קיים', + too_heavy = 'אינבנטורי מלא', + duplicate_license = 'Rockstar נמצא שכפול רישיון', + no_valid_license = 'תקף Rockstar לא נמצא רישיון', + not_whitelisted = 'אתה לא ברשימת המותרים בשרת הזה' }, success = {}, info = { - received_paycheck = '$%{value} קיבלת משבורת על סך', + received_paycheck = '$%{value} קיבלת תלוש שכר על סך', job_info = '%{value3} :בתפקיד | %{value2} :דרגה | %{value} :עבודה', gang_info = '%{value2} :דרגה | %{value} :גאנג', - on_duty = 'אתה בתפקיד כעת', - off_duty = 'ירדת מתפקיד כעת' + on_duty = '!אתה עכשיו בתפקיד', + off_duty = '!ירדת מהתפקיד', + checking_ban = '.אנחנו בודקים אם אתה בבאן .%s שלום', + join_server = '.{Server Name}-ל %s ברוך הבא', + checking_whitelisted = '.אנחנו בודקים אם אתה ברשימת המותרים .%s שלום' } } From 9245a209c18a17a8ee542ce75ea1866dc2fdb782 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Thu, 21 Jul 2022 14:38:20 +0300 Subject: [PATCH 11/19] Update he.lua --- locale/he.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/he.lua b/locale/he.lua index da28017..fd0dc5b 100644 --- a/locale/he.lua +++ b/locale/he.lua @@ -10,18 +10,18 @@ local Translations = { too_heavy = 'אינבנטורי מלא', duplicate_license = 'Rockstar נמצא שכפול רישיון', no_valid_license = 'תקף Rockstar לא נמצא רישיון', - not_whitelisted = 'אתה לא ברשימת המותרים בשרת הזה' + not_whitelisted = 'אתם לא ברשימת המותרים בשרת הזה' }, success = {}, info = { received_paycheck = '$%{value} קיבלת תלוש שכר על סך', job_info = '%{value3} :בתפקיד | %{value2} :דרגה | %{value} :עבודה', gang_info = '%{value2} :דרגה | %{value} :גאנג', - on_duty = '!אתה עכשיו בתפקיד', + on_duty = '!אתם עכשיו בתפקיד', off_duty = '!ירדת מהתפקיד', - checking_ban = '.אנחנו בודקים אם אתה בבאן .%s שלום', - join_server = '.{Server Name}-ל %s ברוך הבא', - checking_whitelisted = '.אנחנו בודקים אם אתה ברשימת המותרים .%s שלום' + checking_ban = '.אנחנו בודקים אם אתם חסומים בשרת הזה .%s שלום', + join_server = '.{Server Name}-ל %s ברוכים הבאים', + checking_whitelisted = '.אנחנו בודקים אם אתם ברשימת המותרים .%s שלום' } } From cbed255874750d9dae7b211b51b56fa4467b6b2b Mon Sep 17 00:00:00 2001 From: David Malchin Date: Thu, 21 Jul 2022 15:10:08 +0300 Subject: [PATCH 12/19] Update he.lua --- locale/he.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/he.lua b/locale/he.lua index fd0dc5b..d31647e 100644 --- a/locale/he.lua +++ b/locale/he.lua @@ -10,18 +10,18 @@ local Translations = { too_heavy = 'אינבנטורי מלא', duplicate_license = 'Rockstar נמצא שכפול רישיון', no_valid_license = 'תקף Rockstar לא נמצא רישיון', - not_whitelisted = 'אתם לא ברשימת המותרים בשרת הזה' + not_whitelisted = 'את/ה לא ברשימת המותרים בשרת הזה' }, success = {}, info = { received_paycheck = '$%{value} קיבלת תלוש שכר על סך', job_info = '%{value3} :בתפקיד | %{value2} :דרגה | %{value} :עבודה', gang_info = '%{value2} :דרגה | %{value} :גאנג', - on_duty = '!אתם עכשיו בתפקיד', + on_duty = '!עלית בתפקיד', off_duty = '!ירדת מהתפקיד', - checking_ban = '.אנחנו בודקים אם אתם חסומים בשרת הזה .%s שלום', - join_server = '.{Server Name}-ל %s ברוכים הבאים', - checking_whitelisted = '.אנחנו בודקים אם אתם ברשימת המותרים .%s שלום' + checking_ban = '.אנחנו בודקים אם את/ה חסומ/ה בשרת הזה .%s שלום', + join_server = '.{Server Name}-ל %s ברוכ/ה הבא/ה', + checking_whitelisted = '.אנחנו בודקים אם את/ה ברשימת המותרים .%s שלום' } } From 770ea44530dd4f6cd69e7cb48664dfe39fcab3da Mon Sep 17 00:00:00 2001 From: David Malchin Date: Thu, 21 Jul 2022 15:11:16 +0300 Subject: [PATCH 13/19] Update he.lua --- locale/he.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/he.lua b/locale/he.lua index d31647e..619f650 100644 --- a/locale/he.lua +++ b/locale/he.lua @@ -17,7 +17,7 @@ local Translations = { received_paycheck = '$%{value} קיבלת תלוש שכר על סך', job_info = '%{value3} :בתפקיד | %{value2} :דרגה | %{value} :עבודה', gang_info = '%{value2} :דרגה | %{value} :גאנג', - on_duty = '!עלית בתפקיד', + on_duty = '!עלית לתפקיד', off_duty = '!ירדת מהתפקיד', checking_ban = '.אנחנו בודקים אם את/ה חסומ/ה בשרת הזה .%s שלום', join_server = '.{Server Name}-ל %s ברוכ/ה הבא/ה', From 8b5f5b2b378890030a354e951ddd2f80b6cbb069 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Fri, 22 Jul 2022 12:14:02 +0300 Subject: [PATCH 14/19] Fix styling, docs, and a possible bug (#762) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🎨 Fix spacing and indentation * 🎨 Use single quotes over backticks * 📝 Fix docs * 🐛 Make replace function clear and extend locales correctly * Revert "🎨 Use single quotes over backticks" * Update config.lua --- config.lua | 2 +- html/js/app.js | 1 - html/js/config.js | 4 ++-- shared/locale.lua | 11 +++++------ shared/main.lua | 40 ++++++++++++++++++++-------------------- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/config.lua b/config.lua index 781b3db..70db402 100644 --- a/config.lua +++ b/config.lua @@ -6,7 +6,7 @@ QBConfig.UpdateInterval = 5 -- how often to update player data in minutes QBConfig.StatusInterval = 5000 -- how often to check hunger/thirst status in milliseconds QBConfig.Money = {} -QBConfig.Money.MoneyTypes = { ['cash'] = 500, ['bank'] = 5000, ['crypto'] = 0 } -- ['type'] = startamount - Add or remove money types for your server (for ex. ['blackmoney'] = 0), remember once added it will not be removed from the database! +QBConfig.Money.MoneyTypes = { cash = 500, bank = 5000, crypto = 0 } -- type = startamount - Add or remove money types for your server (for ex. blackmoney = 0), remember once added it will not be removed from the database! QBConfig.Money.DontAllowMinus = { 'cash', 'crypto' } -- Money that is not allowed going in minus QBConfig.Money.PayCheckTimeOut = 10 -- The time in minutes that it will give the paycheck QBConfig.Money.PayCheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management diff --git a/html/js/app.js b/html/js/app.js index 50ff2fb..d13562e 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -8,7 +8,6 @@ import { } from "./config.js"; const { useQuasar } = Quasar; - const { onMounted, onUnmounted } = Vue; const app = Vue.createApp({ diff --git a/html/js/config.js b/html/js/config.js index d21352a..32fa978 100644 --- a/html/js/config.js +++ b/html/js/config.js @@ -13,13 +13,13 @@ export const DEV_MODE = false; * Will hold config statically outside of Vue state * @property {Record} VariantDefinitions * @property {Record} NotificationStyling - * */ + **/ export let NOTIFY_CONFIG = null; /** * Pure function taking a notification type and returning an object * with style details - * @param variant {string} + * @param {string} variant * @returns NotiVariantData **/ export const determineStyleFromVariant = (variant) => { diff --git a/shared/locale.lua b/shared/locale.lua index 6b9510b..c24376c 100644 --- a/shared/locale.lua +++ b/shared/locale.lua @@ -44,7 +44,7 @@ end --- internally for initial population of phrases field. --- @param phrases table - Table of phrase definitions --- @param prefix string | nil - Optional prefix used for recursive calls ---- @return void +--- @return nil function Locale:extend(phrases, prefix) for key, phrase in pairs(phrases) do local prefixKey = prefix and ('%s.%s'):format(prefix, key) or key @@ -57,10 +57,9 @@ function Locale:extend(phrases, prefix) end end - --- Clear locale instance phrases --- Might be useful for memory management of large phrase maps. ---- @return void +--- @return nil function Locale:clear() self.phrases = {} end @@ -69,8 +68,8 @@ end --- @param phrases table function Locale:replace(phrases) phrases = phrases or {} - self.clear() - self.extend(phrases) + self:clear() + self:extend(phrases) end --- Gets & Sets a locale depending on if an argument is passed @@ -85,7 +84,7 @@ end --- Primary translation method for a phrase of given key --- @param key string - The phrase key to target ---- @param subs table +--- @param subs table | nil --- @return string function Locale:t(key, subs) local phrase, result diff --git a/shared/main.lua b/shared/main.lua index 2319bc9..3eb8f61 100644 --- a/shared/main.lua +++ b/shared/main.lua @@ -3,9 +3,9 @@ QBShared = QBShared or {} local StringCharset = {} local NumberCharset = {} -for i = 48, 57 do NumberCharset[#NumberCharset+1] = string.char(i) end -for i = 65, 90 do StringCharset[#StringCharset+1] = string.char(i) end -for i = 97, 122 do StringCharset[#StringCharset+1] = string.char(i) end +for i = 48, 57 do NumberCharset[#NumberCharset + 1] = string.char(i) end +for i = 65, 90 do StringCharset[#StringCharset + 1] = string.char(i) end +for i = 97, 122 do StringCharset[#StringCharset + 1] = string.char(i) end function QBShared.RandomStr(length) if length <= 0 then return '' end @@ -22,16 +22,16 @@ function QBShared.SplitStr(str, delimiter) local from = 1 local delim_from, delim_to = string.find(str, delimiter, from) while delim_from do - result[#result+1] = string.sub(str, from, delim_from - 1) + result[#result + 1] = string.sub(str, from, delim_from - 1) from = delim_to + 1 delim_from, delim_to = string.find(str, delimiter, from) end - result[#result+1] = string.sub(str, from) + result[#result + 1] = string.sub(str, from) return result end function QBShared.Trim(value) - if not value then return nil end + if not value then return nil end return (string.gsub(value, '^%s*(.-)%s*$', '%1')) end @@ -42,24 +42,24 @@ function QBShared.Round(value, numDecimalPlaces) end function QBShared.ChangeVehicleExtra(vehicle, extra, enable) - if DoesExtraExist(vehicle, extra) then - if enable then - SetVehicleExtra(vehicle, extra, false) - if not IsVehicleExtraTurnedOn(vehicle, extra) then - QBShared.ChangeVehicleExtra(vehicle, extra, enable) - end - else - SetVehicleExtra(vehicle, extra, true) - if IsVehicleExtraTurnedOn(vehicle, extra) then - QBShared.ChangeVehicleExtra(vehicle, extra, enable) - end - end - end + if DoesExtraExist(vehicle, extra) then + if enable then + SetVehicleExtra(vehicle, extra, false) + if not IsVehicleExtraTurnedOn(vehicle, extra) then + QBShared.ChangeVehicleExtra(vehicle, extra, enable) + end + else + SetVehicleExtra(vehicle, extra, true) + if IsVehicleExtraTurnedOn(vehicle, extra) then + QBShared.ChangeVehicleExtra(vehicle, extra, enable) + end + end + end end function QBShared.SetDefaultVehicleExtras(vehicle, config) -- Clear Extras - for i = 1,20 do + for i = 1, 20 do if DoesExtraExist(vehicle, i) then SetVehicleExtra(vehicle, i, 1) end From 1b2915a75f8b19c9dd163e66b2960753b40d1568 Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Fri, 22 Jul 2022 22:59:01 -0500 Subject: [PATCH 15/19] Vehicle server-spawning functions/callback --- server/events.lua | 11 +++++++++++ server/functions.lua | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/server/events.lua b/server/events.lua index ee8adfa..151d40a 100644 --- a/server/events.lua +++ b/server/events.lua @@ -244,3 +244,14 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am end cb(retval) end) + +-- Vehicle server-side spawning callback (netId) +-- use the netid on the client with the NetworkGetEntityFromNetworkId native +-- convert it to a vehicle via the NetToVeh native +QBCore.Functions.CreateCallback('QBCore:Server:SpawnVehicle', function(source, cb, model, coords, warp) + if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end + local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, true) + while not DoesEntityExist(veh) do Wait(0) end + if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end + cb(NetworkGetNetworkIdFromEntity(veh)) +end) \ No newline at end of file diff --git a/server/functions.lua b/server/functions.lua index eb2097a..cca2f8e 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -167,6 +167,30 @@ function QBCore.Functions.GetEntitiesInBucket(bucket --[[ int ]]) end end +-- Server side vehicle creation with optional callback +-- the CreateVehicle RPC still uses the client for creation so players must be near +function QBCore.Functions.SpawnVehicle(model, cb, coords, warp) + model = type(model) == 'string' and GetHashKey(model) or model + if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end + local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, true) + while not DoesEntityExist(veh) do Wait(0) end + if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end + if cb then cb(veh) end +end + +-- Server side vehicle creation with optional callback +-- the CreateAutomobile native is still experimental but doesn't use client for creation +-- doesn't work for all vehicles! +function QBCore.Functions.CreateVehicle(model, cb, coords, warp) + model = type(model) == 'string' and GetHashKey(model) or model + if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end + local CreateAutomobile = GetHashKey("CREATE_AUTOMOBILE") + local veh = Citizen.InvokeNative(CreateAutomobile, model, coords, coords.w, true, true) + while not DoesEntityExist(veh) do Wait(0) end + if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end + if cb then cb(veh) end +end + -- Paychecks (standalone - don't touch) function PaycheckInterval() From 2b0e0c8edcfd1bb8f7fe4b1218e81f114fdf4ecc Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Sat, 23 Jul 2022 02:14:20 -0500 Subject: [PATCH 16/19] Model check --- server/events.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/events.lua b/server/events.lua index 151d40a..fff48ff 100644 --- a/server/events.lua +++ b/server/events.lua @@ -249,9 +249,10 @@ end) -- use the netid on the client with the NetworkGetEntityFromNetworkId native -- convert it to a vehicle via the NetToVeh native QBCore.Functions.CreateCallback('QBCore:Server:SpawnVehicle', function(source, cb, model, coords, warp) + model = type(model) == 'string' and GetHashKey(model) or model if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, true) while not DoesEntityExist(veh) do Wait(0) end if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end cb(NetworkGetNetworkIdFromEntity(veh)) -end) \ No newline at end of file +end) From 38ed80fed292243cacb40bbc5c2788be6468b221 Mon Sep 17 00:00:00 2001 From: NetOut <32980305+Maykellll1@users.noreply.github.com> Date: Sat, 23 Jul 2022 15:01:23 +0200 Subject: [PATCH 17/19] Fixed isnetworked (#764) With the above way, the condition was always true because (false or true) is true or (nil or true) is true. With this change it is fixed. --- client/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/functions.lua b/client/functions.lua index db572c3..6292a46 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -396,7 +396,7 @@ function QBCore.Functions.SpawnVehicle(model, cb, coords, isnetworked, teleportI else coords = GetEntityCoords(ped) end - isnetworked = isnetworked or true + isnetworked = isnetworked == nil or isnetworked QBCore.Functions.LoadModel(model) local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, isnetworked, false) local netid = NetworkGetNetworkIdFromEntity(veh) From 2120ce506d185868555cc25b50a56c5ce3156f19 Mon Sep 17 00:00:00 2001 From: SuperDaniel <56658457+TransitNode@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:10:56 +0100 Subject: [PATCH 18/19] Update loops.lua (#749) Correction of typographical error. Co-authored-by: BerkieBb <82737367+BerkieBb@users.noreply.github.com> --- client/loops.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/loops.lua b/client/loops.lua index 925e588..19b9c6d 100644 --- a/client/loops.lua +++ b/client/loops.lua @@ -15,8 +15,8 @@ CreateThread(function() if (QBCore.PlayerData.metadata['hunger'] <= 0 or QBCore.PlayerData.metadata['thirst'] <= 0) and not QBCore.PlayerData.metadata['isdead'] then local ped = PlayerPedId() local currentHealth = GetEntityHealth(ped) - local decreaseTreshold = math.random(5, 10) - SetEntityHealth(ped, currentHealth - decreaseTreshold) + local decreaseThreshold = math.random(5, 10) + SetEntityHealth(ped, currentHealth - decreaseThreshold) end end Wait(QBCore.Config.StatusInterval) From e22e9217fe830835cffff106a9ad6c0c8df4bfb5 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Sun, 24 Jul 2022 11:55:09 +0300 Subject: [PATCH 19/19] Update he.lua --- locale/he.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/he.lua b/locale/he.lua index 619f650..15943ca 100644 --- a/locale/he.lua +++ b/locale/he.lua @@ -19,8 +19,8 @@ local Translations = { gang_info = '%{value2} :דרגה | %{value} :גאנג', on_duty = '!עלית לתפקיד', off_duty = '!ירדת מהתפקיד', - checking_ban = '.אנחנו בודקים אם את/ה חסומ/ה בשרת הזה .%s שלום', - join_server = '.{Server Name}-ל %s ברוכ/ה הבא/ה', + checking_ban = '.אנחנו בודקים אם את/ה חסום/ה בשרת הזה .%s שלום', + join_server = '.{Server Name}-ל %s ברוך/ה הבא/ה', checking_whitelisted = '.אנחנו בודקים אם את/ה ברשימת המותרים .%s שלום' } }