Skip to content

Commit

Permalink
feat: reworked bridge and new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon committed Jul 20, 2024
1 parent 3b73e51 commit 8d313d3
Show file tree
Hide file tree
Showing 40 changed files with 3,842 additions and 448 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug Report
about: Create a bug report to help solve an issue
title: 'Bug: TITLE'
labels: New Issue
assignees: ''
---

**Describe the issue**

A clear and concise description of what the bug is.

**Expected behavior**

A clear and concise description of what you expected to happen.

**To Reproduce**

Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error


**Media**

If applicable, add a screenshot or a video to help explain your problem.

**Needed information (please complete the following information):**
- **Client Version:**: [e.g. Canary or Release]
- **Release Version:**: [e.g 1.0]

**Additional context**
Add any other context about the issue here.
Binary file added .github/assets/slrn_multijob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI
on:
push:
paths:
- 'ui/**'
- '.github/workflows/ci.yml'
pull_request:
paths:
- 'ui/**'
- '.github/workflows/ci.yml'
jobs:
build:
name: Build Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

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

- name: Install deps
run: pnpm install --frozen-lockfile
working-directory: ui

- name: Try build
run: pnpm build
working-directory: ui
env:
CI: true
56 changes: 56 additions & 0 deletions .github/workflows/debugbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Debug Build Action"

on:
workflow_dispatch:

jobs:
debug-build:
name: "Create Debug Build"
runs-on: "ubuntu-latest"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}

- 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: "ui/pnpm-lock.yaml"

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

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

- name: Bundle files
run: |
shopt -s extglob
mkdir -p ./temp/${{ github.event.repository.name }}
mkdir -p ./temp/${{ github.event.repository.name }}/ui
cp ./{README.md,LICENSE,fxmanifest.lua} ./temp/${{ github.event.repository.name }}
cp -r ./{client,bridge,server} ./temp/${{ github.event.repository.name }}
cp -r ./ui/dist ./temp/${{ github.event.repository.name }}/ui/
cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ./temp/
11 changes: 9 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: Lint
on: [push, pull_request_target]
on:
push:
paths:
- '*.lua'
- '.github/workflows/lint.yml'
pull_request_target:
paths:
- '*.lua'
- '.github/workflows/lint.yml'
jobs:
lint:
name: Lint Resource
Expand All @@ -15,7 +23,6 @@ jobs:
args: "-t --formatter JUnit"
extra_libs: ox_lib+mysql+qblocales+qbox+qbox_playerdata+qbox_lib
- name: Generate Lint Report
if: always()
uses: mikepenz/action-junit-report@v4
with:
report_paths: "**/junit.xml"
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/release-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,37 @@ jobs:
- 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: "ui/pnpm-lock.yaml"

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

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

