Skip to content

Commit 7a35e95

Browse files
authored
Merge branch 'main' into main
2 parents 723b03a + 9adb33b commit 7a35e95

15 files changed

+510
-107
lines changed

client/events.lua

+10-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ RegisterNetEvent('QBCore:Client:VehicleInfo', function(info)
164164
local hasKeys = true
165165

166166
if GetResourceState('qb-vehiclekeys') == 'started' then
167-
hasKeys = exports['qb-vehiclekeys']:HasKeys()
167+
hasKeys = exports['qb-vehiclekeys']:HasKeys(plate)
168168
end
169169

170170
local data = {
@@ -208,15 +208,22 @@ end)
208208

209209
-- Client Callback
210210
RegisterNetEvent('QBCore:Client:TriggerClientCallback', function(name, ...)
211-
QBCore.Functions.TriggerClientCallback(name, function(...)
211+
if not QBCore.ClientCallbacks[name] then return end
212+
213+
QBCore.ClientCallbacks[name](function(...)
212214
TriggerServerEvent('QBCore:Server:TriggerClientCallback', name, ...)
213215
end, ...)
214216
end)
215217

216218
-- Server Callback
217219
RegisterNetEvent('QBCore:Client:TriggerCallback', function(name, ...)
218220
if QBCore.ServerCallbacks[name] then
219-
QBCore.ServerCallbacks[name](...)
221+
QBCore.ServerCallbacks[name].promise:resolve(...)
222+
223+
if QBCore.ServerCallbacks[name].callback then
224+
QBCore.ServerCallbacks[name].callback(...)
225+
end
226+
220227
QBCore.ServerCallbacks[name] = nil
221228
end
222229
end)

client/functions.lua

+43-18
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@ function QBCore.Functions.CreateClientCallback(name, cb)
66
QBCore.ClientCallbacks[name] = cb
77
end
88

9-
function QBCore.Functions.TriggerClientCallback(name, cb, ...)
10-
if not QBCore.ClientCallbacks[name] then return end
11-
QBCore.ClientCallbacks[name](cb, ...)
12-
end
9+
function QBCore.Functions.TriggerCallback(name, ...)
10+
local cb = nil
11+
local args = { ... }
12+
13+
if QBCore.Shared.IsFunction(args[1]) then
14+
cb = args[1]
15+
table.remove(args, 1)
16+
end
1317

14-
function QBCore.Functions.TriggerCallback(name, cb, ...)
15-
QBCore.ServerCallbacks[name] = cb
16-
TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
18+
QBCore.ServerCallbacks[name] = {
19+
callback = cb,
20+
promise = promise.new()
21+
}
22+
23+
TriggerServerEvent('QBCore:Server:TriggerCallback', name, table.unpack(args))
24+
25+
if cb == nil then
26+
Citizen.Await(QBCore.ServerCallbacks[name].promise)
27+
return QBCore.ServerCallbacks[name].promise.value
28+
end
1729
end
1830

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

51+
---Returns the full character name
52+
---@return string
53+
function QBCore.Functions.GetName()
54+
local charinfo = QBCore.PlayerData.charinfo
55+
return charinfo.firstname .. ' ' .. charinfo.lastname
56+
end
57+
3958
---@param entity number - The entity to look at
4059
---@param timeout number - The time in milliseconds before the function times out
4160
---@param speed number - The speed at which the entity should turn
4261
---@return number - The time at which the entity was looked at
4362
function QBCore.Functions.LookAtEntity(entity, timeout, speed)
4463
local involved = GetInvokingResource()
4564
if not DoesEntityExist(entity) then
46-
turnPromise:reject(involved .. ' :^1 Entity does not exist')
47-
return turnPromise.value
65+
return involved .. ' :^1 Entity does not exist'
4866
end
49-
if not type(entity) == 'number' then
50-
turnPromise:reject(involved .. ' :^1 Entity must be a number')
51-
return turnPromise.value
67+
if type(entity) ~= 'number' then
68+
return involved .. ' :^1 Entity must be a number'
5269
end
53-
if not type(speed) == 'number' then
54-
turnPromise:reject(involved .. ' :^1 Speed must be a number')
55-
return turnPromise.value
70+
if type(speed) ~= 'number' then
71+
return involved .. ' :^1 Speed must be a number'
5672
end
5773
if speed > 5.0 then speed = 5.0 end
5874
if timeout > 5000 then timeout = 5000 end
@@ -62,7 +78,7 @@ function QBCore.Functions.LookAtEntity(entity, timeout, speed)
6278
local dx = targetPos.x - playerPos.x
6379
local dy = targetPos.y - playerPos.y
6480
local targetHeading = GetHeadingFromVector_2d(dx, dy)
65-
local turnSpeed = speed
81+
local turnSpeed
6682
local startTimeout = GetGameTimer()
6783
while true do
6884
local currentHeading = GetEntityHeading(ped)
@@ -569,7 +585,7 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props)
569585
SetVehicleEngineHealth(vehicle, props.engineHealth + 0.0)
570586
end
571587
if props.tankHealth then
572-
SetVehiclePetrolTankHealth(vehicle, props.tankHealth)
588+
SetVehiclePetrolTankHealth(vehicle, props.tankHealth + 0.0)
573589
end
574590
if props.fuelLevel then
575591
SetVehicleFuelLevel(vehicle, props.fuelLevel + 0.0)
@@ -578,7 +594,7 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props)
578594
SetVehicleDirtLevel(vehicle, props.dirtLevel + 0.0)
579595
end
580596
if props.oilLevel then
581-
SetVehicleOilLevel(vehicle, props.oilLevel)
597+
SetVehicleOilLevel(vehicle, props.oilLevel + 0.0)
582598
end
583599
if props.color1 then
584600
if type(props.color1) == 'number' then
@@ -1078,3 +1094,12 @@ function QBCore.Functions.GetGroundHash(entity)
10781094
local retval, success, endCoords, surfaceNormal, materialHash, entityHit = GetShapeTestResultEx(num)
10791095
return materialHash, entityHit, surfaceNormal, endCoords, success, retval
10801096
end
1097+
1098+
for functionName, func in pairs(QBCore.Functions) do
1099+
if type(func) == 'function' then
1100+
exports(functionName, func)
1101+
end
1102+
end
1103+
1104+
-- Access a specific function directly:
1105+
-- exports['qb-core']:Notify('Hello Player!')

