81 lines
2.6 KiB
Lua
81 lines
2.6 KiB
Lua
local open = false
|
|
local bankLocations = {
|
|
vector3(149.77, -1040.72, 29.37),
|
|
vector3(-1212.98, -330.84, 37.78),
|
|
vector3(-2962.58, 482.63, 15.70),
|
|
vector3(314.19, -278.62, 54.17)
|
|
}
|
|
|
|
local function setOpen(state)
|
|
open = state
|
|
SetNuiFocus(state, state)
|
|
SendNUIMessage({ action = state and 'open' or 'close' })
|
|
if state then
|
|
DevXTriggerCallback('banking:overview', {}, function(result)
|
|
SendNUIMessage({
|
|
action = result.ok and 'overview' or 'error',
|
|
overview = result.overview,
|
|
message = result.error
|
|
})
|
|
end)
|
|
end
|
|
end
|
|
|
|
RegisterCommand('bank', function()
|
|
if exports.devx_core:IsPlayerLoaded() then setOpen(not open) end
|
|
end, false)
|
|
|
|
RegisterNUICallback('close', function(_, cb)
|
|
setOpen(false)
|
|
cb({ ok = true })
|
|
end)
|
|
|
|
RegisterNUICallback('refresh', function(_, cb)
|
|
DevXTriggerCallback('banking:overview', {}, cb)
|
|
end)
|
|
|
|
RegisterNUICallback('transfer', function(data, cb)
|
|
DevXTriggerCallback('banking:transfer', data, cb)
|
|
end)
|
|
|
|
CreateThread(function()
|
|
for _, location in ipairs(bankLocations) do
|
|
local blip = AddBlipForCoord(location.x, location.y, location.z)
|
|
SetBlipSprite(blip, 108)
|
|
SetBlipScale(blip, 0.65)
|
|
SetBlipColour(blip, 2)
|
|
SetBlipAsShortRange(blip, true)
|
|
BeginTextCommandSetBlipName('STRING')
|
|
AddTextComponentString('Bank')
|
|
EndTextCommandSetBlipName(blip)
|
|
end
|
|
end)
|
|
|
|
CreateThread(function()
|
|
while true do
|
|
local sleep = 1000
|
|
if exports.devx_core:IsPlayerLoaded() then
|
|
local coords = GetEntityCoords(PlayerPedId())
|
|
for _, location in ipairs(bankLocations) do
|
|
local distance = #(coords - location)
|
|
if distance < 15.0 then
|
|
sleep = 0
|
|
DrawMarker(
|
|
1, location.x, location.y, location.z - 1.0,
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
|
1.1, 1.1, 0.35, 70, 120, 255, 120,
|
|
false, false, 2, false, nil, nil, false
|
|
)
|
|
if distance < 1.5 then
|
|
BeginTextCommandDisplayHelp('STRING')
|
|
AddTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um die Bank zu öffnen.')
|
|
EndTextCommandDisplayHelp(0, false, true, -1)
|
|
if IsControlJustReleased(0, 38) then setOpen(true) end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
Wait(sleep)
|
|
end
|
|
end)
|