mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
11 Commits
20cea95783
...
v2.1.03
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee15f3b076 | ||
|
|
6919f038ee | ||
|
|
47029da6ed | ||
|
|
e1d292d1bf | ||
|
|
f08638812c | ||
|
|
de5424c506 | ||
|
|
b46d734442 | ||
|
|
92ad96e435 | ||
|
|
6166314cbf | ||
|
|
9fa8f58cfb | ||
|
|
ed997ad8a2 |
71
.github/workflows/notify-release.yml
vendored
Normal file
71
.github/workflows/notify-release.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Discord Release Notifier
|
||||
|
||||
on:
|
||||
# Manual or UI-published releases
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
# Releases created by your tag-driven workflow
|
||||
workflow_run:
|
||||
workflows: ["Package & Release"] # must match the 'name:' in release.yml
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# 1) Handle manual / UI / non-workflow-created releases
|
||||
notify-from-release:
|
||||
if: github.event_name == 'release' && github.event.action == 'published'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Send release payload to Discord Bot
|
||||
env:
|
||||
URL: http://${{ secrets.DISCORDBOT }}:3000/github-releases
|
||||
run: |
|
||||
curl -sS -X POST "$URL" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-binary "@$GITHUB_EVENT_PATH"
|
||||
|
||||
# 2) Handle releases created by your 'Package & Release' workflow
|
||||
# (which won’t trigger `on: release` when using GITHUB_TOKEN)
|
||||
notify-from-workflow-run:
|
||||
if: >
|
||||
github.event_name == 'workflow_run' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install jq
|
||||
run: sudo apt-get update && sudo apt-get install -y jq
|
||||
|
||||
- name: Fetch release JSON by tag
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
OWNER="${GITHUB_REPOSITORY%/*}"
|
||||
REPO="${GITHUB_REPOSITORY#*/}"
|
||||
TAG="${{ github.event.workflow_run.head_branch }}"
|
||||
# head_branch is the tag name for a tag push workflow_run
|
||||
curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"https://api.github.com/repos/$OWNER/$REPO/releases/tags/$TAG" \
|
||||
> release.json
|
||||
|
||||
- name: Wrap as 'release' event payload & notify bot
|
||||
env:
|
||||
URL: http://${{ secrets.DISCORDBOT }}:3000/github-releases
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jq -n --slurpfile rel release.json \
|
||||
--arg repo "$GITHUB_REPOSITORY" \
|
||||
--arg repo_url "https://github.com/$GITHUB_REPOSITORY" \
|
||||
--arg action "published" '
|
||||
{ action: $action,
|
||||
repository: { full_name: $repo, html_url: $repo_url },
|
||||
release: $rel[0],
|
||||
sender: { login: "github-actions[bot]" } }' > payload.json
|
||||
|
||||
curl -sS -X POST "$URL" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-binary "@payload.json"
|
||||
@@ -1,6 +1,6 @@
|
||||
name "Jim_Bridge"
|
||||
author "Jimathy"
|
||||
version "2.1.02"
|
||||
version "2.1.03"
|
||||
description "Framework Bridge By Jimathy"
|
||||
fx_version "cerulean"
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
|
||||
@@ -27,6 +27,132 @@ local function _debouncedRun(func)
|
||||
end)
|
||||
end
|
||||
|
||||
local frameworkLoadFunc = {
|
||||
{ framework = Exports.QBXExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', func)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', func)
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
local startTime = GetGameTimer()
|
||||
while not LocalPlayer.state.isLoggedIn and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = Exports.QBExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', func)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', func)
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
local startTime = GetGameTimer()
|
||||
while not LocalPlayer.state.isLoggedIn and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = Exports.ESXExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent("esx:playerLoaded", function()
|
||||
-- make sure shared has loaded (because sql)
|
||||
if waitForSharedLoad() then func() end
|
||||
end)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
RegisterNetEvent("esx:onPlayerLogout", func)
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
local startTime = GetGameTimer()
|
||||
while (GetGameTimer() - startTime) < timeout do
|
||||
local playerData = ESX.GetPlayerData()
|
||||
if playerData and playerData.job then
|
||||
return true
|
||||
end
|
||||
Wait(100)
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = Exports.OXCoreExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent('ox:playerLoaded', func)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
RegisterNetEvent('ox:playerLogout', func)
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
if OxPlayer["stateId"] then
|
||||
return true
|
||||
end
|
||||
while not OxPlayer["stateId"] do
|
||||
Wait(1000)
|
||||
if OxPlayer.get["stateId"] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = Exports.RSGExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent('RSGCore:Client:OnPlayerLoaded', func)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
RegisterNetEvent('RSGCore:Client:OnPlayerUnload', func)
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
local startTime = GetGameTimer()
|
||||
while not LocalPlayer.state.isLoggedIn and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = Exports.VorpExport,
|
||||
onPlayerLoaded =
|
||||
function(func)
|
||||
RegisterNetEvent('vorp_core:Client:OnPlayerSpawned', func)
|
||||
end,
|
||||
onPlayerUnload =
|
||||
function(func)
|
||||
--??
|
||||
end,
|
||||
waitforLogin =
|
||||
function(timeout)
|
||||
local startTime = GetGameTimer()
|
||||
while not LocalPlayer.state.IsInSession and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
return LocalPlayer.state.IsInSession
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
-------------------------------------------------------------
|
||||
-- Player Loaded and Unloaded Events
|
||||
-------------------------------------------------------------
|
||||
@@ -44,9 +170,6 @@ end
|
||||
--- end, true)
|
||||
--- ```
|
||||
function onPlayerLoaded(func, onStart)
|
||||
local onPlayerFramework = ""
|
||||
local loaded = false
|
||||
|
||||
if onStart then
|
||||
onResourceStart(function()
|
||||
if not waitForLogin() then return end
|
||||
@@ -59,34 +182,16 @@ function onPlayerLoaded(func, onStart)
|
||||
_debouncedRun(func)
|
||||
end
|
||||
|
||||
if isStarted(QBExport) or isStarted(QBXExport) then
|
||||
onPlayerFramework = QBExport
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', handler)
|
||||
|
||||
elseif isStarted(ESXExport) then
|
||||
onPlayerFramework = ESXExport
|
||||
RegisterNetEvent('esx:playerLoaded', function()
|
||||
if waitForSharedLoad() then handler() end
|
||||
end)
|
||||
|
||||
elseif isStarted(OXCoreExport) then
|
||||
onPlayerFramework = OXCoreExport
|
||||
RegisterNetEvent('ox:playerLoaded', handler)
|
||||
|
||||
elseif isStarted(RSGExport) then
|
||||
onPlayerFramework = RSGExport
|
||||
RegisterNetEvent('RSGCore:Client:OnPlayerLoaded', handler)
|
||||
|
||||
elseif isStarted(VorpExport) then
|
||||
onPlayerFramework = VorpExport
|
||||
RegisterNetEvent('vorp_core:Client:OnPlayerSpawned', handler)
|
||||
end
|
||||
|
||||
if onPlayerFramework ~= "" then
|
||||
debugPrint("^6Bridge^7: ^2Registering ^3onPlayerLoaded^7()^2 with ^3" .. onPlayerFramework .. "^7")
|
||||
else
|
||||
print("^4ERROR^7: No supported core detected for onPlayerLoaded - Check starter.lua")
|
||||
for i = 1, #frameworkLoadFunc do
|
||||
local data = frameworkLoadFunc[i]
|
||||
jsonPrint(data)
|
||||
if isStarted(data.framework) then
|
||||
debugPrint("^6Bridge^7: ^2Registering ^3"..data.framework.." ^5onPlayerLoaded^7()")
|
||||
data.onPlayerLoaded(handler)
|
||||
return
|
||||
end
|
||||
end
|
||||
print("^1ERROR^7: ^1No supported core detected for onPlayerLoaded - Check starter.lua^7")
|
||||
end
|
||||
|
||||
--- Executes a function when the player character is unloaded.
|
||||
@@ -99,15 +204,15 @@ end
|
||||
--- end)
|
||||
--- ```
|
||||
function onPlayerUnload(func)
|
||||
debugPrint("^6Bridge^7: ^2Registering ^3onPlayerUnload^7()")
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() func() end)
|
||||
|
||||
RegisterNetEvent('ox:playerLogout', function() func() end)
|
||||
|
||||
RegisterNetEvent('RSGCore:Client:OnPlayerUnload', function() func() end)
|
||||
|
||||
RegisterNetEvent('esx:onPlayerLogout', function() func() end)
|
||||
|
||||
for i = 1, #frameworkLoadFunc do
|
||||
local data = frameworkLoadFunc[i]
|
||||
if isStarted(data.framework) then
|
||||
debugPrint("^6Bridge^7: ^2Registering ^3"..data.framework.." ^5onPlayerUnload^7()")
|
||||
data.onPlayerUnload(func)
|
||||
return
|
||||
end
|
||||
end
|
||||
print("^1ERROR^7: ^1No supported core detected for onPlayerUnload - Check starter.lua^7")
|
||||
end
|
||||
|
||||
-------------------------------------------------------------
|
||||
@@ -166,51 +271,18 @@ end
|
||||
--- @usage
|
||||
--- waitForLogin()
|
||||
function waitForLogin()
|
||||
local timeout = 10000 -- 10 seconds in milliseconds
|
||||
local startTime = GetGameTimer()
|
||||
local loggedIn = false
|
||||
|
||||
if isStarted(ESXExport) then
|
||||
while (GetGameTimer() - startTime) < timeout do
|
||||
local playerData = ESX.GetPlayerData()
|
||||
if playerData and playerData.job then
|
||||
loggedIn = true
|
||||
break
|
||||
for i = 1, #frameworkLoadFunc do
|
||||
local data = frameworkLoadFunc[i]
|
||||
if isStarted(data.framework) then
|
||||
debugPrint("^6Bridge^7: ^2Waiting for ^3"..data.framework.."^2 player login^7.")
|
||||
local result = data.waitforLogin(10000)
|
||||
if result == true then
|
||||
debugPrint("^6Bridge^7: ^3"..data.framework.."^2 Player Login Detected^7.")
|
||||
else
|
||||
print("^4Error^7: ^2Timeout reached while waiting for player login^7.")
|
||||
end
|
||||
Wait(100)
|
||||
return result
|
||||
end
|
||||
elseif isStarted(OXCoreExport) then
|
||||
if OxPlayer["stateId"] then
|
||||
loggedIn = true
|
||||
end
|
||||
while not OxPlayer["stateId"] do
|
||||
Wait(1000)
|
||||
debugPrint("Waiting for stateId to class as logged in")
|
||||
if OxPlayer.get["stateId"] then
|
||||
loggedIn = true
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif isStarted(VorpExport) then
|
||||
-- For other frameworks, use LocalPlayer.state.isLoggedIn.
|
||||
while not LocalPlayer.state.IsInSession and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
loggedIn = LocalPlayer.state.IsInSession
|
||||
else
|
||||
-- For other frameworks, use LocalPlayer.state.isLoggedIn.
|
||||
while not LocalPlayer.state.isLoggedIn and (GetGameTimer() - startTime) < timeout do
|
||||
Wait(100)
|
||||
end
|
||||
loggedIn = LocalPlayer.state.isLoggedIn
|
||||
end
|
||||
|
||||
if not loggedIn then
|
||||
print("^4Error^7: ^2Timeout reached while waiting for player login^7.")
|
||||
return false
|
||||
else
|
||||
debugPrint("^6Bridge^7: ^2Player Login Detected^7.")
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ local InvFunc = {
|
||||
local weight = 0
|
||||
local itemcheck = getPlayerInv(src)
|
||||
for _, v in pairs(itemcheck) do
|
||||
weight += ((v.weight * v.amount) or 0)
|
||||
weight += v.weight
|
||||
end
|
||||
return weight
|
||||
end,
|
||||
@@ -341,7 +341,7 @@ local InvFunc = {
|
||||
local count = 0
|
||||
for _, itemData in pairs(invCache) do
|
||||
if itemData and itemData.name == item then
|
||||
count += (itemData.amount or itemData.count or 1)
|
||||
count += (itemData.amount or 0)
|
||||
end
|
||||
end
|
||||
return count >= amount, count
|
||||
@@ -384,7 +384,7 @@ local InvFunc = {
|
||||
if src then
|
||||
grabInv = exports[CodeMInv]:GetInventory(getPlayer(src).citizenId, src)
|
||||
else
|
||||
grabInv = exports[CodeMInv]:getUserInventory()
|
||||
grabInv = exports[CodeMInv]:GetClientPlayerInventory()
|
||||
end
|
||||
return grabInv
|
||||
end,
|
||||
@@ -1279,6 +1279,7 @@ end
|
||||
function hasItem(items, amount, src)
|
||||
local amount = amount and amount or 1
|
||||
local grabInv, foundInv = getPlayerInv(src)
|
||||
|
||||
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||
|
||||
local hasTable = {}
|
||||
@@ -2516,7 +2517,7 @@ end
|
||||
--- ```
|
||||
function sellAnim(data, token)
|
||||
if not hasItem(data.item, 1) then
|
||||
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..getItemLabel(data.item), "error")
|
||||
triggerNotify(nil, (Loc[Config.Lan].error["dont_have"] or "You don't have any") .." "..getItemLabel(data.item), "error")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ local progressFunc = {
|
||||
if exports[OXLibExport]:progressBar(options) then
|
||||
return true
|
||||
else
|
||||
print("^1progressBar was not successful")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
--- Registers a command with the active command system.
|
||||
--- This function supports multiple command systems (OXLib, qb-core, ESX Legacy).
|
||||
---
|
||||
@@ -47,7 +46,7 @@ function registerCommand(command, options)
|
||||
optionTable.helpInfo,
|
||||
optionTable.subText,
|
||||
optionTable.argsRequired,
|
||||
optionTable.funt,
|
||||
optionTable.funct,
|
||||
optionTable.restriction or nil
|
||||
)
|
||||
|
||||
@@ -57,7 +56,7 @@ function registerCommand(command, options)
|
||||
optionTable.helpInfo,
|
||||
optionTable.subText,
|
||||
optionTable.argsRequired,
|
||||
optionTable.funt,
|
||||
optionTable.funct,
|
||||
optionTable.restriction or nil
|
||||
)
|
||||
|
||||
|
||||
16
version.txt
16
version.txt
@@ -1,9 +1,13 @@
|
||||
2.1.02
|
||||
2.1.03
|
||||
|
||||
- Script Overhaul, replace whole script
|
||||
- Removal of Quasar Script Support
|
||||
- Support Tgiann-inv's new item system
|
||||
- **Hotfix for stores and stashes not registering properly**
|
||||
- **Hotfix "nil" print and use .xy for distance check**
|
||||
- Fix hunger and thirst math (add instead of set)
|
||||
- Fix cleanup of targets qb-targets on unload
|
||||
- Add support for new jim-shops exploit protection
|
||||
- Add full support for esx_society (fixes esx bossmenu errors)
|
||||
- Fix possible issue with qb-core /command registering
|
||||
- Make ox_lib progressbars return false correctly
|
||||
- Fix ox_inv players current weight checks
|
||||
- User alternate function for inventory retreival for CodeM Inv
|
||||
- Rework _loaders.lua tobe more organised/optimizied
|
||||
|
||||
https://github.com/jimathy/jim_bridge/releases/latest
|
||||
Reference in New Issue
Block a user