client/main.lua

+42-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,46 @@ QBCore.Shared = QBShared
55
QBCore.ClientCallbacks = {}
66
QBCore.ServerCallbacks = {}
77

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

12-
-- To use this export in a script instead of manifest method
13-
-- Just put this line of code below at the very top of the script
14-
-- local QBCore = exports['qb-core']:GetCoreObject()
11+
-- Get only specific parts of QBCore:
12+
-- local QBCore = GetCoreObject({'Players', 'Config'})
13+
14+
local function GetCoreObject(filters)
15+
if not filters then return QBCore end
16+
local results = {}
17+
for i = 1, #filters do
18+
local key = filters[i]
19+
if QBCore[key] then
20+
results[key] = QBCore[key]
21+
end
22+
end
23+
return results
24+
end
25+
exports('GetCoreObject', GetCoreObject)
26+
27+
local function GetSharedItems()
28+
return QBShared.Items
29+
end
30+
exports('GetSharedItems', GetSharedItems)
31+
32+
local function GetSharedVehicles()
33+
return QBShared.Vehicles
34+
end
35+
exports('GetSharedVehicles', GetSharedVehicles)
36+
37+
local function GetSharedWeapons()
38+
return QBShared.Weapons
39+
end
40+
exports('GetSharedWeapons', GetSharedWeapons)
41+
42+
local function GetSharedJobs()
43+
return QBShared.Jobs
44+
end
45+
exports('GetSharedJobs', GetSharedJobs)
46+
47+
local function GetSharedGangs()
48+
return QBShared.Gangs
49+
end
50+
exports('GetSharedGangs', GetSharedGangs)

config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ QBConfig.StatusInterval = 5000 -- how often to check hu
88
QBConfig.Money = {}
99
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!
1010
QBConfig.Money.DontAllowMinus = { 'cash', 'crypto' } -- Money that is not allowed going in minus
11+
QBConfig.Money.MinusLimit = -5000 -- The maximum amount you can be negative
1112
QBConfig.Money.PayCheckTimeOut = 10 -- The time in minutes that it will give the paycheck
1213
QBConfig.Money.PayCheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management
1314

fxmanifest.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ game 'gta5'
33
lua54 'yes'
44
author 'Kakarot'
55
description 'Core resource for the framework, contains all the core functionality and features'
6-
version '1.2.6'
6+
version '1.3.0'
77

