Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions __resource.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
client_script('client/client.lua')
resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9'

description 'The New Way of Banking'

version '1.0.0'

client_scripts {
'@es_extended/locale.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/nl.lua',
'config.lua',
'client/main.lua'
}

server_scripts {
'@mysql-async/lib/MySQL.lua',
'server.lua'
'@es_extended/locale.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/nl.lua',
'config.lua',
'@mysql-async/lib/MySQL.lua',
'server/main.lua'
}

-- Uncomment the desired version
Expand Down
169 changes: 169 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
--================================================================================================
--== VARIABLES - DO NOT EDIT ==
--================================================================================================
ESX = nil
inMenu = true
local showblips = true
local atbank = false
local bankMenu = true

--================================================================================================
--== THREADING - DO NOT EDIT ==
--================================================================================================

--===============================================
--== Base ESX Threading ==
--===============================================
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)

--===============================================
--== Core Threading ==
--===============================================
if bankMenu then
Citizen.CreateThread(function()
while true do
Wait(0)
if nearBank() or nearATM() then
DisplayHelpText(_U('helptext'))
if IsControlJustPressed(1, 38) then
inMenu = true
SetNuiFocus(true, true)
SendNUIMessage({type = 'openGeneral'})
TriggerServerEvent('bank:balance')
local ped = GetPlayerPed(-1)
end
end
if IsControlJustPressed(1, 322) then
inMenu = false
SetNuiFocus(false, false)
SendNUIMessage({type = 'close'})
end
end
end)
end

--===============================================
--== Map Blips ==
--===============================================
Citizen.CreateThread(function()
if showblips then
for k,v in pairs(Config.Banks)do
local blip = AddBlipForCoord(v.x, v.y, v.z)
SetBlipSprite(blip, v.id)
SetBlipScale(blip, 0.7)
SetBlipAsShortRange(blip, true)
if v.principal ~= nil and v.principal then
SetBlipColour(blip, 77)
end
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(tostring(v.name))
EndTextCommandSetBlipName(blip)
end
end
end)

--===============================================
--== Deposit Event ==
--===============================================
RegisterNetEvent('currentbalance1')
AddEventHandler('currentbalance1', function(balance)
local id = PlayerId()
local playerName = GetPlayerName(id)

SendNUIMessage({
type = "balanceHUD",
balance = balance,
player = playerName
})
end)
--===============================================
--== Deposit Event ==
--===============================================
RegisterNUICallback('deposit', function(data)
TriggerServerEvent('bank:deposit', tonumber(data.amount))
TriggerServerEvent('bank:balance')
end)

--===============================================
--== Withdraw Event ==
--===============================================
RegisterNUICallback('withdrawl', function(data)
TriggerServerEvent('bank:withdraw', tonumber(data.amountw))
TriggerServerEvent('bank:balance')
end)

--===============================================
--== Balance Event ==
--===============================================
RegisterNUICallback('balance', function()
TriggerServerEvent('bank:balance')
end)

RegisterNetEvent('balance:back')
AddEventHandler('balance:back', function(balance)
SendNUIMessage({type = 'balanceReturn', bal = balance})
end)

--===============================================
--== Transfer Event ==
--===============================================
RegisterNUICallback('transfer', function(data)
TriggerServerEvent('bank:transfer', data.to, data.amountt)
TriggerServerEvent('bank:balance')
end)

--===============================================
--== Result Event ==
--===============================================
RegisterNetEvent('bank:result')
AddEventHandler('bank:result', function(type, message)
SendNUIMessage({type = 'result', m = message, t = type})
end)

--===============================================
--== NUIFocusoff ==
--===============================================
RegisterNUICallback('NUIFocusOff', function()
inMenu = false
SetNuiFocus(false, false)
SendNUIMessage({type = 'closeAll'})
end)

--===============================================
--== Capture Bank Distance ==
--===============================================
function nearBank()
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)

for _, search in pairs(Config.Banks) do
local distance = GetDistanceBetweenCoords(search.x, search.y, search.z, playerloc['x'], playerloc['y'], playerloc['z'], true)

if distance <= 3 then
return true
end
end
end

function nearATM()
local player = GetPlayerPed(-1)
local playerloc = GetEntityCoords(player, 0)

for _, search in pairs(Config.ATM) do
local distance = GetDistanceBetweenCoords(search.x, search.y, search.z, playerloc['x'], playerloc['y'], playerloc['z'], true)
if distance <= 3 then
return true
end
end
end

function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
Loading