- name: Bundle files
run: |
rm -rf ./.github ./.vscode ./.git
shopt -s extglob
mkdir ./${{ github.event.repository.name }}
cp -r !(${{ github.event.repository.name }}) ${{ github.event.repository.name }}
zip -r ./${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }}
mkdir -p ./temp/${{ github.event.repository.name }}
mkdir -p ./temp/${{ github.event.repository.name }}/ui
cp ./{README.md,LICENSE,fxmanifest.lua} ./temp/${{ github.event.repository.name }}
cp -r ./{client,bridge,server} ./temp/${{ github.event.repository.name }}
cp -r ./ui/dist ./temp/${{ github.event.repository.name }}/ui/dist
cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }}
- name: Get App Token
uses: actions/create-github-app-token@v1
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
# SLRN Multijob - App for LB-Phone
![Lint](https://github.com/solareon/slrn_multijob/actions/workflows/lint.yml/badge.svg)
![CI](https://github.com/solareon/slrn_multijob/actions/workflows/ci.yml/badge.svg)

A simple lb-phone application to manage the native [qbx_core](https://github.com/qbox-project/qbx_core) multijob. It does not manage multigang, if you wish to do that then you will need to modify the script yourself.
A simple lb-phone application to manage multijob systems. It does not manage multigang, if you wish to do that then you will need to modify the script yourself.

# If you are looking for the [qbcore version that is located here](https://github.com/solareon/slrn_qbmultijob)
**QBOX/QB supported with bridge**
ESX/ND/OX support soon

# Preview
![image](https://github.com/solareon/slrn_multijob/assets/769465/eba40145-4255-4993-9527-945ff4eaec0c)

![image](.github/assets/slrn_multijob.png)

# Installation
Download the [release version](https://github.com/solareon/slrn_groups/releases) and copy to your server.

# Customizing and building from source
Download the latest commit and navigate to the ui folder
```bash copy
pnpm i
```
Then to preview the UI. You can also switch the UI path in the app registration (switch the commented lines) and then the game will display the preview running from vite.
```bash copy
pnpm start
```
Or to build for production
```bash copy
pnpm build
```

# Support
- [Discord](https://discord.gg/TZFBBHvG6E)

# Credits
- [Randolio](https://github.com/Randolio/randol_multijob) for the multijob natives
- [Randolio](https://github.com/Randolio/randol_multijob) for the multijob natives for qbox
- [LB-Phone](https://github.com/lbphone/lb-phone-app-template) for the template apps
- [FuZZED105](https://github.com/FuZZED105/fzd_multijob) for the original app

# Dependencies
- [qbx_core](https://github.com/qbox-project/qbx_core) 1.7.0 or later
- [lb-phone](https://lbphone.com/)
- [ox_lib](https://github.com/overextended/ox_lib)

Expand Down
17 changes: 17 additions & 0 deletions bridge/esx.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if GetResourceState('es_extended') ~= 'started' then return end

if not IsDuplicityVersion() then return end

local ESX = exports.es_extended:getSharedObject()

local function getPlayer(source)
return ESX.GetPlayerFromId(source)
end

---Get the player data from the source
---@param source number
---@return string
function GetPlayerName(source)
local xPlayer = getPlayer(source)
return xPlayer.getName()
end
19 changes: 19 additions & 0 deletions bridge/nd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if not lib.checkDependency('ND_Core', '2.0.0') then return end

if not IsDuplicityVersion() then return end

NDCore = {}

lib.load('@ND_Core.init')

function GetPlayer(id)
return NDCore.getPlayer(id)
end

---Get the player data from the source
---@param source number
---@return string
function GetPlayerName(source)
local player = GetPlayer(source)
return player.fullname
end
8 changes: 8 additions & 0 deletions bridge/ox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if GetResourceState('ox_core') ~= 'started' then return end

local isServer = IsDuplicityVersion()

local Ox = require '@ox_core.lib.init'

--TODO: Add ox_core support

96 changes: 96 additions & 0 deletions bridge/qb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
if GetResourceState('qb-core') ~= 'started' or GetResourceState('qbx_core') == 'started' then return end

QBCore = exports['qb-core']:GetCoreObject()
local isServer = IsDuplicityVersion()


function GetJobs()
return QBCore.Shared.Jobs
end

JOBS = GetJobs()

if isServer then
function GetPlayer(source)
return QBCore.Functions.GetPlayer(source)
end

function GetPlayerData(source)
return GetPlayer(source).PlayerData
end

function Notify(source, message, type)
return QBCore.Functions.Notify(source, message, type)
end

function CheckCurrentJob(source, job)
local playerData = GetPlayerData(source)
return playerData.job.name == job
end

function CanSetJob(source, jobName)
local playerData = GetPlayerData(source)
local jobs = playerData.jobs
for job, _ in pairs(jobs) do
if jobName == job then
return true
end
end
return false
end

function SetPlayerJob(source, job)
return exports.qbx_core:SetPlayerPrimaryJob(GetPlayerData(source).citizenid, job)
end

function RemovePlayerFromJob(source, job)
return exports.qbx_core:RemovePlayerFromJob(GetPlayerData(source).citizenid, job)
end

function SetPlayerDuty(source, duty)
return GetPlayer(source).Functions.SetJobDuty(duty)
end

AddEventHandler('QBCore:Server:OnJobUpdate', function(playerSource, job)
local citizenid = GetPlayerData(playerSource).citizenid
if GetPlayerJob(citizenid, job) or GetPlayerJobCount(citizenid) then return end
AddPlayerJob(citizenid, job.name, job.grade)
end)

AddEventHandler('QBCore:Server:UpdateObject', function()
JOBS = GetJobs()
end)

AddEventHandler('onResourceStart', function(resource)
if resource ~= GetCurrentResourceName() then return end
MySQL.query([=[
CREATE TABLE IF NOT EXISTS `save_jobs` (
`cid` VARCHAR(100) NOT NULL,
`job` VARCHAR(100) NOT NULL,
`grade` INT(11) NOT NULL,
UNIQUE KEY `cid_job` (`cid`,`job`)
);
]=])
end)

else
function GetPlayerData()
return QBCore.Functions.GetPlayerData()
end

function Notify(message, type)
return QBCore.Functions.Notify(message, type)
end

AddEventHandler('QBCore:Client:OnSharedUpdate', function(data)
Wait(0)
if data ~= 'Jobs' then return end
JOBS = GetJobs()
end)

AddEventHandler('QBCore:Client:OnSharedUpdateMultiple', function(data)
Wait(0)
if data ~= 'Jobs' then return end
JOBS = GetJobs()
end)
end
Loading

0 comments on commit 8d313d3

Please sign in to comment.