88
shared_scripts {
99
'config.lua',

locale/np.lua

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
local Translations = {
2+
error = {
3+
not_online = 'खिलाडी अनलाइन छैन',
4+
wrong_format = 'गलत ढाँचा',
5+
missing_args = 'सबै तर्कहरू प्रविष्ट गरिएको छैन (x, y, z)',
6+
missing_args2 = 'सबै तर्कहरू पूरा गर्नुपर्छ!',
7+
no_access = 'यस आदेशको लागि पहुँच छैन',
8+
company_too_poor = 'तपाईंको नियोक्ता टाट पल्टेको छ',
9+
item_not_exist = 'वस्तु अवस्थित छैन',
10+
too_heavy = 'इन्वेन्टरी धेरै भरिएको छ',
11+
location_not_exist = 'स्थान अवस्थित छैन',
12+
duplicate_license = '[QBCORE] - दोहोरिएको रकस्टार लाइसेन्स भेटियो',
13+
no_valid_license = '[QBCORE] - मान्य रकस्टार लाइसेन्स भेटिएन',
14+
not_whitelisted = '[QBCORE] - तपाईं यस सर्भरको लागि सेतो सूचीमा हुनुहुन्न',
15+
server_already_open = 'सर्भर पहिले नै खुल्ला छ',
16+
server_already_closed = 'सर्भर पहिले नै बन्द छ',
17+
no_permission = 'तपाईंलाई यसका लागि अनुमति छैन।',
18+
no_waypoint = 'वेपॉइंट सेट गरिएको छैन।',
19+
tp_error = 'टेलिपोर्ट गर्दा त्रुटि।',
20+
ban_table_not_found = '[QBCORE] - डाटाबेसमा प्रतिबन्ध तालिका फेला पार्न सकेन। कृपया तपाईंले SQL फाइल सही रूपमा आयात गरेको सुनिश्चित गर्नुहोस्।',
21+
connecting_database_error = '[QBCORE] - डाटाबेससँग जडान गर्दा त्रुटि भयो। कृपया SQL सर्भर चलिरहेको छ र server.cfg फाइलमा विवरणहरू सही छन् भन्ने सुनिश्चित गर्नुहोस्।',
22+
connecting_database_timeout = '[QBCORE] - डाटाबेस जडानले समय समाप्त गर्यो। कृपया SQL सर्भर चलिरहेको छ र server.cfg फाइलमा विवरणहरू सही छन् भन्ने सुनिश्चित गर्नुहोस्।',
23+
},
24+
success = {
25+
server_opened = 'सर्भर खोलियो',
26+
server_closed = 'सर्भर बन्द भयो',
27+
teleported_waypoint = 'वेपॉइंटमा टेलिपोर्ट भयो।',
28+
},
29+
info = {
30+
received_paycheck = 'तपाईंले $%{value} को तलब प्राप्त गर्नुभयो',
31+
job_info = 'काम: %{value} | ग्रेड: %{value2} | ड्युटी: %{value3}',
32+
gang_info = 'ग्याङ: %{value} | ग्रेड: %{value2}',
33+
on_duty = 'तपाईं अब ड्युटीमा हुनुहुन्छ!',
34+
off_duty = 'तपाईं अब ड्युटीबाट बाहिर हुनुहुन्छ!',
35+
checking_ban = 'नमस्ते %s। हामी तपाईं प्रतिबन्धित हुनुहुन्छ कि छैन जाँच गर्दैछौं।',
36+
join_server = 'स्वागत छ %s {Server Name} मा।',
37+
checking_whitelisted = 'नमस्ते %s। हामी तपाईंको अनुमतिहरू जाँच्दैछौं।',
38+
exploit_banned = 'तपाईंलाई धोकाधडीको लागि प्रतिबन्ध लगाइएको छ। थप जानकारीका लागि हाम्रो डिस्कर्ड हेर्नुहोस्: %{discord}',
39+
exploit_dropped = 'धोकाधडीको लागि तपाईंलाई निकालिएको छ',
40+
},
41+
command = {
42+
tp = {
43+
help = 'खिलाडी वा निर्देशांकमा टेलिपोर्ट गर्नुहोस् (केवल प्रशासक)',
44+
params = {
45+
x = { name = 'id/x', help = 'खिलाडीको ID वा X स्थिति' },
46+
y = { name = 'y', help = 'Y स्थिति' },
47+
z = { name = 'z', help = 'Z स्थिति' },
48+
},
49+
},
50+
tpm = { help = 'मार्करमा टेलिपोर्ट गर्नुहोस् (केवल प्रशासक)' },
51+
togglepvp = { help = 'सर्भरमा PVP सक्रिय/निष्क्रिय गर्नुहोस् (केवल प्रशासक)' },
52+
addpermission = {
53+
help = 'खिलाडीलाई अनुमति दिनुहोस् (केवल देवता)',
54+
params = {
55+
id = { name = 'id', help = 'खिलाडीको ID' },
56+
permission = { name = 'permission', help = 'अनुमतिका स्तर' },
57+
},
58+
},
59+
removepermission = {
60+
help = 'खिलाडीबाट अनुमति हटाउनुहोस् (केवल देवता)',
61+
params = {
62+
id = { name = 'id', help = 'खिलाडीको ID' },
63+
permission = { name = 'permission', help = 'अनुमतिका स्तर' },
64+
},
65+
},
66+
openserver = { help = 'सबैलाई सर्भर खोल्नुहोस् (केवल प्रशासक)' },
67+
closeserver = {
68+
help = 'अनुमति बिना मानिसहरूलाई सर्भर बन्द गर्नुहोस् (केवल प्रशासक)',
69+
params = {
70+
reason = { name = 'reason', help = 'बन्द गर्ने कारण (वैकल्पिक)' },
71+
},
72+
},
73+
car = {
74+
help = 'सवारी साधन उत्पन्न गर्नुहोस् (केवल प्रशासक)',
75+
params = {
76+
model = { name = 'model', help = 'सवारी साधनको मोडल नाम' },
77+
},
78+
},
79+
dv = { help = 'सवारी साधन मेटाउनुहोस् (केवल प्रशासक)' },
80+
dvall = { help = 'सबै सवारी साधन मेटाउनुहोस् (केवल प्रशासक)' },
81+
dvp = { help = 'सबै NPC मेटाउनुहोस् (केवल प्रशासक)' },
82+
dvo = { help = 'सबै वस्तुहरू मेटाउनुहोस् (केवल प्रशासक)' },
83+
givemoney = {
84+
help = 'खिलाडीलाई पैसा दिनुहोस् (केवल प्रशासक)',
85+
params = {
86+
id = { name = 'id', help = 'खिलाडीको ID' },
87+
moneytype = { name = 'moneytype', help = 'पैसाको प्रकार (नगद, बैंक, क्रिप्टो)' },
88+
amount = { name = 'amount', help = 'पैसाको रकम' },
89+
},
90+
},
91+
setmoney = {
92+
help = 'खिलाडीको पैसा सेट गर्नुहोस् (केवल प्रशासक)',
93+
params = {
94+
id = { name = 'id', help = 'खिलाडीको ID' },
95+
moneytype = { name = 'moneytype', help = 'पैसाको प्रकार (नगद, बैंक, क्रिप्टो)' },
96+
amount = { name = 'amount', help = 'पैसाको रकम' },
97+
},
98+
},
99+
job = { help = 'तपाईंको काम जाँच्नुहोस्' },
100+
setjob = {
101+
help = 'खिलाडीलाई काम दिनुहोस् (केवल प्रशासक)',
102+
params = {
103+
id = { name = 'id', help = 'खिलाडीको ID' },
104+
job = { name = 'job', help = 'कामको नाम' },
105+
grade = { name = 'grade', help = 'कामको स्तर' },
106+
},
107+
},
108+
gang = { help = 'तपाईंको ग्याङ जाँच्नुहोस्' },
109+
setgang = {
110+
help = 'खिलाडीलाई ग्याङ दिनुहोस् (केवल प्रशासक)',
111+
params = {
112+
id = { name = 'id', help = 'खिलाडीको ID' },
113+
gang = { name = 'gang', help = 'ग्याङको नाम' },
114+
grade = { name = 'grade', help = 'ग्याङको स्तर' },
115+
},
116+
},
117+
ooc = { help = 'OOC च्याट सन्देश' },
118+
me = {
119+
help = 'स्थानीय सन्देश देखाउनुहोस्',
120+
params = {
121+
message = { name = 'message', help = 'पठाउनको लागि सन्देश' }
122+
},
123+
},
124+
},
125+
}
126+
127+
if GetConvar('qb_locale', 'en') == 'np' then
128+
Lang = Locale:new({
129+
phrases = Translations,
130+
warnOnMissing = true,
131+
fallbackLang = Locale:new({ phrases = {}, warnOnMissing = true }) -- Fallback to empty locale if needed
132+
})
133+
end

0 commit comments

Comments
 (0)