Skip to content

Commit

Permalink
chore: bpt_banking 🎨 Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Jun 10, 2024
1 parent 19a3b33 commit 15b9ff8
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 183 deletions.
92 changes: 50 additions & 42 deletions server-data/resources/[bpt_addons]/bpt_banking/client/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local BANK = {
Data = {}
Data = {},
}

local activeBlips, bankPoints, atmPoints, markerPoints = {}, {}, {}, {}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -95,15 +95,15 @@ 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)
SetBlipSprite(blip, bInfo.Sprite)
SetBlipScale(blip, bInfo.Scale)
SetBlipColour(blip, bInfo.Color)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName('STRING')
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName(bInfo.Label)
EndTextCommandSetBlipName(blip)
tmpActiveBlips[#tmpActiveBlips + 1] = blip
Expand Down Expand Up @@ -131,32 +131,32 @@ 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,
datas = {
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
Expand All @@ -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)
70 changes: 35 additions & 35 deletions server-data/resources/[bpt_addons]/bpt_banking/config.lua
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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",
},
},
}
Loading

0 comments on commit 15b9ff8

Please sign in to comment.