From 84d8006817c5217e88b579c7885feff00ae2ee85 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:40:38 +0200 Subject: [PATCH 01/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 46 ++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index c2e6153e9..b3d46a2c2 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -1,7 +1,39 @@ -- uses: actions/checkout@v4 -- uses: JohnnyMorganz/stylua-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes - # CLI arguments - args: --check . \ No newline at end of file +name: formatter-all + +on: + push: + branches: [ main, dev ] + pull_request: + types: [ labeled ] + +jobs: + formatter: + name: formatter + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + - name: Install stylua and format files + uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: v0.18.0 + args: -- . + - name: Format files with Prettier + run: | + npx prettier --write '**/*.{ts,js,css,html}' + - name: Update repo before push + run: | + git pull + - name: Commit changes and push current branch + uses: stefanzweifel/git-auto-commit-action@v4 \ No newline at end of file From e904135514c15d05d42203acc2c034974afffa0b Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:45:42 +0200 Subject: [PATCH 02/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index b3d46a2c2..8116e16a9 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -29,9 +29,6 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} version: v0.18.0 args: -- . - - name: Format files with Prettier - run: | - npx prettier --write '**/*.{ts,js,css,html}' - name: Update repo before push run: | git pull From 30e43f7b78200ade971de34728035d91653ca73d Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:51:30 +0200 Subject: [PATCH 03/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 35 +++++------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 8116e16a9..464fc0b8f 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -6,31 +6,10 @@ on: pull_request: types: [ labeled ] -jobs: - formatter: - name: formatter - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: "16" - - name: Install stylua and format files - uses: JohnnyMorganz/stylua-action@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: v0.18.0 - args: -- . - - name: Update repo before push - run: | - git pull - - name: Commit changes and push current branch - uses: stefanzweifel/git-auto-commit-action@v4 \ No newline at end of file +- uses: actions/checkout@v3 +- uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes + # CLI arguments + args: --check . \ No newline at end of file From e3e640d4f3b35f5c38145c297b7c7b7d38f70d82 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:54:54 +0200 Subject: [PATCH 04/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 464fc0b8f..62e892be5 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -6,10 +6,12 @@ on: pull_request: types: [ labeled ] -- uses: actions/checkout@v3 -- uses: JohnnyMorganz/stylua-action@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes - # CLI arguments - args: --check . \ No newline at end of file + stylua-check: + name: Stylua Check + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} + steps: + - uses: actions/checkout@v3 + - uses: JohnnyMorganz/stylua-action@v3 \ No newline at end of file From 1420a5993a016636ef8485983bb2618c40249793 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:59:07 +0200 Subject: [PATCH 05/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 62e892be5..f9ec45b80 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -6,8 +6,9 @@ on: pull_request: types: [ labeled ] - stylua-check: - name: Stylua Check +jobs: + formatter: + name: formatter runs-on: ubuntu-latest permissions: contents: write From 0d0d13e9119d8109caf81e52a32d9a7acd3037d6 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:01:30 +0200 Subject: [PATCH 06/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index f9ec45b80..179974266 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -15,4 +15,11 @@ jobs: if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} steps: - uses: actions/checkout@v3 - - uses: JohnnyMorganz/stylua-action@v3 \ No newline at end of file + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + - name: Install stylua and format files + uses: JohnnyMorganz/stylua-action@v3 \ No newline at end of file From 7e7fbc647d78f706e82a7b91739dcfb3fccb65a1 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:03:30 +0200 Subject: [PATCH 07/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 179974266..f16ae036c 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -22,4 +22,5 @@ jobs: with: node-version: "16" - name: Install stylua and format files - uses: JohnnyMorganz/stylua-action@v3 \ No newline at end of file + uses: JohnnyMorganz/stylua-action@v3 + version: v0.18.0 \ No newline at end of file From ad046799b482b4c653318882e8a59735360158c5 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:04:57 +0200 Subject: [PATCH 08/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index f16ae036c..3cf8e4642 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -23,4 +23,7 @@ jobs: node-version: "16" - name: Install stylua and format files uses: JohnnyMorganz/stylua-action@v3 - version: v0.18.0 \ No newline at end of file + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: v0.18.0 + args: -- . \ No newline at end of file From 594f37f5f5836985d649cc3ef3abeac7ecc50b1a Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:09:06 +0200 Subject: [PATCH 09/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 3cf8e4642..bd9ecd08e 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -13,6 +13,8 @@ jobs: permissions: contents: write if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 with: @@ -26,4 +28,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} version: v0.18.0 - args: -- . \ No newline at end of file + args: -- . \ No newline at end of file From 1b50135d1093b154939ee95bf0c07f515df4162a Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:10:29 +0200 Subject: [PATCH 10/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index bd9ecd08e..87f6f8da7 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -22,7 +22,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: Install stylua and format files uses: JohnnyMorganz/stylua-action@v3 with: From 19a3b33bf32cd9f0cc498982a6370fefb4033eeb Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:14:02 +0200 Subject: [PATCH 11/16] Update StyLuaGitHubAction.yml --- .github/workflows/StyLuaGitHubAction.yml | 32 +++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/StyLuaGitHubAction.yml b/.github/workflows/StyLuaGitHubAction.yml index 87f6f8da7..b84756c0c 100644 --- a/.github/workflows/StyLuaGitHubAction.yml +++ b/.github/workflows/StyLuaGitHubAction.yml @@ -1,31 +1,23 @@ -name: formatter-all - +# Check Lua Formatting +name: Check Lua Formatting on: - push: - branches: [ main, dev ] - pull_request: - types: [ labeled ] + push: + branches: [ main, dev ] + pull_request: + types: [ labeled ] jobs: - formatter: - name: formatter + stylua-check: + name: Stylua Check runs-on: ubuntu-latest permissions: contents: write if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: "18" - - name: Install stylua and format files - uses: JohnnyMorganz/stylua-action@v3 + - uses: actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@v3 with: token: ${{ secrets.GITHUB_TOKEN }} version: v0.18.0 - args: -- . \ No newline at end of file + # CLI arguments + args: --check . \ No newline at end of file From 15b9ff879e02defe9d2d024d5d00c69f8b364d7a Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:36:33 +0200 Subject: [PATCH 12/16] =?UTF-8?q?chore:=20bpt=5Fbanking=20=F0=9F=8E=A8=20R?= =?UTF-8?q?un=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[bpt_addons]/bpt_banking/client/main.lua | 92 +++++++------- .../[bpt_addons]/bpt_banking/config.lua | 70 +++++------ .../[bpt_addons]/bpt_banking/fxmanifest.lua | 46 +++---- .../[bpt_addons]/bpt_banking/locales/en.lua | 30 ++--- .../[bpt_addons]/bpt_banking/locales/it.lua | 30 ++--- .../[bpt_addons]/bpt_banking/server/main.lua | 114 ++++++++++-------- 6 files changed, 199 insertions(+), 183 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_banking/client/main.lua b/server-data/resources/[bpt_addons]/bpt_banking/client/main.lua index 11751d25a..ecd3d0951 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/client/main.lua @@ -1,5 +1,5 @@ local BANK = { - Data = {} + Data = {}, } local activeBlips, bankPoints, atmPoints, markerPoints = {}, {}, {}, {} @@ -22,8 +22,7 @@ function BANK:Thread() if (IsPedOnFoot(data.ped) and not ESX.PlayerData.dead) and not inMenu then for i = 1, #Config.AtmModels do - local atm = GetClosestObjectOfType(data.coord.x, data.coord.y, data.coord.z, 0.7, Config.AtmModels - [i], false, false, false) + local atm = GetClosestObjectOfType(data.coord.x, data.coord.y, data.coord.z, 0.7, Config.AtmModels[i], false, false, false) if atm ~= 0 then atmPoints[#atmPoints + 1] = GetEntityCoords(atm) end @@ -56,15 +55,16 @@ function BANK:Thread() end end) - if not Config.ShowMarker then return end + if not Config.ShowMarker then + return + end CreateThread(function() local wait = 1000 while playerLoaded do if next(markerPoints) then for i = 1, #markerPoints do - DrawMarker(20, markerPoints[i].x, markerPoints[i].y, markerPoints[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.3, 0.2, 0.2, 187, 255, 0, 255, false, true, 2, false, nil, nil, false) + DrawMarker(20, markerPoints[i].x, markerPoints[i].y, markerPoints[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.2, 187, 255, 0, 255, false, true, 2, false, nil, nil, false) end wait = 0 end @@ -79,7 +79,7 @@ function BANK:TextUi(state, atm) if not state then return ESX.HideUI() end - ESX.TextUI(TranslateCap('press_e_banking')) + ESX.TextUI(TranslateCap("press_e_banking")) CreateThread(function() while uiActive do if IsControlJustReleased(0, 38) then @@ -95,7 +95,7 @@ end function BANK:CreateBlips() local tmpActiveBlips = {} for i = 1, #Config.Banks do - if type(Config.Banks[i].Blip) == 'table' and Config.Banks[i].Blip.Enabled then + if type(Config.Banks[i].Blip) == "table" and Config.Banks[i].Blip.Enabled then local position = Config.Banks[i].Position local bInfo = Config.Banks[i].Blip local blip = AddBlipForCoord(position.x, position.y, position.z) @@ -103,7 +103,7 @@ function BANK:CreateBlips() SetBlipScale(blip, bInfo.Scale) SetBlipColour(blip, bInfo.Color) SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName('STRING') + BeginTextCommandSetBlipName("STRING") AddTextComponentSubstringPlayerName(bInfo.Label) EndTextCommandSetBlipName(blip) tmpActiveBlips[#tmpActiveBlips + 1] = blip @@ -131,11 +131,11 @@ function BANK:HandleUi(state, atm) ClearPedTasks(PlayerPedId()) if not state then SendNUIMessage({ - showMenu = false + showMenu = false, }) return end - ESX.TriggerServerCallback('bpt_banking:getPlayerData', function(data) + ESX.TriggerServerCallback("bpt_banking:getPlayerData", function(data) SendNUIMessage({ showMenu = true, openATM = atm, @@ -143,20 +143,20 @@ function BANK:HandleUi(state, atm) your_money_panel = { accountsData = { { name = "cash", - amount = data.money + amount = data.money, }, { name = "bank", - amount = data.bankMoney - } } + amount = data.bankMoney, + } }, }, bankCardData = { - bankName = TranslateCap('bank_name'), + bankName = TranslateCap("bank_name"), cardNumber = "2232 2222 2222 2222", createdDate = "08/08", - name = data.playerName + name = data.playerName, }, - transactionsData = data.transactionHistory - } + transactionsData = data.transactionHistory, + }, }) end) end @@ -179,84 +179,92 @@ function BANK:LoadNpc(index, netID) end -- Events -RegisterNetEvent('bpt_banking:closebanking', function() +RegisterNetEvent("bpt_banking:closebanking", function() BANK:HandleUi(false) end) -RegisterNetEvent('bpt_banking:pedHandler', function(netIdTable) +RegisterNetEvent("bpt_banking:pedHandler", function(netIdTable) for i = 1, #netIdTable do BANK:LoadNpc(i, netIdTable[i]) end end) -RegisterNetEvent('bpt_banking:updateMoneyInUI', function(doingType, bankMoney, money) +RegisterNetEvent("bpt_banking:updateMoneyInUI", function(doingType, bankMoney, money) SendNUIMessage({ updateData = true, data = { type = doingType, bankMoney = bankMoney, - money = money - } + money = money, + }, }) end) -- Handlers -- Resource starting -AddEventHandler('onResourceStart', function(resource) - if resource ~= GetCurrentResourceName() then return end +AddEventHandler("onResourceStart", function(resource) + if resource ~= GetCurrentResourceName() then + return + end BANK:Thread() end) -- Enable the script on player loaded -RegisterNetEvent('esx:playerLoaded', function() +RegisterNetEvent("esx:playerLoaded", function() BANK:Thread() end) -- Disable the script on player logout -RegisterNetEvent('esx:onPlayerLogout', function() +RegisterNetEvent("esx:onPlayerLogout", function() playerLoaded = false end) -- Resource stopping -AddEventHandler('onResourceStop', function(resource) - if resource ~= GetCurrentResourceName() then return end +AddEventHandler("onResourceStop", function(resource) + if resource ~= GetCurrentResourceName() then + return + end BANK:RemoveBlips() - if uiActive then BANK:TextUi(false) end + if uiActive then + BANK:TextUi(false) + end end) -RegisterNetEvent('esx:onPlayerDeath', function() BANK:TextUi(false) end) +RegisterNetEvent("esx:onPlayerDeath", function() + BANK:TextUi(false) +end) -- Nui Callbacks -RegisterNUICallback('close', function(data, cb) +RegisterNUICallback("close", function(data, cb) BANK:HandleUi(false) - cb('ok') + cb("ok") end) -RegisterNUICallback('clickButton', function(data, cb) +RegisterNUICallback("clickButton", function(data, cb) if not data or not inMenu then - return cb('ok') + return cb("ok") end TriggerServerEvent("bpt_banking:doingType", data) - cb('ok') + cb("ok") end) -RegisterNUICallback('checkPincode', function(data, cb) +RegisterNUICallback("checkPincode", function(data, cb) if not data or not inMenu then - return cb('ok') + return cb("ok") end ESX.TriggerServerCallback("bpt_banking:checkPincode", function(pincode) if pincode then cb({ - success = true + success = true, }) - ESX.ShowNotification(TranslateCap('pincode_found'), "success") + ESX.ShowNotification(TranslateCap("pincode_found"), "success") else cb({ - error = true + error = true, }) - ESX.ShowNotification(TranslateCap('pincode_not_found'), "error") + ESX.ShowNotification(TranslateCap("pincode_not_found"), "error") end end, data) end) diff --git a/server-data/resources/[bpt_addons]/bpt_banking/config.lua b/server-data/resources/[bpt_addons]/bpt_banking/config.lua index e76e47f3c..f405106b1 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/config.lua @@ -1,7 +1,7 @@ Config = { Debug = false, DrawMarker = 10, - Locale = GetConvar('esx:locale', 'en'), + Locale = GetConvar("esx:locale", "en"), EnablePeds = true, AtmModels = { `prop_fleeca_atm`, `prop_atm_01`, `prop_atm_02`, `prop_atm_03` }, Banks = { @@ -10,122 +10,122 @@ Config = { Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(-1212.63, -330.78, 37.59, 210), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(-2962.47, 482.93, 15.5, 270), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(-113.01, 6470.24, 31.43, 315), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(314.16, -279.09, 53.97, 160), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(-350.99, -49.99, 48.84, 160), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(1175.02, 2706.87, 37.89, 0), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, { Position = vector4(246.63, 223.62, 106.0, 160), Blip = { Enabled = true, Color = 69, - Label = 'Bank', + Label = "Bank", Sprite = 108, - Scale = 0.7 - } + Scale = 0.7, + }, }, }, Peds = { { Position = vector4(149.5513, -1042.1570, 29.3680, 341.6520), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(-1211.8585, -331.9854, 37.7809, 28.5983), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(-2961.0720, 483.1107, 15.6970, 88.1986), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(-112.2223, 6471.1128, 31.6267, 132.7517), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(313.8176, -280.5338, 54.1647, 339.1609), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(-351.3247, -51.3466, 49.0365, 339.3305), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(1174.9718, 2708.2034, 38.0879, 178.2974), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' + Scenario = "WORLD_HUMAN_CLIPBOARD", }, { Position = vector4(247.0348, 225.1851, 106.2875, 158.7528), Model = `U_M_M_BankMan`, - Scenario = 'WORLD_HUMAN_CLIPBOARD' - } - } + Scenario = "WORLD_HUMAN_CLIPBOARD", + }, + }, } diff --git a/server-data/resources/[bpt_addons]/bpt_banking/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_banking/fxmanifest.lua index aa1ac1d34..805a8539b 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/fxmanifest.lua @@ -1,31 +1,31 @@ -fx_version 'cerulean' +fx_version("cerulean") -game 'gta5' +game("gta5") -description 'A banking system that adds interactable banks and ATMs' -lua54 'yes' -version '1.0.1' +description("A banking system that adds interactable banks and ATMs") +lua54("yes") +version("1.0.1") -shared_scripts { - '@es_extended/imports.lua', - '@es_extended/locale.lua', - 'locales/*.lua', - 'config.lua' -} +shared_scripts({ + "@es_extended/imports.lua", + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", +}) -server_scripts { - '@oxmysql/lib/MySQL.lua', - 'server/main.lua' -} +server_scripts({ + "@oxmysql/lib/MySQL.lua", + "server/main.lua", +}) -client_scripts { - 'client/main.lua' -} +client_scripts({ + "client/main.lua", +}) -ui_page 'html/ui.html' +ui_page("html/ui.html") -files { - 'html/**', -} +files({ + "html/**", +}) -dependency 'es_extended' +dependency("es_extended") diff --git a/server-data/resources/[bpt_addons]/bpt_banking/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_banking/locales/en.lua index 2a9d97e6f..1566d284c 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/locales/en.lua @@ -1,16 +1,16 @@ -Locales['en'] = { - ['invalid_amount'] = 'That\'s an invalid amount of money', - ['deposit_money'] = 'you have deposited $%s', - ['withdraw_money'] = 'you have withdrawn $%s', - ['pincode_money'] = 'you have new pincode %s', - ['transfer_money'] = 'you success transfer money $%s ID: %s', - ['receive_transfer'] = 'you receive transfer money $%s ID: %s', - ['press_e_banking'] = 'press [E] to access the bank', - ['access_bank'] = 'Access the bank', - ['banking_blip'] = 'Bank', - ['cant_do_it'] = "Can't do it!", - ['not_enough_money'] = "Not enough money! You need %s money!", - ['pincode_not_found'] = "Invalid PIN code", - ['pincode_found'] = "Valid PIN code...", - ['bank_name'] = "Fleeca Bank" +Locales["en"] = { + ["invalid_amount"] = "That's an invalid amount of money", + ["deposit_money"] = "you have deposited $%s", + ["withdraw_money"] = "you have withdrawn $%s", + ["pincode_money"] = "you have new pincode %s", + ["transfer_money"] = "you success transfer money $%s ID: %s", + ["receive_transfer"] = "you receive transfer money $%s ID: %s", + ["press_e_banking"] = "press [E] to access the bank", + ["access_bank"] = "Access the bank", + ["banking_blip"] = "Bank", + ["cant_do_it"] = "Can't do it!", + ["not_enough_money"] = "Not enough money! You need %s money!", + ["pincode_not_found"] = "Invalid PIN code", + ["pincode_found"] = "Valid PIN code...", + ["bank_name"] = "Fleeca Bank", } diff --git a/server-data/resources/[bpt_addons]/bpt_banking/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_banking/locales/it.lua index 8f4662ee7..f1beae28b 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/locales/it.lua @@ -1,16 +1,16 @@ -Locales['it'] = { - ['invalid_amount'] = 'questa è una somma di denaro non valida', - ['deposit_money'] = 'hai depositato $%s', - ['withdraw_money'] = 'hai prelevato $%s', - ['pincode_money'] = 'hai un nuovo codice pin %s', - ['transfer_money'] = 'hai trasferito con successo il denaro a $%s ID: %s', - ['receive_transfer'] = 'hai ricevuto un trasferimento di denaro da $%s ID: %s', - ['press_e_banking'] = 'premi [E] per accedere alla banca', - ['access_bank'] = 'accedi alla banca', - ['banking_blip'] = 'Banca', - ['cant_do_it'] = "non puoi farlo!", - ['not_enough_money'] = "non hai abbastanza soldi! hai bisogno di %s soldi!", - ['pincode_not_found'] = "codice PIN errato", - ['pincode_found'] = "codice PIN valido...", - ['bank_name'] = "Banca Fleeca", +Locales["it"] = { + ["invalid_amount"] = "questa è una somma di denaro non valida", + ["deposit_money"] = "hai depositato $%s", + ["withdraw_money"] = "hai prelevato $%s", + ["pincode_money"] = "hai un nuovo codice pin %s", + ["transfer_money"] = "hai trasferito con successo il denaro a $%s ID: %s", + ["receive_transfer"] = "hai ricevuto un trasferimento di denaro da $%s ID: %s", + ["press_e_banking"] = "premi [E] per accedere alla banca", + ["access_bank"] = "accedi alla banca", + ["banking_blip"] = "Banca", + ["cant_do_it"] = "non puoi farlo!", + ["not_enough_money"] = "non hai abbastanza soldi! hai bisogno di %s soldi!", + ["pincode_not_found"] = "codice PIN errato", + ["pincode_found"] = "codice PIN valido...", + ["bank_name"] = "Banca Fleeca", } diff --git a/server-data/resources/[bpt_addons]/bpt_banking/server/main.lua b/server-data/resources/[bpt_addons]/bpt_banking/server/main.lua index 8e276eed3..f0fa5cf51 100644 --- a/server-data/resources/[bpt_addons]/bpt_banking/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_banking/server/main.lua @@ -10,35 +10,47 @@ local function get_key(t) end -- Resource starting -AddEventHandler('onResourceStart', function(resourceName) - if (GetCurrentResourceName() ~= resourceName) then return end - if Config.EnablePeds then BANK.CreatePeds() end +AddEventHandler("onResourceStart", function(resourceName) + if GetCurrentResourceName() ~= resourceName then + return + end + if Config.EnablePeds then + BANK.CreatePeds() + end local twoMonthMs = (os.time() - 5259487) * 1000 - MySQL.Sync.fetchScalar('DELETE FROM banking WHERE time < ? ', { twoMonthMs }) + MySQL.Sync.fetchScalar("DELETE FROM banking WHERE time < ? ", { twoMonthMs }) end) -AddEventHandler('onResourceStop', function(resourceName) - if (GetCurrentResourceName() ~= resourceName) then return end - if Config.EnablePeds then BANK.DeletePeds() end +AddEventHandler("onResourceStop", function(resourceName) + if GetCurrentResourceName() ~= resourceName then + return + end + if Config.EnablePeds then + BANK.DeletePeds() + end end) if Config.EnablePeds then - AddEventHandler('esx:playerLoaded', function(playerId) - TriggerClientEvent('bpt_banking:pedHandler', playerId, netIdTable) + AddEventHandler("esx:playerLoaded", function(playerId) + TriggerClientEvent("bpt_banking:pedHandler", playerId, netIdTable) end) end -- event -RegisterServerEvent('bpt_banking:doingType') -AddEventHandler('bpt_banking:doingType', function(typeData) - if source == nil then return end - if (typeData == nil) then return end +RegisterServerEvent("bpt_banking:doingType") +AddEventHandler("bpt_banking:doingType", function(typeData) + if source == nil then + return + end + if typeData == nil then + return + end local source = source local xPlayer = ESX.GetPlayerFromId(source) local identifier = xPlayer.getIdentifier() - local money = xPlayer.getAccount('money').money - local bankMoney = xPlayer.getAccount('bank').money + local money = xPlayer.getAccount("money").money + local bankMoney = xPlayer.getAccount("bank").money local amount local key = get_key(typeData) @@ -52,11 +64,13 @@ AddEventHandler('bpt_banking:doingType', function(typeData) amount = tonumber(typeData.pincode) end - if not tonumber(amount) then return end + if not tonumber(amount) then + return + end amount = ESX.Math.Round(amount) if amount == nil or (not typeData.pincode and amount <= 0) then - TriggerClientEvent("esx:showNotification", source, TranslateCap('invalid_amount'), "error") + TriggerClientEvent("esx:showNotification", source, TranslateCap("invalid_amount"), "error") else if typeData.deposit and amount <= money then -- deposit @@ -75,7 +89,7 @@ AddEventHandler('bpt_banking:doingType', function(typeData) end if bankMoney < amount then - TriggerClientEvent("esx:showNotification", source, TranslateCap('not_enough_money', amount), "error") + TriggerClientEvent("esx:showNotification", source, TranslateCap("not_enough_money", amount), "error") return end @@ -84,19 +98,16 @@ AddEventHandler('bpt_banking:doingType', function(typeData) return end else - TriggerClientEvent("esx:showNotification", source, TranslateCap('not_enough_money', amount), "error") + TriggerClientEvent("esx:showNotification", source, TranslateCap("not_enough_money", amount), "error") return end - money = xPlayer.getAccount('money').money - bankMoney = xPlayer.getAccount('bank').money + money = xPlayer.getAccount("money").money + bankMoney = xPlayer.getAccount("bank").money if typeData.transfer then - TriggerClientEvent("esx:showNotification", source, - TranslateCap(string.format('%s_money', key), amount, typeData.transfer.playerId), "success") + TriggerClientEvent("esx:showNotification", source, TranslateCap(string.format("%s_money", key), amount, typeData.transfer.playerId), "success") else - TriggerClientEvent("esx:showNotification", source, - TranslateCap(string.format('%s_money', key), - typeData.pincode and (string.format("%04d", amount)) or amount), "success") + TriggerClientEvent("esx:showNotification", source, TranslateCap(string.format("%s_money", key), typeData.pincode and (string.format("%04d", amount)) or amount), "success") end if not typeData.pincode then BANK.LogTransaction(source, string.upper(key), string.upper(key), amount, bankMoney) @@ -111,13 +122,12 @@ ESX.RegisterServerCallback("bpt_banking:getPlayerData", function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) local identifier = xPlayer.getIdentifier() local weekAgo = (os.time() - 604800) * 1000 - local transactionHistory = MySQL.Sync.fetchAll( - 'SELECT * FROM banking WHERE identifier = ? AND time > ? ORDER BY time DESC LIMIT 10', { identifier, weekAgo }) + local transactionHistory = MySQL.Sync.fetchAll("SELECT * FROM banking WHERE identifier = ? AND time > ? ORDER BY time DESC LIMIT 10", { identifier, weekAgo }) local playerData = { playerName = xPlayer.getName(), - money = xPlayer.getAccount('money').money, - bankMoney = xPlayer.getAccount('bank').money, - transactionHistory = transactionHistory + money = xPlayer.getAccount("money").money, + bankMoney = xPlayer.getAccount("bank").money, + transactionHistory = transactionHistory, } cb(playerData) @@ -126,8 +136,7 @@ end) ESX.RegisterServerCallback("bpt_banking:checkPincode", function(source, cb, inputPincode) local xPlayer = ESX.GetPlayerFromId(source) local identifier = xPlayer.getIdentifier() - local pincode = MySQL.Sync.fetchScalar('SELECT COUNT(1) AS pincode FROM users WHERE identifier = ? AND pincode = ?', - { identifier, inputPincode }) + local pincode = MySQL.Sync.fetchScalar("SELECT COUNT(1) AS pincode FROM users WHERE identifier = ? AND pincode = ?", { identifier, inputPincode }) cb(pincode > 0) end) @@ -142,7 +151,7 @@ function logTransaction(targetSource, label, key, amount) return end - if type(key) ~= "string" or key == '' then + if type(key) ~= "string" or key == "" then print("ERROR: Do you need use these: WITHDRAW,DEPOSIT,TRANSFER_RECEIVE and can only be string type!") return end @@ -159,7 +168,7 @@ function logTransaction(targetSource, label, key, amount) local xPlayer = ESX.GetPlayerFromId(tonumber(targetSource)) if xPlayer ~= nil then - local bankCurrentMoney = xPlayer.getAccount('bank').money + local bankCurrentMoney = xPlayer.getAccount("bank").money BANK.LogTransaction(targetSource, label, string.upper(key), amount, bankCurrentMoney) else print("ERROR: xPlayer is nil!") @@ -168,8 +177,8 @@ end exports("logTransaction", logTransaction) -RegisterServerEvent('bpt_banking:logTransaction') -AddEventHandler('bpt_banking:logTransaction', function(label, key, amount) +RegisterServerEvent("bpt_banking:logTransaction") +AddEventHandler("bpt_banking:logTransaction", function(label, key, amount) logTransaction(source, label, key, amount) end) @@ -181,11 +190,13 @@ BANK = { local coords = Config.Peds[i].Position spawnedPeds[i] = CreatePed(0, model, coords.x, coords.y, coords.z, coords.w, true, true) netIdTable[i] = NetworkGetNetworkIdFromEntity(spawnedPeds[i]) - while not DoesEntityExist(spawnedPeds[i]) do Wait(50) end + while not DoesEntityExist(spawnedPeds[i]) do + Wait(50) + end end Wait(100) - TriggerClientEvent('bpt_banking:pedHandler', -1, netIdTable) + TriggerClientEvent("bpt_banking:pedHandler", -1, netIdTable) end, DeletePeds = function() for i = 1, #spawnedPeds do @@ -194,12 +205,12 @@ BANK = { end end, Withdraw = function(amount, xPlayer) - xPlayer.addAccountMoney('money', amount) - xPlayer.removeAccountMoney('bank', amount) + xPlayer.addAccountMoney("money", amount) + xPlayer.removeAccountMoney("bank", amount) end, Deposit = function(amount, xPlayer) - xPlayer.removeAccountMoney('money', amount) - xPlayer.addAccountMoney('bank', amount) + xPlayer.removeAccountMoney("money", amount) + xPlayer.addAccountMoney("bank", amount) end, Transfer = function(xTarget, xPlayer, amount, key) if xTarget == nil or xPlayer.source == xTarget.source then @@ -207,18 +218,16 @@ BANK = { return false end - xPlayer.removeAccountMoney('bank', amount) - xTarget.addAccountMoney('bank', amount) - local bankMoney = xTarget.getAccount('bank').money + xPlayer.removeAccountMoney("bank", amount) + xTarget.addAccountMoney("bank", amount) + local bankMoney = xTarget.getAccount("bank").money BANK.LogTransaction(xTarget.source, "TRANSFER_RECEIVE", amount, bankMoney) - TriggerClientEvent("esx:showNotification", xTarget.source, - TranslateCap('receive_transfer', amount, xPlayer.source), - "success") + TriggerClientEvent("esx:showNotification", xTarget.source, TranslateCap("receive_transfer", amount, xPlayer.source), "success") return true end, Pincode = function(amount, identifier) - MySQL.update('UPDATE users SET pincode = ? WHERE identifier = ? ', { amount, identifier }) + MySQL.update("UPDATE users SET pincode = ? WHERE identifier = ? ", { amount, identifier }) end, LogTransaction = function(playerId, label, logType, amount, bankMoney) if playerId == nil then @@ -232,7 +241,6 @@ BANK = { local xPlayer = ESX.GetPlayerFromId(playerId) local identifier = xPlayer.getIdentifier() - MySQL.insert('INSERT INTO banking (identifier, label, type, amount, time, balance) VALUES (?, ?, ?, ?, ?, ?)', - { identifier, label, logType, amount, os.time() * 1000, bankMoney }) - end + MySQL.insert("INSERT INTO banking (identifier, label, type, amount, time, balance) VALUES (?, ?, ?, ?, ?, ?)", { identifier, label, logType, amount, os.time() * 1000, bankMoney }) + end, } From b525611eaedc9c6f5ef584912e50cc8d7d61a998 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:14:24 +0200 Subject: [PATCH 13/16] convert: esx_basicneeds > bpt_basicneeds - convert esx_basicneeds > bpt_basicneeds - --- .../bpt_basicneeds}/LICENSE | 14 +- .../[bpt_addons]/bpt_basicneeds/README.md | 19 +++ .../bpt_basicneeds/bpt_basicneeds.sql | 4 + .../bpt_basicneeds/client/main.lua | 132 ++++++++++++++++++ .../[bpt_addons]/bpt_basicneeds/config.lua | 21 +++ .../bpt_basicneeds/fxmanifest.lua | 28 ++++ .../bpt_basicneeds/locales/en.lua | 5 + .../bpt_basicneeds/locales/it.lua | 5 + .../localization/it_bpt_basicneeds.sql | 4 + .../[esx_addons]/esx_basicneeds/README.md | 32 ----- .../esx_basicneeds/client/main.lua | 72 ---------- .../[esx_addons]/esx_basicneeds/config.lua | 3 - .../esx_basicneeds/fxmanifest.lua | 28 ---- .../esx_basicneeds/locales/da.lua | 3 - .../esx_basicneeds/locales/de.lua | 3 - .../esx_basicneeds/locales/en.lua | 3 - .../esx_basicneeds/locales/es.lua | 4 - .../esx_basicneeds/locales/fi.lua | 4 - .../esx_basicneeds/locales/fr.lua | 3 - .../esx_basicneeds/locales/hu.lua | 4 - .../esx_basicneeds/locales/it.lua | 5 - .../esx_basicneeds/locales/nl.lua | 3 - .../esx_basicneeds/locales/pl.lua | 4 - .../esx_basicneeds/locales/sl.lua | 3 - .../esx_basicneeds/locales/sr.lua | 3 - .../esx_basicneeds/locales/zh-cn.lua | 3 - .../esx_basicneeds/server/main.lua | 14 -- 27 files changed, 225 insertions(+), 201 deletions(-) rename server-data/resources/{[esx_addons]/esx_basicneeds => [bpt_addons]/bpt_basicneeds}/LICENSE (98%) create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/README.md create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/bpt_basicneeds.sql create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/config.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/fxmanifest.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/locales/en.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/locales/it.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/localization/it_bpt_basicneeds.sql delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/README.md delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/config.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua delete mode 100644 server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/LICENSE b/server-data/resources/[bpt_addons]/bpt_basicneeds/LICENSE similarity index 98% rename from server-data/resources/[esx_addons]/esx_basicneeds/LICENSE rename to server-data/resources/[bpt_addons]/bpt_basicneeds/LICENSE index e315a4492..62f066311 100644 --- a/server-data/resources/[esx_addons]/esx_basicneeds/LICENSE +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - esx_basicneeds - Copyright (C) 2015-2022 Jérémie N'gadi + + Copyright (C) 2024 bitpredator This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - esx_basicneeds Copyright (C) 2015-2022 Jérémie N'gadi + Copyright (C) 2024 bitpredator This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. \ No newline at end of file +. diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/README.md b/server-data/resources/[bpt_addons]/bpt_basicneeds/README.md new file mode 100644 index 000000000..b2f6ccad8 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/README.md @@ -0,0 +1,19 @@ +

bpt_basicneeds

+

Discord + +Copyright (C) 2024 bitpredator + +This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. + +This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. + +ATTENTION: +You are not authorized to change the name of the resource and the resources within it. + +If you want to contribute you can open a pull request. + +You are not authorized to sell this software (this is free project). + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/bpt_basicneeds.sql b/server-data/resources/[bpt_addons]/bpt_basicneeds/bpt_basicneeds.sql new file mode 100644 index 000000000..7d602553c --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/bpt_basicneeds.sql @@ -0,0 +1,4 @@ +INSERT INTO `items` (`name`, `label`, `weight`) VALUES + ('bread', 'Bread', 1), + ('water', 'Water', 1) +; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua new file mode 100644 index 000000000..23134e146 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua @@ -0,0 +1,132 @@ +local IsDead = false +local IsAnimated = false + +AddEventHandler("bpt_basicneeds:resetStatus", function() + TriggerEvent("bpt_status:set", "hunger", 500000) + TriggerEvent("bpt_status:set", "thirst", 500000) +end) + +RegisterNetEvent("bpt_basicneeds:healPlayer") +AddEventHandler("bpt_basicneeds:healPlayer", function() + -- restore hunger & thirst + TriggerEvent("bpt_status:set", "hunger", 1000000) + TriggerEvent("bpt_status:set", "thirst", 1000000) + + -- restore hp + local playerPed = PlayerPedId() + SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed)) +end) + +AddEventHandler("esx:onPlayerDeath", function() + IsDead = true +end) + +AddEventHandler("esx:onPlayerSpawn", function(spawn) + if IsDead then + TriggerEvent("bpt_basicneeds:resetStatus") + end + + IsDead = false +end) + +AddEventHandler("bpt_status:loaded", function(status) + TriggerEvent("bpt_status:registerStatus", "hunger", 1000000, "#CFAD0F", function(status) + return Config.Visible + end, function(status) + status.remove(100) + end) + + TriggerEvent("bpt_status:registerStatus", "thirst", 1000000, "#0C98F1", function(status) + return Config.Visible + end, function(status) + status.remove(75) + end) +end) + +AddEventHandler("bpt_status:onTick", function(data) + local playerPed = PlayerPedId() + local prevHealth = GetEntityHealth(playerPed) + local health = prevHealth + + for k, v in pairs(data) do + if v.name == "hunger" and v.percent == 0 then + if prevHealth <= 150 then + health = health - 5 + else + health = health - 1 + end + elseif v.name == "thirst" and v.percent == 0 then + if prevHealth <= 150 then + health = health - 5 + else + health = health - 1 + end + end + end + + if health ~= prevHealth then + SetEntityHealth(playerPed, health) + end +end) + +AddEventHandler("bpt_basicneeds:isEating", function(cb) + cb(IsAnimated) +end) + +RegisterNetEvent("bpt_basicneeds:onUse") +AddEventHandler("bpt_basicneeds:onUse", function(type, prop_name, anim) + if not IsAnimated then + local anim = anim + IsAnimated = true + if type == "food" then + prop_name = prop_name or "prop_cs_burger_01" + anim = anim + elseif type == "drink" then + prop_name = prop_name or "prop_ld_flow_bottle" + anim = anim + end + + CreateThread(function() + local playerPed = PlayerPedId() + local x, y, z = table.unpack(GetEntityCoords(playerPed)) + local prop = CreateObject(joaat(prop_name), x, y, z + 0.2, true, true, true) + local boneIndex = GetPedBoneIndex(playerPed, 18905) + AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) + + ESX.Streaming.RequestAnimDict(anim.dict, function() + TaskPlayAnim(playerPed, anim.dict, anim.name, anim.settings[1], anim.settings[2], anim.settings[3], anim.settings[4], anim.settings[5], anim.settings[6], anim.settings[7], anim.settings[8]) + RemoveAnimDict(anim.dict) + + Wait(3000) + IsAnimated = false + ClearPedSecondaryTask(playerPed) + DeleteObject(prop) + end) + end) + end +end) + +-- Backwards compatibility +RegisterNetEvent("bpt_basicneeds:onEat") +AddEventHandler("bpt_basicneeds:onEat", function(prop_name) + local Invoke = GetInvokingResource() + + print(("[^3WARNING^7] ^5%s^7 used ^5bpt_basicneeds:onEat^7, this method is deprecated and should not be used! Refer to ^5https://bitpredator.github.io/bptdevelopment/docs/FiveM/bpt_basicneeds/events/oneat^7 for more info!"):format(Invoke)) + + if not prop_name then + prop_name = "prop_cs_burger_01" + end + TriggerEvent("bpt_basicneeds:onUse", "food", prop_name) +end) + +RegisterNetEvent("bpt_basicneeds:onDrink") +AddEventHandler("bpt_basicneeds:onDrink", function(prop_name) + local Invoke = GetInvokingResource() + + print(("[^3WARNING^7] ^5%s^7 used ^5bpt_basicneeds:onDrink^7, this method is deprecated and should not be used! Refer to ^5https://bitpredator.github.io/bptdevelopment/docs/FiveM/bpt_basicneeds/events/ondrink^7 for more info!"):format(Invoke)) + + if not prop_name then + prop_name = "prop_ld_flow_bottle" + end + TriggerEvent("bpt_basicneeds:onUse", "drink", prop_name) +end) diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/config.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/config.lua new file mode 100644 index 000000000..9ec75b7e1 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/config.lua @@ -0,0 +1,21 @@ +Config = {} +Config.Locale = GetConvar("esx:locale", "en") +Config.Visible = true + +Config.Items = { + ["bread"] = { + type = "food", + prop = "prop_cs_burger_01", + status = 200000, + remove = true, + anim = { dict = "mp_player_inteat@burger", name = "mp_player_int_eat_burger_fp", settings = { 8.0, -8, -1, 49, 0, 0, 0, 0 } }, + }, + + ["water"] = { + type = "drink", + prop = "prop_ld_flow_bottle", + status = 100000, + remove = true, + anim = { dict = "mp_player_intdrink", name = "loop_bottle", settings = { 1.0, -1.0, 2000, 0, 1, true, true, true } }, + }, +} diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/fxmanifest.lua new file mode 100644 index 000000000..6d7999591 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/fxmanifest.lua @@ -0,0 +1,28 @@ +fx_version("adamant") + +game("gta5") + +description("Adds a Hunger & Thrist system") +lua54("yes") +version("1.0.1") + +shared_script("@es_extended/imports.lua") + +server_scripts({ + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "server/main.lua", +}) + +client_scripts({ + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "client/main.lua", +}) + +dependencies({ + "es_extended", + "bpt_status", +}) diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/en.lua new file mode 100644 index 000000000..bef090aa4 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/en.lua @@ -0,0 +1,5 @@ +Locales["en"] = { + ["used_food"] = "You have eaten 1x %s", + ["used_drink"] = "You have drinked 1x %s", + ["got_healed"] = "You have been healed.", +} diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/it.lua new file mode 100644 index 000000000..65c268b77 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/locales/it.lua @@ -0,0 +1,5 @@ +Locales["it"] = { + ["used_bread"] = "hai usato 1x panino", + ["used_water"] = "hai usato 1x acqua", + ["got_healed"] = "Sei stato curato.", +} diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/localization/it_bpt_basicneeds.sql b/server-data/resources/[bpt_addons]/bpt_basicneeds/localization/it_bpt_basicneeds.sql new file mode 100644 index 000000000..98af83699 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/localization/it_bpt_basicneeds.sql @@ -0,0 +1,4 @@ +INSERT INTO `items` (`name`, `label`, `weight`) VALUES + ('bread', 'Pane', 1), + ('water', 'Acqua', 1) +; \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/README.md b/server-data/resources/[esx_addons]/esx_basicneeds/README.md deleted file mode 100644 index 9f17f5307..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/README.md +++ /dev/null @@ -1,32 +0,0 @@ -## Requirements -- bpt_status - -## Installation - -### Manually -- Put it in the `[esx]` directory - - -## Installation -- Import `esx_basicneeds.sql` in your database -- Add this in your server.cfg : - -``` -start esx_basicneeds -``` - -# Legal -### License -esx_basicneeds - thirst and hunger system - -Copyright (C) 2022-2024 bitpredator - -ATTENTION: You are not authorized to change the name of the resource and the resources within it. - -If you want to contribute you can open a pull request. - -You are not authorized to sell this software (this is free project). - -This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua b/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua deleted file mode 100644 index a04012c94..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua +++ /dev/null @@ -1,72 +0,0 @@ -local IsDead = false -local IsAnimated = false - -AddEventHandler('esx_basicneeds:resetStatus', function() - TriggerEvent('bpt_status:set', 'hunger', 500000) - TriggerEvent('bpt_status:set', 'thirst', 500000) -end) - -RegisterNetEvent('esx_basicneeds:healPlayer') -AddEventHandler('esx_basicneeds:healPlayer', function() - -- restore hunger & thirst - TriggerEvent('bpt_status:set', 'hunger', 1000000) - TriggerEvent('bpt_status:set', 'thirst', 1000000) - - -- restore hp - local playerPed = PlayerPedId() - SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed)) -end) - -AddEventHandler('esx:onPlayerDeath', function() - IsDead = true -end) - -AddEventHandler('esx:onPlayerSpawn', function() - if IsDead then - TriggerEvent('esx_basicneeds:resetStatus') - end - - IsDead = false -end) - -AddEventHandler('bpt_status:loaded', function() - TriggerEvent('bpt_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function() - return Config.Visible - end, function(status) - status.remove(100) - end) - - TriggerEvent('bpt_status:registerStatus', 'thirst', 1000000, '#0C98F1', function() - return Config.Visible - end, function(status) - status.remove(75) - end) -end) - -AddEventHandler('bpt_status:onTick', function(data) - local playerPed = PlayerPedId() - local prevHealth = GetEntityHealth(playerPed) - local health = prevHealth - - for _, v in pairs(data) do - if v.name == 'hunger' and v.percent == 0 then - if prevHealth <= 150 then - health = health - 5 - else - health = health - 1 - end - elseif v.name == 'thirst' and v.percent == 0 then - if prevHealth <= 150 then - health = health - 5 - else - health = health - 1 - end - end - end - - if health ~= prevHealth then SetEntityHealth(playerPed, health) end -end) - -AddEventHandler('esx_basicneeds:isEating', function(cb) - cb(IsAnimated) -end) \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/config.lua b/server-data/resources/[esx_addons]/esx_basicneeds/config.lua deleted file mode 100644 index 9c86897f6..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/config.lua +++ /dev/null @@ -1,3 +0,0 @@ -Config = {} -Config.Locale = 'en' -Config.Visible = false \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua b/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua deleted file mode 100644 index bf614cc29..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua +++ /dev/null @@ -1,28 +0,0 @@ -fx_version 'adamant' - -game 'gta5' - -description 'Basic Needs' -lua54 'yes' -version '0.0.5' - -shared_script '@es_extended/imports.lua' - -server_scripts { - '@es_extended/locale.lua', - 'locales/*.lua', - 'config.lua', - 'server/main.lua' -} - -client_scripts { - '@es_extended/locale.lua', - 'locales/*.lua', - 'config.lua', - 'client/main.lua' -} - -dependencies { - 'es_extended', - 'bpt_status' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua deleted file mode 100644 index 15c31d5a8..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['da'] = { - ['got_healed'] = 'Du er blevet helbredt.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua deleted file mode 100644 index 94d91f9d5..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['de'] = { - ['got_healed'] = 'Du wurdest geheilt.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua deleted file mode 100644 index 3f490d0a1..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['en'] = { - ['got_healed'] = 'You have been healed.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua deleted file mode 100644 index 06d9abb57..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua +++ /dev/null @@ -1,4 +0,0 @@ -Locales['es'] = { - ['used_bread'] = 'Has usado 1x pan', - ['used_water'] = 'Has usado 1x agua', -} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua deleted file mode 100644 index 92702f41d..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua +++ /dev/null @@ -1,4 +0,0 @@ -Locales['fi'] = { - ['used_bread'] = 'sinä söit 1x leipä', - ['used_water'] = 'sinä joit 1x vesi', -} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua deleted file mode 100644 index 728539d77..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['fr'] = { - ['got_healed'] = 'Vous avez été soigné.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua deleted file mode 100644 index 1277cbaca..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua +++ /dev/null @@ -1,4 +0,0 @@ -Locales['hu'] = { - ['used_bread'] = 'Megettél egy kenyeret.', - ['used_water'] = 'Megittál egy vizet.', -} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua deleted file mode 100644 index d23eb7668..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua +++ /dev/null @@ -1,5 +0,0 @@ -Locales['it'] = { - ['used_bread'] = 'hai usato 1x panino', - ['used_water'] = 'hai usato 1x acqua', - ['got_healed'] = 'Sei stato curato.' -} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua deleted file mode 100644 index 23bb68a10..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['nl'] = { - ['used_eat'] = 'je hebt een %s gegeten', -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua deleted file mode 100644 index 6ce6b3af6..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua +++ /dev/null @@ -1,4 +0,0 @@ -Locales['pl'] = { - ['used_bread'] = 'zjadłeś/aś 1x chleb', - ['used_water'] = 'wypiłeś/aś 1x woda', -} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua deleted file mode 100644 index 031851624..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['sl'] = { - ['got_healed'] = 'Vi ste bili Pozdravljeni.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua deleted file mode 100644 index 336eda766..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['sr'] = { - ['got_healed'] = 'Vi ste izlečeni.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua deleted file mode 100644 index 2ed1e6073..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['zh-cn'] = { - ['got_healed'] = '已重置饥饿+饥渴双值.' -} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua b/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua deleted file mode 100644 index 6cbd0c7e1..000000000 --- a/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua +++ /dev/null @@ -1,14 +0,0 @@ -ESX.RegisterCommand('heal', 'admin', function(_, args) - args.playerId.triggerEvent('esx_basicneeds:healPlayer') - args.playerId.showNotification(_U('got_healed')) -end, true, {help = 'Heal a player, or yourself - restores thirst, hunger and health.', validate = true, arguments = { - {name = 'playerId', help = 'the player id', type = 'player'} -}}) - -AddEventHandler('txAdmin:events:healedPlayer', function(eventData) - if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then - return - end - - TriggerClientEvent('esx_basicneeds:healPlayer', eventData.id) -end) \ No newline at end of file From 47d39bc68ef6921097e9d2fd76aab0ac5822558c Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:26:42 +0200 Subject: [PATCH 14/16] fix: bpt_basicneeds/client/main.lua fixed lint error --- .../[bpt_addons]/bpt_basicneeds/client/main.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua index 23134e146..395b0e475 100644 --- a/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua @@ -30,15 +30,15 @@ AddEventHandler("esx:onPlayerSpawn", function(spawn) end) AddEventHandler("bpt_status:loaded", function(status) - TriggerEvent("bpt_status:registerStatus", "hunger", 1000000, "#CFAD0F", function(status) + TriggerEvent("bpt_status:registerStatus", "hunger", 1000000, "#CFAD0F", function() return Config.Visible - end, function(status) + end, function() status.remove(100) end) TriggerEvent("bpt_status:registerStatus", "thirst", 1000000, "#0C98F1", function(status) return Config.Visible - end, function(status) + end, function() status.remove(75) end) end) @@ -48,7 +48,7 @@ AddEventHandler("bpt_status:onTick", function(data) local prevHealth = GetEntityHealth(playerPed) local health = prevHealth - for k, v in pairs(data) do + for _, v in pairs(data) do if v.name == "hunger" and v.percent == 0 then if prevHealth <= 150 then health = health - 5 @@ -74,9 +74,9 @@ AddEventHandler("bpt_basicneeds:isEating", function(cb) end) RegisterNetEvent("bpt_basicneeds:onUse") -AddEventHandler("bpt_basicneeds:onUse", function(type, prop_name, anim) +AddEventHandler("bpt_basicneeds:onUse", function(type, prop_name) if not IsAnimated then - local anim = anim + local anim = {} IsAnimated = true if type == "food" then prop_name = prop_name or "prop_cs_burger_01" From 80a1fe53ac032a16f52c7ac76333f7b0ad450da3 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:30:10 +0200 Subject: [PATCH 15/16] fix: bpt_basicneeds/client/main.lua fixed lint error --- .../resources/[bpt_addons]/bpt_basicneeds/client/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua index 395b0e475..bf6859fa7 100644 --- a/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua @@ -36,7 +36,7 @@ AddEventHandler("bpt_status:loaded", function(status) status.remove(100) end) - TriggerEvent("bpt_status:registerStatus", "thirst", 1000000, "#0C98F1", function(status) + TriggerEvent("bpt_status:registerStatus", "thirst", 1000000, "#0C98F1", function() return Config.Visible end, function() status.remove(75) From a0cc7de9a5ea64b6ea1562d29217f374bade7394 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:34:50 +0200 Subject: [PATCH 16/16] convert: esx_basicneeds > bpt_basicneeds --- .../bpt_basicneeds/server/main.lua | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 server-data/resources/[bpt_addons]/bpt_basicneeds/server/main.lua diff --git a/server-data/resources/[bpt_addons]/bpt_basicneeds/server/main.lua b/server-data/resources/[bpt_addons]/bpt_basicneeds/server/main.lua new file mode 100644 index 000000000..09a9554d0 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_basicneeds/server/main.lua @@ -0,0 +1,36 @@ +CreateThread(function() + for k, v in pairs(Config.Items) do + ESX.RegisterUsableItem(k, function(source) + local xPlayer = ESX.GetPlayerFromId(source) + if v.remove then + xPlayer.removeInventoryItem(k, 1) + end + if v.type == "food" then + TriggerClientEvent("bpt_status:add", source, "hunger", v.status) + TriggerClientEvent("bpt_basicneeds:onUse", source, v.type, v.prop, v.anim) + xPlayer.showNotification(TranslateCap("used_food", ESX.GetItemLabel(k))) + elseif v.type == "drink" then + TriggerClientEvent("bpt_status:add", source, "thirst", v.status) + TriggerClientEvent("bpt_basicneeds:onUse", source, v.type, v.prop, v.anim) + xPlayer.showNotification(TranslateCap("used_drink", ESX.GetItemLabel(k))) + else + print(string.format("^1[ERROR]^0 %s has no correct type defined.", k)) + end + end) + end +end) + +ESX.RegisterCommand("heal", "admin", function(xPlayer, args, showError) + args.playerId.triggerEvent("bpt_basicneeds:healPlayer") + args.playerId.showNotification(TranslateCap("got_healed")) +end, true, { help = "Heal a player, or yourself - restores thirst, hunger and health.", validate = true, arguments = { + { name = "playerId", help = "the player id", type = "player" }, +} }) + +AddEventHandler("txAdmin:events:healedPlayer", function(eventData) + if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then + return + end + + TriggerClientEvent("bpt_basicneeds:healPlayer", eventData.id) +end)