Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NickReagan authored Jan 30, 2025
2 parents 723b03a + 9adb33b commit 7a35e95
Show file tree
Hide file tree
Showing 15 changed files with 510 additions and 107 deletions.
13 changes: 10 additions & 3 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ RegisterNetEvent('QBCore:Client:VehicleInfo', function(info)
local hasKeys = true

if GetResourceState('qb-vehiclekeys') == 'started' then
hasKeys = exports['qb-vehiclekeys']:HasKeys()
hasKeys = exports['qb-vehiclekeys']:HasKeys(plate)
end

local data = {
Expand Down Expand Up @@ -208,15 +208,22 @@ end)

-- Client Callback
RegisterNetEvent('QBCore:Client:TriggerClientCallback', function(name, ...)
QBCore.Functions.TriggerClientCallback(name, function(...)
if not QBCore.ClientCallbacks[name] then return end

QBCore.ClientCallbacks[name](function(...)
TriggerServerEvent('QBCore:Server:TriggerClientCallback', name, ...)
end, ...)
end)

-- Server Callback
RegisterNetEvent('QBCore:Client:TriggerCallback', function(name, ...)
if QBCore.ServerCallbacks[name] then
QBCore.ServerCallbacks[name](...)
QBCore.ServerCallbacks[name].promise:resolve(...)

if QBCore.ServerCallbacks[name].callback then
QBCore.ServerCallbacks[name].callback(...)
end

QBCore.ServerCallbacks[name] = nil
end
end)
Expand Down
61 changes: 43 additions & 18 deletions client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ function QBCore.Functions.CreateClientCallback(name, cb)
QBCore.ClientCallbacks[name] = cb
end

function QBCore.Functions.TriggerClientCallback(name, cb, ...)
if not QBCore.ClientCallbacks[name] then return end
QBCore.ClientCallbacks[name](cb, ...)
end
function QBCore.Functions.TriggerCallback(name, ...)
local cb = nil
local args = { ... }

if QBCore.Shared.IsFunction(args[1]) then
cb = args[1]
table.remove(args, 1)
end

function QBCore.Functions.TriggerCallback(name, cb, ...)
QBCore.ServerCallbacks[name] = cb
TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
QBCore.ServerCallbacks[name] = {
callback = cb,
promise = promise.new()
}

TriggerServerEvent('QBCore:Server:TriggerCallback', name, table.unpack(args))

if cb == nil then
Citizen.Await(QBCore.ServerCallbacks[name].promise)
return QBCore.ServerCallbacks[name].promise.value
end
end

function QBCore.Debug(resource, obj, depth)
Expand All @@ -36,23 +48,27 @@ function QBCore.Functions.HasItem(items, amount)
return exports['qb-inventory']:HasItem(items, amount)
end

---Returns the full character name
---@return string
function QBCore.Functions.GetName()
local charinfo = QBCore.PlayerData.charinfo
return charinfo.firstname .. ' ' .. charinfo.lastname
end

---@param entity number - The entity to look at
---@param timeout number - The time in milliseconds before the function times out
---@param speed number - The speed at which the entity should turn
---@return number - The time at which the entity was looked at
function QBCore.Functions.LookAtEntity(entity, timeout, speed)
local involved = GetInvokingResource()
if not DoesEntityExist(entity) then
turnPromise:reject(involved .. ' :^1 Entity does not exist')
return turnPromise.value
return involved .. ' :^1 Entity does not exist'
end
if not type(entity) == 'number' then
turnPromise:reject(involved .. ' :^1 Entity must be a number')
return turnPromise.value
if type(entity) ~= 'number' then
return involved .. ' :^1 Entity must be a number'
end
if not type(speed) == 'number' then
turnPromise:reject(involved .. ' :^1 Speed must be a number')
return turnPromise.value
if type(speed) ~= 'number' then
return involved .. ' :^1 Speed must be a number'
end
if speed > 5.0 then speed = 5.0 end
if timeout > 5000 then timeout = 5000 end
Expand All @@ -62,7 +78,7 @@ function QBCore.Functions.LookAtEntity(entity, timeout, speed)
local dx = targetPos.x - playerPos.x
local dy = targetPos.y - playerPos.y
local targetHeading = GetHeadingFromVector_2d(dx, dy)
local turnSpeed = speed
local turnSpeed
local startTimeout = GetGameTimer()
while true do
local currentHeading = GetEntityHeading(ped)
Expand Down Expand Up @@ -569,7 +585,7 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props)
SetVehicleEngineHealth(vehicle, props.engineHealth + 0.0)
end
if props.tankHealth then
SetVehiclePetrolTankHealth(vehicle, props.tankHealth)
SetVehiclePetrolTankHealth(vehicle, props.tankHealth + 0.0)
end
if props.fuelLevel then
SetVehicleFuelLevel(vehicle, props.fuelLevel + 0.0)
Expand All @@ -578,7 +594,7 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props)
SetVehicleDirtLevel(vehicle, props.dirtLevel + 0.0)
end
if props.oilLevel then
SetVehicleOilLevel(vehicle, props.oilLevel)
SetVehicleOilLevel(vehicle, props.oilLevel + 0.0)
end
if props.color1 then
if type(props.color1) == 'number' then
Expand Down Expand Up @@ -1078,3 +1094,12 @@ function QBCore.Functions.GetGroundHash(entity)
local retval, success, endCoords, surfaceNormal, materialHash, entityHit = GetShapeTestResultEx(num)
return materialHash, entityHit, surfaceNormal, endCoords, success, retval
end

