-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
464 lines (429 loc) · 15 KB
/
init.lua
File metadata and controls
464 lines (429 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
ESX,QBCORE = nil, nil
shared = {}
-- ========================================
-- DEBUG MODE
-- ========================================
-- Enable verbose logging for development/troubleshooting
-- Prints shop loading, inventory validation, purchase attempts, etc.
shared.debug = false
-- ========================================
-- LANGUAGE SETTINGS
-- ========================================
-- Change language file (config/locales/%s.lua)
-- Available: 'en' for English, or create your own (e.g., 'es' for Spanish)
shared.lang = 'en'
-- ========================================
-- UI CONFIGURATION
-- ========================================
-- Use ox_inventory's built-in shop UI (experimental)
-- false = Use the full-featured custom UI (recommended)
-- true = Use ox_inventory UI (requires specific ox_inventory fork)
shared.oxShops = false
-- ========================================
-- PLAYER PERMISSIONS
-- ========================================
-- Allow shop owners to create custom items?
-- false = Only admins can add new items via /storeadmin (recommended)
-- true = Shop owners can add items (requires items to exist in ox_inventory)
shared.allowplayercreateitem = false
-- ========================================
-- TARGETING SYSTEM
-- ========================================
-- Use ox_target for shop interactions?
-- true = Modern targeting (requires ox_target) (recommended)
-- false = Use proximity markers (old-school drawtext)
shared.target = false -- FMRP: proximity text UI (ox_lib showTextUI) — ox_target disabled
-- ========================================
-- FINANCING SYSTEM (Player Loans)
-- ========================================
-- Minimum shop purchase price to enable financing option
shared.FinanceMinimum = 500000
-- Down payment percentage (20 = 20% upfront)
shared.FinanceDownPayment = 20
-- Interest rate (10 = 10% interest on remaining balance)
shared.FinanceInterest = 10
-- Maximum days to repay loan
shared.FinanceMaxDays = 30
-- Maximum total debt a player can have before being blocked from new loans
shared.MaxDebt = 1000000
-- ========================================
-- DEFAULT STOCK AMOUNTS
-- ========================================
-- How much stock each item gets when a player first buys a shop
-- Default shops (24/7, Ammunation) have INFINITE stock - this doesn't affect them
-- Only affects OWNED shops (purchasable by players)
shared.defaultStock = {
General = 100, -- 24/7 stores start with 100 of each item
Ammunation = 20, -- Gun stores start with 20 of each weapon
VehicleShop = 10, -- Vehicle dealers start with 10 of each vehicle
BlackMarketArms = 20, -- Black markets start with 20 of each item
}
-- ========================================
-- PAYMENT SETTINGS
-- ========================================
-- Where does shop revenue go?
-- false = Money stays in shop cashier (owner withdraws manually) (recommended)
-- true = Money auto-deposits to owner's bank account
shared.SendtoBank = false
shared.VehicleKeysType = {
['export'] = false, -- if false it will use trigger events
['client'] = true, -- if false it will use server event or server exports
}
shared.VehicleKeys = function(plate,source) -- vehicle keys
-- first parameter expected is plate
local sendvehiclekeys
if IsDuplicityVersion() then
if shared.VehicleKeysType['export'] then -- server export edit this if your using server exports vehicle keys
func = function()
sendvehiclekeys = exports.renzu_garage.GiveVehicleKey -- replace this
end
if pcall(func, result or false) then
return sendvehiclekeys(nil,plate,source)
end
elseif shared.VehicleKeysType['client'] and shared.VehicleKeysType['export'] then -- do not edit this condition
TriggerClientEvent('murderface-shops:Vehiclekeys', source, plate)
elseif shared.VehicleKeysType['client'] then -- client events from server edit this if your using client events vehicle keys
-- Server Events Keys
TriggerClientEvent('vehiclekeys:client:SetOwner', source, plate) -- this is non existing and example only
else -- server events from server edit this
-- Server Events Keys
-- ex TriggerEvent('GiveKeys', plate, source) -- this is non existing and example only
end
elseif not IsDuplicityVersion() then -- client exports edit this if your using exports in client
if shared.VehicleKeysType['export'] then
func = function()
sendvehiclekeys = exports.renzu_garage.GiveVehicleKey -- replace this
end
if pcall(func, result or false) then
return sendvehiclekeys(nil,plate)
end
else -- if triggered using client
TriggerEvent('vehiclekeys:client:SetOwner', plate) -- this is non existing and example only
end
end
end
-- ========================================
-- FRAMEWORK & INVENTORY (AUTO-DETECTED)
-- ========================================
-- These are set automatically based on what resources are running
-- You can manually override if needed, but usually auto-detection works fine
-- Framework: ESX, QBCORE, or QBX
-- Auto-detected based on running resources
shared.framework = 'QBCORE'
-- Inventory: ox_inventory or qb-inventory
-- Auto-detected based on running resources
shared.inventory = 'ox_inventory'
-- ========================================
-- AUTO-DETECTION (Don't edit unless you know what you're doing)
-- ========================================
-- Automatically detects and configures framework
if GetResourceState('es_extended') == 'started' then
shared.framework = 'ESX'
ESX = exports['es_extended']:getSharedObject()
print('[Murderface Shops] ESX Legacy detected')
elseif GetResourceState('qbx_core') == 'started' then
shared.framework = 'QBX'
-- QBX uses exports differently - no GetCoreObject needed
-- Functions are accessed directly via exports.qbx_core
print('[Murderface Shops] QBX Core detected')
elseif GetResourceState('qb-core') == 'started' then
shared.framework = 'QBCORE'
QBCore = exports['qb-core']:GetCoreObject()
print('[Murderface Shops] QB-Core detected')
end
-- Automatically detects inventory system
if GetResourceState('ox_inventory') == 'started' then
shared.inventory = 'ox_inventory'
print('[Murderface Shops] ox_inventory detected')
elseif GetResourceState('qb-inventory') == 'started' then
shared.inventory = 'qb-inventory'
print('[Murderface Shops] qb-inventory detected')
end
MultiCategory = function(blacklist,whitelist,data,...)
local newtable = {}
local i = 1
local whitelisted = false
for k,v in pairs(whitelist) do whitelisted = true end
if not whitelisted then
local t = {...}
for k,v in pairs(t) do
if type(v) == 'table' then
for k,v in pairs(v) do
if not blacklist[v.type] then
newtable[i] = v
i = i + 1
end
end
end
end
else
for k,v in pairs(data) do
if whitelist[v.type] then
newtable[i] = v
i = i + 1
end
end
end
return newtable
end
function request(file)
local name = ('%s.lua'):format(file)
local content = LoadResourceFile(GetCurrentResourceName(),name)
local f, err = load(content)
return f()
end
-- do not edit
shared.Storeitems = request('config/storeitems')
shared.Shops = request('config/defaultshops')
shared.OwnedShops = request('config/ownedshops/init')
shared.MovableShops = request('config/movableshop')
shared.locales = request('config/locales/'..shared.lang)
shared.playerbooth = request('config/stalls')
request('config/shipping')
-- DISABLED: Automotive shop items are now defined individually in storeitems.lua
-- No need to map to AutomotiveSupply since each shop has its own item list
-- shared.Storeitems.Bennys = shared.Storeitems.AutomotiveSupply
-- shared.Storeitems.ToxsShop = shared.Storeitems.AutomotiveSupply
-- shared.Storeitems.Flywheels = shared.Storeitems.AutomotiveSupply
-- shared.Storeitems.LSCustoms = shared.Storeitems.AutomotiveSupply
-- shared.Storeitems.SonsAuto = shared.Storeitems.AutomotiveSupply
-- DISABLED: ox_inventory handles weapon components natively; injecting the
-- murderface-shops Components table creates hundreds of broken shop entries
-- (at_skin_perseus, at_skin_camo, etc.) with no item defs or images.
-- Ammunation/BlackMarketArms items are defined in storeitems.lua instead.
-- if shared.inventory == 'ox_inventory' then
-- for k,v in pairs(Components) do
-- table.insert(shared.Storeitems.Ammunation,v)
-- table.insert(shared.Storeitems.BlackMarketArms,v)
-- end
if shared.inventory == 'qb-inventory' then
local weapons = {}
Components = {}
Citizen.CreateThreadNow(function()
Wait(1000)
-- SAFETY: Check QBCore exists before accessing
if not QBCore or not QBCore.Shared or not QBCore.Shared.Weapons then
print('[Murderface Shops] Warning: QBCore.Shared.Weapons not available, skipping weapon components loading')
return
end
local weaponshared = QBCore.Shared.Weapons
for k,v in pairs(weaponshared) do
Wait(0)
local data = exports['qb-weapons']:getConfigWeaponAttachments(v.name:upper()) -- if there is a way to fetch single all the datas of weapon atachment from qbweapons it will be more opt
if data then
for k,weapon in pairs(data) do
if not Components[weapon.item] then Components[weapon.item] = {} end
Components[weapon.item] = {
name = weapon.item,
label = weaponshared[weapon.item] and weaponshared[weapon.item].label or k,
type = weapon.type,
price = 1500,
category = 'attachments',
client = { component = {weapon.component}}
}
end
end
end
for k,v in pairs(Components) do
table.insert(shared.Storeitems.Ammunation,v)
table.insert(shared.Storeitems.BlackMarketArms,v)
end
end)
end
Utils = {}
if not IsDuplicityVersion() then
self = self or {} -- Initialize self if it doesn't exist yet
Utils.CreateMenu = function(data)
lib.registerContext({
id = data.id,
title = data.title,
onExit = function()
--data.OnExit()
end,
options = data.options
})
lib.showContext(data.id)
end
Utils.Proccesed = function(data)
lib.progressBar({
duration = data.duration,
label = data.label,
useWhileDead = false,
canCancel = false,
anim = {
dict = data.dict,
clip = data.clip
},
disable = {
car = true,
}
})
local callback = lib.callback.await('murderface-shops:proccessed',100, data)
if not callback then
lib.notify({
title = 'Not Enough Ingredients',
type = 'error'
})
end
end
self.ImagesPath = function(item)
local url = ''
if shared.inventory == 'ox_inventory' then
if item then
url = 'https://cfx-nui-ox_inventory/web/images/'..item..'.png'
else
url = 'https://cfx-nui-ox_inventory/web/images/'
end
return url
else
if item then
url = 'https://cfx-nui-qb-inventory/html/images/'..item:lower()..'.png'
else
url = 'https://cfx-nui-qb-inventory/html/images/'
end
return url
end
end
self.LoadJobShops = function()
for k,zones in pairs(self.JobSpheres) do
if zones then
if not shared.target and zones.remove then
zones:remove()
else
rzone = function()
return exports.ox_target:removeZone(zones)
end
if pcall(rzone,ret or false) then end
end
end
end
local jobshop = GlobalState.JobShop
for k,shops in pairs(shared.OwnedShops) do
for k,shop in pairs(shops) do
if self.PlayerData and self.PlayerData.job and self.PlayerData.job.name and jobshop[shop.label] == self.PlayerData.job.name then
if not shared.target then
self.temporalspheres[shop.label] = self.Add(shop.coord,'My Store '..shop.label,self.StoreOwner,false,shop)
self.JobSpheres[self.PlayerData.job.name] = self.temporalspheres[shop.label]
else
local zone = self.addTarget(shop.coord,'My Store '..shop.label,self.StoreOwner,false,shop)
self.JobSpheres[self.PlayerData.job.name] = zone
end
end
end
end
end
self.Playerloaded = function()
if shared.framework == 'ESX' then
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
self.PlayerData = xPlayer
self.LoadShops()
self.LoadJobShops()
self.LoadDefaultShops()
end)
elseif shared.framework == 'QBX' then
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(1500)
self.PlayerData = exports.qbx_core:GetPlayerData()
if self.PlayerData.job ~= nil then
self.PlayerData.job.grade = self.PlayerData.job.grade.level
end
if self.PlayerData.identifier == nil then
self.PlayerData.identifier = self.PlayerData.license
end
self.LoadShops()
self.LoadJobShops()
self.LoadDefaultShops()
end)
elseif shared.framework == 'QBCORE' then
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(1500)
self.PlayerData = QBCore.Functions.GetPlayerData()
if self.PlayerData.job ~= nil then
self.PlayerData.job.grade = self.PlayerData.job.grade.level
end
if self.PlayerData.identifier == nil then
self.PlayerData.identifier = self.PlayerData.license
end
self.LoadShops()
self.LoadJobShops()
self.LoadDefaultShops()
end)
end
end
self.GetPlayerData = function()
if shared.framework == 'ESX' then
return ESX.GetPlayerData()
elseif shared.framework == 'QBX' then
local Player = exports.qbx_core:GetPlayerData()
if Player.job ~= nil then
Player.job.grade = Player.job.grade.level
end
if Player.identifier == nil then
Player.identifier = Player.license
end
return Player
else
local Player = QBCore.Functions.GetPlayerData()
if Player.job ~= nil then
Player.job.grade = Player.job.grade.level
end
if Player.identifier == nil then
Player.identifier = Player.license
end
return Player
end
end
self.SetJob = function()
if shared.framework == 'ESX' then
RegisterNetEvent('esx:setJob', function(job)
self.PlayerData.job = job
self.LoadDefaultShops()
self.LoadJobShops()
self.LoadShops()
end)
elseif shared.framework == 'QBX' or shared.framework == 'QBCORE' then
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
self.PlayerData.job = job
self.PlayerData.job.grade = self.PlayerData.job.grade.level
self.LoadDefaultShops()
self.LoadJobShops()
self.LoadShops()
end)
end
end
self.getInventoryItems = function(name)
if shared.inventory == 'ox_inventory' then
return exports.ox_inventory:Search('count', name)
elseif shared.inventory == 'qb-inventory' then
local count = 0
local PlayerData
if shared.framework == 'QBX' then
PlayerData = exports.qbx_core:GetPlayerData()
else
PlayerData = QBCore.Functions.GetPlayerData()
end
for _, item in pairs(PlayerData.items) do
if name == item.name then
count = count + 1
end
end
return count
end
end
-- RUN RESOURCE
self.Playerloaded()
self.SetJob()
-- NOTE: Handlers() and StartUp() are defined in client/main.lua and will be called from there
-- Commenting these out to prevent errors during script loading
-- self.Handlers()
-- self.StartUp()
-- EXPORTS FOR ALL FUNCTION
exports('Shops', function ()
return self
end)
-- SHITY 3dME
RegisterCommand('bubble', function(source,args)
local Functions = exports['murderface-shops']:Shops()
Functions.CreateBubbleSpeechSync({id = GetPlayerServerId(PlayerId()), title = GetPlayerName(PlayerId()), message = args[1], bagname = 'player:', ms = 5000})
end)
end