Skip to content

Commit

Permalink
Merge pull request #66 from solareon/qbx-bridge
Browse files Browse the repository at this point in the history
feat: qbx bridge and society account creation
  • Loading branch information
FjamZoo authored Aug 26, 2024
2 parents 528e0db + cbe0d99 commit 5481444
Show file tree
Hide file tree
Showing 14 changed files with 1,083 additions and 1,599 deletions.
14 changes: 14 additions & 0 deletions .github/actions/bump-manifest-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs')

const version = process.env.TGT_RELEASE_VERSION
const newVersion = version.replace('v', '')

const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'})

let newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`)

if (newFileContent == manifestFile) {
newFileContent = manifestFile.replace(/\bgame\s+(.*)$/gm, `game 'gta5'\nversion '${newVersion}'`);
}

fs.writeFileSync('fxmanifest.lua', newFileContent)
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Main CI
on: [push, pull_request]
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
name: Build Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: web

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.BRANCH_NAME }}

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 9

- name: Setup node environment
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "web/pnpm-lock.yaml"

- name: Install dependencies
run: pnpm i --frozen-lockfile
working-directory: web

- name: Try build
run: pnpm build
env:
CI: true
63 changes: 63 additions & 0 deletions .github/workflows/release-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Release Action"

on:
push:
tags:
- "v*"

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
release-action:
name: "Create Release"
runs-on: "ubuntu-latest"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.BRANCH_NAME }}

- name: Install ZIP
run: sudo apt install zip

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 9

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "web/pnpm-lock.yaml"

- name: Install dependencies
run: pnpm i --frozen-lockfile
working-directory: web

- name: Run build
run: pnpm build
working-directory: web
env:
CI: false

- name: Bundle files
run: |
shopt -s extglob
mkdir -p ./temp/${{ github.event.repository.name }}
mkdir -p ./temp/${{ github.event.repository.name }}/web
cp ./{README.md,LICENSE,fxmanifest.lua} ./temp/${{ github.event.repository.name }}
cp -r ./{client,config,server} ./temp/${{ github.event.repository.name }}
cp -r ./web/public ./temp/${{ github.event.repository.name }}/web/public
cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }}
- name: Create Release
uses: marvinpinto/action-automatic-releases@latest
with:
title: ${{ github.ref_name }}
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: ${{ github.event.repository.name }}.zip
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create New Release

on:
workflow_dispatch:
inputs:
version:
required: true

jobs:
create-release:
name: Create New Release
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Bump manifest version
run: node .github/actions/bump-manifest-version.js
env:
TGT_RELEASE_VERSION: ${{ inputs.version }}

- name: Push manifest change
uses: EndBug/add-and-commit@v9
with:
add: fxmanifest.lua
push: true
message: 'chore: bump manifest version to ${{ inputs.version }}'

- name: Push Git Tag
run: |
git tag ${{ inputs.version }}
git push origin ${{ inputs.version }}
13 changes: 0 additions & 13 deletions Renewed-Banking.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ CREATE TABLE IF NOT EXISTS `bank_accounts_new` (
PRIMARY KEY (`id`)
);

INSERT INTO `bank_accounts_new` (`id`, `amount`, `transactions`, `auth`, `isFrozen`, `creator`) VALUES
('ambulance', 0, '[]', '[]', 0, NULL),
('cardealer', 0, '[]', '[]', 0, NULL),
('mechanic', 0, '[]', '[]', 0, NULL),
('police', 0, '[]', '[]', 0, NULL),
('realestate', 0, '[]', '[]', 0, NULL),
('lostmc', 0, '[]', '[]', 0, NULL),
('ballas', 0, '[]', '[]', 0, NULL),
('vagos', 0, '[]', '[]', 0, NULL),
('cartel', 0, '[]', '[]', 0, NULL),
('families', 0, '[]', '[]', 0, NULL),
('triads', 0, '[]', '[]', 0, NULL);

CREATE TABLE IF NOT EXISTS `player_transactions` (
`id` varchar(50) NOT NULL,
`isFrozen` int(11) DEFAULT 0,
Expand Down
10 changes: 6 additions & 4 deletions client/framework.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
local Framework = Config.framework
QBCore, ESX, FullyLoaded = nil, nil, nil
if Framework == 'qb'then
QBCore = exports['qb-core']:GetCoreObject()
QBCore, ESX, FullyLoaded = nil, nil, nil --luacheck: ignore
if Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject() --luacheck: ignore
FullyLoaded = Framework == 'qb' and LocalPlayer.state.isLoggedIn
elseif Framework == 'esx'then
elseif Framework == 'qbx' then
FullyLoaded = Framework == 'qbx' and LocalPlayer.state.isLoggedIn
elseif Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
FullyLoaded = Framework == 'esx' and ESX.PlayerLoaded or false
else
Expand Down
99 changes: 54 additions & 45 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,57 @@ CreateThread(function ()
end)

local pedSpawned = false
local peds = {basic = {}, adv ={}}
local blips = {}
function CreatePeds()
if pedSpawned then return end
for k=1, #Config.peds do
local model = joaat(Config.peds[k].model)

RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end

for k = 1, #Config.peds do
local coords = Config.peds[k].coords
local bankPed = CreatePed(0, model, coords.x, coords.y, coords.z-1, coords.w, false, false)
local pedPoint = lib.points.new({
coords = coords,
distance = 300,
model = joaat(Config.peds[k].model),
ped = nil,
targetOptions = Config.peds[k].createAccounts and {{
name = 'renewed_banking_accountmng',
event = 'Renewed-Banking:client:accountManagmentMenu',
icon = 'fas fa-money-check',
label = locale('manage_bank'),
atm = false,
canInteract = function(_, distance)
return distance < 4.5
end
}} or {{
name = 'renewed_banking_openui',
event = 'Renewed-Banking:client:openBankUI',
icon = 'fas fa-money-check',
label = locale('view_bank'),
atm = false,
canInteract = function(_, distance)
return distance < 4.5
end
}}
})

function pedPoint:onEnter()
lib.requestModel(self.model, 10000)

self.ped = CreatePed(0, self.model, self.coords.x, self.coords.y, self.coords.z-1, self.coords.w, false, false)
SetModelAsNoLongerNeeded(self.model)

TaskStartScenarioInPlace(self.ped, 'PROP_HUMAN_STAND_IMPATIENT', 0, true)
FreezeEntityPosition(self.ped, true)
SetEntityInvincible(self.ped, true)
SetBlockingOfNonTemporaryEvents(self.ped, true)
exports.ox_target:addLocalEntity(self.ped, self.targetOptions)
end

TaskStartScenarioInPlace(bankPed, 'PROP_HUMAN_STAND_IMPATIENT', 0, true)
FreezeEntityPosition(bankPed, true)
SetEntityInvincible(bankPed, true)
SetBlockingOfNonTemporaryEvents(bankPed, true)
table.insert(Config.peds[k].createAccounts and peds.adv or peds.basic, bankPed)
function pedPoint:onExit()
exports.ox_target:removeLocalEntity(self.ped, self.advanced and 'renewed_banking_accountmng' or 'renewed_banking_openui')
if DoesEntityExist(self.ped) then
DeletePed(self.ped)
end
self.ped = nil
end

blips[k] = AddBlipForCoord(coords.x, coords.y, coords.z-1)
SetBlipSprite(blips[k], 108)
Expand All @@ -116,51 +149,27 @@ function CreatePeds()
AddTextComponentString('Bank')
EndTextCommandSetBlipName(blips[k])
end

local targetOpts ={{
name = 'renewed_banking_openui',
event = 'Renewed-Banking:client:openBankUI',
icon = 'fas fa-money-check',
label = locale('view_bank'),
atm = false,
canInteract = function(_, distance)
return distance < 4.5
end
}}
exports.ox_target:addLocalEntity(peds.basic, targetOpts)
targetOpts[#targetOpts+1]={
name = 'renewed_banking_accountmng',
event = 'Renewed-Banking:client:accountManagmentMenu',
icon = 'fas fa-money-check',
label = locale('manage_bank'),
atm = false,
canInteract = function(_, distance)
return distance < 4.5
end
}
exports.ox_target:addLocalEntity(peds.adv, targetOpts)
pedSpawned = true
end

function DeletePeds()
if not pedSpawned then return end
local k=1
for x,v in pairs(peds)do
for i=1, #v do
DeletePed(v[i])
RemoveBlip(blips[k])
k += 1
local points = lib.points.getAllPoints()
for i = 1, #points do
if DoesEntityExist(points[i].ped) then
DeletePed(points[i].ped)
end
peds[x] = {}
points[i]:remove()
end
for i = 1, #blips do
RemoveBlip(blips[i])
end
pedSpawned = false
end

AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
exports.ox_target:removeModel(Config.atms, {'renewed_banking_openui'})
exports.ox_target:removeEntity(peds.basic, {'renewed_banking_openui'})
exports.ox_target:removeEntity(peds.adv, {'renewed_banking_openui','renewed_banking_accountmng'})
DeletePeds()
end)

Expand Down
4 changes: 2 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
lib.locale()
Config = {
framework = 'qb', -- QB and ESX preconfigured edit the framework.lua to add functionality to other frameworks
framework = 'qb', -- QB, QBX, and ESX preconfigured edit the framework.lua to add functionality to other frameworks
renewedMultiJob = false, -- QBCORE ONLY! https://github.com/Renewed-Scripts/qb-phone
progressbar = 'circle', -- circle or rectangle (Anything other than circle will default to rectangle)
currency ='USD', -- USD, EUR, GBP ect.....
currency = 'USD', -- USD, EUR, GBP ect.....
atms = {
`prop_atm_01`,
`prop_atm_02`,
Expand Down
Loading

0 comments on commit 5481444

Please sign in to comment.