for functionName, func in pairs(QBCore.Functions) do
if type(func) == 'function' then
exports(functionName, func)
end
end

-- Access a specific function directly:
-- exports['qb-core']:Notify('Hello Player!')
48 changes: 42 additions & 6 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,46 @@ QBCore.Shared = QBShared
QBCore.ClientCallbacks = {}
QBCore.ServerCallbacks = {}

exports('GetCoreObject', function()
return QBCore
end)
-- Get the full QBCore object (default behavior):
-- local QBCore = GetCoreObject()

-- To use this export in a script instead of manifest method
-- Just put this line of code below at the very top of the script
-- local QBCore = exports['qb-core']:GetCoreObject()
-- Get only specific parts of QBCore:
-- local QBCore = GetCoreObject({'Players', 'Config'})

local function GetCoreObject(filters)
if not filters then return QBCore end
local results = {}
for i = 1, #filters do
local key = filters[i]
if QBCore[key] then
results[key] = QBCore[key]
end
end
return results
end
exports('GetCoreObject', GetCoreObject)

local function GetSharedItems()
return QBShared.Items
end
exports('GetSharedItems', GetSharedItems)

local function GetSharedVehicles()
return QBShared.Vehicles
end
exports('GetSharedVehicles', GetSharedVehicles)

local function GetSharedWeapons()
return QBShared.Weapons
end
exports('GetSharedWeapons', GetSharedWeapons)

local function GetSharedJobs()
return QBShared.Jobs
end
exports('GetSharedJobs', GetSharedJobs)

local function GetSharedGangs()
return QBShared.Gangs
end
exports('GetSharedGangs', GetSharedGangs)
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ QBConfig.StatusInterval = 5000 -- how often to check hu
QBConfig.Money = {}
QBConfig.Money.MoneyTypes = { cash = 500, bank = 5000, crypto = 0 } -- type = startamount - Add or remove money types for your server (for ex. blackmoney = 0), remember once added it will not be removed from the database!
QBConfig.Money.DontAllowMinus = { 'cash', 'crypto' } -- Money that is not allowed going in minus
QBConfig.Money.MinusLimit = -5000 -- The maximum amount you can be negative
QBConfig.Money.PayCheckTimeOut = 10 -- The time in minutes that it will give the paycheck
QBConfig.Money.PayCheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management

Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'gta5'
lua54 'yes'
author 'Kakarot'
description 'Core resource for the framework, contains all the core functionality and features'
version '1.2.6'
version '1.3.0'

