From b156f5c658e476961c4aa123868980a59017b9ff Mon Sep 17 00:00:00 2001 From: Daniel GP Date: Mon, 15 May 2023 22:26:06 +0200 Subject: [PATCH 1/6] Add GetPlayerByLicense function --- server/functions.lua | 7 +++++++ server/player.lua | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/server/functions.lua b/server/functions.lua index 8b9e106..3c86faf 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -76,6 +76,13 @@ function QBCore.Functions.GetOfflinePlayerByCitizenId(citizenid) return QBCore.Player.GetOfflinePlayer(citizenid) end +---Get player by license +---@param license string +---@return table? +function QBCore.Functions.GetPlayerByLicense(license) + return QBCore.Player.GetPlayerByLicense(license) +end + ---Get player by phone number ---@param number number ---@return table? diff --git a/server/player.lua b/server/player.lua index 2c454c0..a8d1885 100644 --- a/server/player.lua +++ b/server/player.lua @@ -57,6 +57,27 @@ function QBCore.Player.GetOfflinePlayer(citizenid) return nil end +function QBCore.Player.GetPlayerByLicense(license) + if license then + local PlayerData = MySQL.Sync.prepare('SELECT * FROM players where license = ?', {license}) + if PlayerData then + PlayerData.money = json.decode(PlayerData.money) + PlayerData.job = json.decode(PlayerData.job) + PlayerData.position = json.decode(PlayerData.position) + PlayerData.metadata = json.decode(PlayerData.metadata) + PlayerData.charinfo = json.decode(PlayerData.charinfo) + if PlayerData.gang then + PlayerData.gang = json.decode(PlayerData.gang) + else + PlayerData.gang = {} + end + + return QBCore.Player.CheckPlayerData(nil, PlayerData) + end + end + return nil +end + function QBCore.Player.CheckPlayerData(source, PlayerData) PlayerData = PlayerData or {} local Offline = true From 4b1acec5d11f1bcce8e6e21ce201154665a6b768 Mon Sep 17 00:00:00 2001 From: Daniel GP <96537843+DaniGP17@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:23:00 +0200 Subject: [PATCH 2/6] Update query function --- server/player.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/player.lua b/server/player.lua index a8d1885..96ec738 100644 --- a/server/player.lua +++ b/server/player.lua @@ -59,7 +59,7 @@ end function QBCore.Player.GetPlayerByLicense(license) if license then - local PlayerData = MySQL.Sync.prepare('SELECT * FROM players where license = ?', {license}) + local PlayerData = MySQL.prepare.await('SELECT * FROM players where license = ?', {license}) if PlayerData then PlayerData.money = json.decode(PlayerData.money) PlayerData.job = json.decode(PlayerData.job) From 5998d92a9bd46626efc5acc702c38c1c32cb5d6a Mon Sep 17 00:00:00 2001 From: Daniel GP <96537843+DaniGP17@users.noreply.github.com> Date: Fri, 2 Jun 2023 22:09:52 +0200 Subject: [PATCH 3/6] Fix bad implemention with SQL Function --- server/player.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/player.lua b/server/player.lua index 96ec738..cff52e9 100644 --- a/server/player.lua +++ b/server/player.lua @@ -38,7 +38,7 @@ end function QBCore.Player.GetOfflinePlayer(citizenid) if citizenid then - local PlayerData = MySQL.Sync.prepare('SELECT * FROM players where citizenid = ?', {citizenid}) + local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', {citizenid}) if PlayerData then PlayerData.money = json.decode(PlayerData.money) PlayerData.job = json.decode(PlayerData.job) From 1769fbe8b01532d544093f00a6e9460797df7a4d Mon Sep 17 00:00:00 2001 From: Cocodrulo <142546774+Cocodrulo@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:49:08 +0100 Subject: [PATCH 4/6] Update player.lua A more comprehensive way of notifying a player and checking if a player has items from the server side. --- server/player.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/player.lua b/server/player.lua index 2c454c0..f9b133b 100644 --- a/server/player.lua +++ b/server/player.lua @@ -249,6 +249,14 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline) return true end + function self.Functions.Notify(text, type, lenght) + TriggerClientEvent('QBCore:Notify', self.PlayerData.source, text, type, lenght) + end + + function self.Functions.HasItem(items, amount) + QBCore.Functions.HasItem(self.PlayerData.source, items, amount) + end + function self.Functions.SetJobDuty(onDuty) self.PlayerData.job.onduty = not not onDuty -- Make sure the value is a boolean if nil is sent TriggerEvent('QBCore:Server:OnJobUpdate', self.PlayerData.source, self.PlayerData.job) From 01ccf06c3a6a927a875a3ca6269aa0e4b80ac129 Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Sat, 23 Sep 2023 15:09:33 -0500 Subject: [PATCH 5/6] Create stale.yml --- .github/workflows/stale.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..c18b212 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,29 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '41 15 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue has had 60 days of inactivity & will close within 7 days' + stale-pr-message: 'This PR has had 60 days of inactivity & will close within 7 days' + close-issue-label: 'Stale Closed' + close-pr-label: 'Stale Closed' + exempt-issue-labels: 'Suggestion' + exempt-pr-labels: 'Suggestion' From 7314e8453f5ad15eaf26b3b43b24e1aa6cb3adc8 Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Sat, 23 Sep 2023 15:35:54 -0500 Subject: [PATCH 6/6] Natives --- client/functions.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 7ec0bad..edba745 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -23,9 +23,9 @@ function QBCore.Functions.DrawText(x, y, width, height, scale, r, g, b, a, text) SetTextFont(4) SetTextScale(scale, scale) SetTextColour(r, g, b, a) - SetTextEntry('STRING') - AddTextComponentString(text) - DrawText(x - width / 2, y - height / 2 + 0.005) + BeginTextCommandDisplayText('STRING') + AddTextComponentSubstringPlayerName(text) + EndTextCommandDisplayText(x - width / 2, y - height / 2 + 0.005) end function QBCore.Functions.DrawText3D(x, y, z, text) @@ -34,11 +34,11 @@ function QBCore.Functions.DrawText3D(x, y, z, text) SetTextFont(4) SetTextProportional(1) SetTextColour(255, 255, 255, 215) - SetTextEntry('STRING') + BeginTextCommandDisplayText('STRING') SetTextCentre(true) - AddTextComponentString(text) + AddTextComponentSubstringPlayerName(text) SetDrawOrigin(x, y, z, 0) - DrawText(0.0, 0.0) + EndTextCommandDisplayText(0.0, 0.0) local factor = (string.len(text)) / 370 DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75) ClearDrawOrigin()