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] =?UTF-8?q?chore:=20bpt=5Fbanking=20=F0=9F=8E=A8=20Run=20f?= =?UTF-8?q?ormatter?= 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, }