shared_scripts {
'config.lua',
Expand Down
133 changes: 133 additions & 0 deletions locale/np.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
local Translations = {
error = {
not_online = 'खिलाडी अनलाइन छैन',
wrong_format = 'गलत ढाँचा',
missing_args = 'सबै तर्कहरू प्रविष्ट गरिएको छैन (x, y, z)',
missing_args2 = 'सबै तर्कहरू पूरा गर्नुपर्छ!',
no_access = 'यस आदेशको लागि पहुँच छैन',
company_too_poor = 'तपाईंको नियोक्ता टाट पल्टेको छ',
item_not_exist = 'वस्तु अवस्थित छैन',
too_heavy = 'इन्वेन्टरी धेरै भरिएको छ',
location_not_exist = 'स्थान अवस्थित छैन',
duplicate_license = '[QBCORE] - दोहोरिएको रकस्टार लाइसेन्स भेटियो',
no_valid_license = '[QBCORE] - मान्य रकस्टार लाइसेन्स भेटिएन',
not_whitelisted = '[QBCORE] - तपाईं यस सर्भरको लागि सेतो सूचीमा हुनुहुन्न',
server_already_open = 'सर्भर पहिले नै खुल्ला छ',
server_already_closed = 'सर्भर पहिले नै बन्द छ',
no_permission = 'तपाईंलाई यसका लागि अनुमति छैन।',
no_waypoint = 'वेपॉइंट सेट गरिएको छैन।',
tp_error = 'टेलिपोर्ट गर्दा त्रुटि।',
ban_table_not_found = '[QBCORE] - डाटाबेसमा प्रतिबन्ध तालिका फेला पार्न सकेन। कृपया तपाईंले SQL फाइल सही रूपमा आयात गरेको सुनिश्चित गर्नुहोस्।',
connecting_database_error = '[QBCORE] - डाटाबेससँग जडान गर्दा त्रुटि भयो। कृपया SQL सर्भर चलिरहेको छ र server.cfg फाइलमा विवरणहरू सही छन् भन्ने सुनिश्चित गर्नुहोस्।',
connecting_database_timeout = '[QBCORE] - डाटाबेस जडानले समय समाप्त गर्यो। कृपया SQL सर्भर चलिरहेको छ र server.cfg फाइलमा विवरणहरू सही छन् भन्ने सुनिश्चित गर्नुहोस्।',
},
success = {
server_opened = 'सर्भर खोलियो',
server_closed = 'सर्भर बन्द भयो',
teleported_waypoint = 'वेपॉइंटमा टेलिपोर्ट भयो।',
},
info = {
received_paycheck = 'तपाईंले $%{value} को तलब प्राप्त गर्नुभयो',
job_info = 'काम: %{value} | ग्रेड: %{value2} | ड्युटी: %{value3}',
gang_info = 'ग्याङ: %{value} | ग्रेड: %{value2}',
on_duty = 'तपाईं अब ड्युटीमा हुनुहुन्छ!',
off_duty = 'तपाईं अब ड्युटीबाट बाहिर हुनुहुन्छ!',
checking_ban = 'नमस्ते %s। हामी तपाईं प्रतिबन्धित हुनुहुन्छ कि छैन जाँच गर्दैछौं।',
join_server = 'स्वागत छ %s {Server Name} मा।',
checking_whitelisted = 'नमस्ते %s। हामी तपाईंको अनुमतिहरू जाँच्दैछौं।',
exploit_banned = 'तपाईंलाई धोकाधडीको लागि प्रतिबन्ध लगाइएको छ। थप जानकारीका लागि हाम्रो डिस्कर्ड हेर्नुहोस्: %{discord}',
exploit_dropped = 'धोकाधडीको लागि तपाईंलाई निकालिएको छ',
},
command = {
tp = {
help = 'खिलाडी वा निर्देशांकमा टेलिपोर्ट गर्नुहोस् (केवल प्रशासक)',
params = {
x = { name = 'id/x', help = 'खिलाडीको ID वा X स्थिति' },
y = { name = 'y', help = 'Y स्थिति' },
z = { name = 'z', help = 'Z स्थिति' },
},
},
tpm = { help = 'मार्करमा टेलिपोर्ट गर्नुहोस् (केवल प्रशासक)' },
togglepvp = { help = 'सर्भरमा PVP सक्रिय/निष्क्रिय गर्नुहोस् (केवल प्रशासक)' },
addpermission = {
help = 'खिलाडीलाई अनुमति दिनुहोस् (केवल देवता)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
permission = { name = 'permission', help = 'अनुमतिका स्तर' },
},
},
removepermission = {
help = 'खिलाडीबाट अनुमति हटाउनुहोस् (केवल देवता)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
permission = { name = 'permission', help = 'अनुमतिका स्तर' },
},
},
openserver = { help = 'सबैलाई सर्भर खोल्नुहोस् (केवल प्रशासक)' },
closeserver = {
help = 'अनुमति बिना मानिसहरूलाई सर्भर बन्द गर्नुहोस् (केवल प्रशासक)',
params = {
reason = { name = 'reason', help = 'बन्द गर्ने कारण (वैकल्पिक)' },
},
},
car = {
help = 'सवारी साधन उत्पन्न गर्नुहोस् (केवल प्रशासक)',
params = {
model = { name = 'model', help = 'सवारी साधनको मोडल नाम' },
},
},
dv = { help = 'सवारी साधन मेटाउनुहोस् (केवल प्रशासक)' },
dvall = { help = 'सबै सवारी साधन मेटाउनुहोस् (केवल प्रशासक)' },
dvp = { help = 'सबै NPC मेटाउनुहोस् (केवल प्रशासक)' },
dvo = { help = 'सबै वस्तुहरू मेटाउनुहोस् (केवल प्रशासक)' },
givemoney = {
help = 'खिलाडीलाई पैसा दिनुहोस् (केवल प्रशासक)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
moneytype = { name = 'moneytype', help = 'पैसाको प्रकार (नगद, बैंक, क्रिप्टो)' },
amount = { name = 'amount', help = 'पैसाको रकम' },
},
},
setmoney = {
help = 'खिलाडीको पैसा सेट गर्नुहोस् (केवल प्रशासक)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
moneytype = { name = 'moneytype', help = 'पैसाको प्रकार (नगद, बैंक, क्रिप्टो)' },
amount = { name = 'amount', help = 'पैसाको रकम' },
},
},
job = { help = 'तपाईंको काम जाँच्नुहोस्' },
setjob = {
help = 'खिलाडीलाई काम दिनुहोस् (केवल प्रशासक)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
job = { name = 'job', help = 'कामको नाम' },
grade = { name = 'grade', help = 'कामको स्तर' },
},
},
gang = { help = 'तपाईंको ग्याङ जाँच्नुहोस्' },
setgang = {
help = 'खिलाडीलाई ग्याङ दिनुहोस् (केवल प्रशासक)',
params = {
id = { name = 'id', help = 'खिलाडीको ID' },
gang = { name = 'gang', help = 'ग्याङको नाम' },
grade = { name = 'grade', help = 'ग्याङको स्तर' },
},
},
ooc = { help = 'OOC च्याट सन्देश' },
me = {
help = 'स्थानीय सन्देश देखाउनुहोस्',
params = {
message = { name = 'message', help = 'पठाउनको लागि सन्देश' }
},
},
},
}

if GetConvar('qb_locale', 'en') == 'np' then
Lang = Locale:new({
phrases = Translations,
warnOnMissing = true,
fallbackLang = Locale:new({ phrases = {}, warnOnMissing = true }) -- Fallback to empty locale if needed
})
end
Loading

0 comments on commit 7a35e95

Please sign in to comment.