1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-04 04:28:47 +02:00
parent 875c8448e1
commit c81ae4bb6d
219 changed files with 8036 additions and 7 deletions

View file

@ -0,0 +1,63 @@
local coreName = 'es_extended'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
RegisterNetEvent('esx:playerLoaded', function(playerId)
TriggerEvent('bl_bridge:client:playerLoaded', playerId)
end)
RegisterNetEvent('esx:onPlayerLogout', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('esx:setJob', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}})
end)
local shared = exports[coreName]:getSharedObject()
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not shared.IsPlayerLoaded() do
Wait(1000)
end
local data = originalFun()
local job = data.job
local month, day, year = data.dateofbirth and data.dateofbirth:match("(%d+)/(%d+)/(%d+)") or 00, 00, 24
return {
cid = data.identifier,
money = data.money or 0,
inventory = data.inventory or {},
job = {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}},
firstName = data.firstName or 'Unknown',
lastName = data.lastName or 'Unknown',
phone = data.phone_number or '0',
gender = data.sex == 'm' and 'male' or 'female',
dob = ('%s/%s/%s'):format(month, day, year)
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return shared.IsPlayerLoaded()
end
return Core

View file

@ -0,0 +1,74 @@
local coreName = 'ND_Core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
local jobInfo = {}
local loaded = false
RegisterNetEvent('ND:characterLoaded', function(character)
TriggerEvent('bl_bridge:client:playerLoaded')
jobInfo = character.jobInfo
jobInfo.name = character.job
loaded = true
Wait(1000)
end)
AddEventHandler("ND:characterUnloaded", function(character)
TriggerEvent('bl_bridge:client:playerUnloaded')
jobInfo = {}
loaded = false
end)
RegisterNetEvent('ND:updateCharacter', function(character)
local jobData = character.jobInfo
if character.job ~= jobInfo.name or jobInfo.rank ~= jobData.rank then
TriggerEvent('bl_bridge:client:jobUpdated', { name = character.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss or false, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } })
end
end)
local shared = exports[coreName]
local coreFunctionsOverride = {
playerData = {
originalMethod = 'getPlayer',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not loaded do
Wait(1000)
end
local data = originalFun()
local jobData = data.jobInfo
local year, month, day = data.dob:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.id,
money = data.cash,
inventory = type(data.inventory) == 'string' and json.decode(data.inventory) or data.inventory,
job = { name = data.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } },
firstName = data.firstname,
lastName = data.lastname,
phone = 'Unknown',
gender = string.lower(data.gender),
dob = ('%s/%s/%s'):format(month, day, year),
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return loaded
end
return Core

View file

@ -0,0 +1,69 @@
local Ox = require '@ox_core/lib/init'
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
LocalPlayer.state.isLoggedIn = true
AddEventHandler('ox:playerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
LocalPlayer.state.isLoggedIn = true
end)
RegisterNetEvent('bl_bridge:client:playerUnloaded',function()
LocalPlayer.state.isLoggedIn = false
end)
local function prepareJobData(job, grade)
return {name = job.name, label = job.label, onDuty = true, isBoss = job.accountRoles[tostring(grade)] == 'owner', type = job.type, grade = { name = grade, label = job.grades[grade], salary = 0 } }
end
RegisterNetEvent('ox:setGroup', function(groupName, grade)
local job = Ox.GetGroup(groupName)
TriggerEvent('bl_bridge:client:jobUpdated', prepareJobData(job, grade))
end)
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayer',
modifier = {
executeFunc = true,
effect = function(originalFun) -- TODO: lazy loading for all data, only return what need, others can be requested like get(key)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
---@type function
local get = data.get
local activeJob = get('activeGroup')
if not activeJob then return end
local grade = data.getGroup(activeJob)
local job = Ox.GetGroup(activeJob)
local group = prepareJobData(job, grade)
return {
cid = data.citizenid,
money = data.money or 0,
inventory = exports.ox_inventory:GetPlayerItems(),
job = group,
gang = group,
firstName = get('firstName') or 'Unknown',
lastName = get('lastName') or 'Unknown',
phone = get('phoneNumber') or '0000000',
gender = get('gender'),
dob = get('dateOfBirth') -- DD/MM/YYYY
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(Ox, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core

View file

@ -0,0 +1,71 @@
local coreName = 'qb-core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
end)
local shared = exports[coreName]:GetCoreObject()
local coreFunctionsOverride = {
Functions = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
local job = data.job
local gang = data.gang
local charinfo = data.charinfo
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.citizenid,
money = data.money or 0,
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
firstName = charinfo.firstname or 'Unknown',
lastName = charinfo.lastname or 'Unknown',
phone = charinfo.phone or '0000000',
gender = charinfo.gender == 1 and 'female' or 'male',
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
}
end
}
},
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core

View file

@ -0,0 +1,69 @@
local coreName = 'qbx_core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
end)
local shared = exports[coreName]
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
local job = data.job
local gang = data.gang
local charinfo = data.charinfo
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.citizenid,
money = data.money or 0,
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
firstName = charinfo.firstname or 'Unknown',
lastName = charinfo.lastname or 'Unknown',
phone = charinfo.phone or '0000000',
gender = charinfo.gender == 1 and 'female' or 'male',
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core