input compat fixes

This commit is contained in:
Jim Shield
2025-03-11 22:41:13 +00:00
committed by GitHub
parent 83ba74bc12
commit 2572f86030
7 changed files with 106 additions and 32 deletions

View File

@@ -58,7 +58,7 @@ function onPlayerLoaded(func, onStart)
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 exports.lua")
print("^4ERROR^7: No supported core detected for onPlayerLoaded - Check starter.lua")
end
end
end
@@ -143,6 +143,18 @@ function waitForLogin()
end
Wait(100)
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
else
-- For other frameworks, use LocalPlayer.state.isLoggedIn.
while not LocalPlayer.state.isLoggedIn and (GetGameTimer() - startTime) < timeout do
@@ -159,3 +171,8 @@ function waitForLogin()
return true
end
end
--local OxPlayer = Ox.GetPlayer()
--jsonPrint(OxPlayer)

View File

@@ -49,6 +49,13 @@ for _, v in pairs(Exports) do
end
end
OxPlayer = nil
if isStarted(OXCoreExport) then
if not isServer() then
OxPlayer = Ox.GetPlayer()
end
end
-------------------------------------------------------------
-- Resource Variables for Items, Jobs, and Vehicles
-------------------------------------------------------------
@@ -186,12 +193,12 @@ elseif isStarted(OXCoreExport) then
end)
else
local TempJobs = triggerCallback(getScript()..":getOxGroups")
Jobs = TempJobs or {}
Jobs = {}
for k, v in pairs(TempJobs) do
local grades = {}
for i = 1, #v.grades do
grades[i] = { name = v.grades[i], isboss = (i == #v.grades) }
end
--for i = 1, #v.grades do
-- grades[i] = { name = v.grades[i], isboss = (i == #v.grades) }
--end
Jobs[v.name] = { label = v.label, grades = grades }
end
Gangs = Jobs

View File

@@ -64,6 +64,15 @@ function drawText(image, input, style, oxStyleTable)
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
end
ESX.TextUI(text, nil)
elseif Config.System.drawText == "jim" then
for k, v in pairs(input) do
input[k] = v.."<br>"
end
exports["jim-nui"]:drawText({
icon = nil,
text = text,
})
end
end

View File

@@ -39,15 +39,17 @@
function createInput(title, opts)
local dialog = nil
local options = {}
local currentNum = 0
if Config.System.Menu == "ox" then
for i = 1, #opts do
currentNum += 1
if opts[i] == nil then currentNum -= 1 goto skip end
if opts[i].type == "radio" then
-- Convert radio options to select type for OX
for k in pairs(opts[i].options) do
opts[i].options[k].label = opts[i].options[k].text
end
options[i] = {
options[currentNum] = {
type = "select",
isRequired = opts[i].isRequired,
label = opts[i].label or opts[i].text,
@@ -57,8 +59,8 @@ function createInput(title, opts)
}
end
if opts[i].type == "number" then
options[i] = {
type = "number",
options[currentNum] = {
type = opts[i].type,
label = (opts[i].label or opts[i].text)..(opts[i].txt and " - "..opts[i].txt or ""),
isRequired = opts[i].isRequired,
name = opts[i].name,
@@ -66,7 +68,7 @@ function createInput(title, opts)
}
end
if opts[i].type == "text" then
options[i] = {
options[currentNum] = {
type = "input",
label = opts[i].text..(opts[i].txt and " - "..opts[i].txt or ""),
default = opts[i].default,
@@ -74,8 +76,8 @@ function createInput(title, opts)
}
end
if opts[i].type == "select" then
options[i] = {
type = "select",
options[currentNum] = {
type = opts[i].type,
label = opts[i].text..(opts[i].txt and " - "..opts[i].txt or ""),
isRequired = opts[i].isRequired,
name = opts[i].name,
@@ -85,6 +87,17 @@ function createInput(title, opts)
default = opts[i].default,
}
end
if opts[i].type == "color" then
options[currentNum] = {
type = opts[i].type,
label = opts[i].label,
isRequired = opts[i].isRequired,
format = opts[i].format,
default = opts[i].default,
}
end
::skip::
end
dialog = exports[OXLibExport]:inputDialog(title, options)
return dialog

View File

@@ -10,6 +10,23 @@
When running client-side (not on the server), the module checks the player's Ped after they load.
Usage Examples:
-- Check if the player's Ped is an animal:
local animalStatus = isPedAnimal()
-- Check if a given Ped is a cat:
if isCat(somePed) then print("This is a cat!") end
-- Determine if a Ped is a dog and whether it's big or small:
local isDogFlag, isBig = isDog(somePed)
-- Retrieve a flat list of all animal model hashes:
local allAnimalModels = getAnimalModels()
File Separation Suggestion:
For scalability, consider separating this module into two files:
• AnimalDetection.lua (for functions and callbacks)
• AnimalPedsData.lua (for the AnimalPeds table)
]]
-- Global animal classification flags.

View File

@@ -61,6 +61,13 @@ function triggerNotify(title, message, type, src)
else
TriggerClientEvent(getScript()..":DisplayESXNotify", src, type, message)
end
elseif Config.System.Notify == "jim" then
if not src then
exports["jim-nui"]:Notify(type, message)
else
TriggerClientEvent("jim-nui:client:notify'", src, type, message)
end
end
end

View File

@@ -380,7 +380,8 @@ function hasJob(job, source, grade)
if info.name == job then hasJobFlag = true end
elseif isStarted(OXCoreExport) then
for k, v in pairs(exports[OXCoreExport]:GetPlayerData().groups) do
local info = OxPlayer.getGroups()
for k, v in pairs(info) do
if k == job then hasJobFlag = true break end
end
@@ -482,7 +483,9 @@ function getPlayer(source)
source = info.PlayerData.source,
job = info.PlayerData.job.name,
jobBoss = info.PlayerData.job.isboss,
jobInfo = info.PlayerData.job,
gang = info.PlayerData.gang.name,
gangInfo = info.PlayerData.gang,
gangBoss = info.PlayerData.gang.isboss,
onDuty = info.PlayerData.job.onduty,
account = info.PlayerData.charinfo.account,
@@ -500,25 +503,10 @@ function getPlayer(source)
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
}
else
local info = exports[QBExport]:GetPlayer(src).PlayerData
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
@@ -554,11 +542,23 @@ function getPlayer(source)
bank = bank,
}
elseif isStarted(OXCoreExport) then
local info = exports[OXCoreExport]:GetPlayerData()
--local info = exports[OXCoreExport]:GetPlayerData()
Player = {
name = info.firstName.." "..info.lastName,
firstname = OxPlayer.get("firstName"),
lastname = OxPlayer.get("lastName"),
name = OxPlayer.get("firstName").." "..OxPlayer.get("lastName"),
cash = exports[OXInv]:Search('count', "money"),
bank = 0,
--source = info.source,
job = OxPlayer.getGroups(),
--jobBoss = info.job.isboss,
gang = OxPlayer.getGroups(),
--gangBoss = info.gang.isboss,
--onDuty = info.job.onduty,
--account = info.charinfo.account,
citizenId = OxPlayer.get("stateId"),
}
elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayerData()
@@ -571,8 +571,10 @@ function getPlayer(source)
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
@@ -589,8 +591,10 @@ function getPlayer(source)
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,