Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit c6a4f2d

Browse files
committed
fix: remove loadouts
one would think you shouldn't run commented code, yet here we are.
1 parent 3c0fa4e commit c6a4f2d

3 files changed

Lines changed: 1 addition & 136 deletions

File tree

client.lua

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -210,81 +210,6 @@ local function init()
210210
menu = ('sync_armory:%s:armor'):format(type)
211211
}
212212
end
213-
--[[
214-
if Config.Loadouts then
215-
main[#main + 1] = {
216-
title = 'Loadouts',
217-
icon = 'backpack',
218-
arrow = true,
219-
onSelect = function()
220-
local options = {}
221-
local response = lib.callback.await('sync_armory:fetchLoadouts')
222-
if not response then
223-
options[#options + 1] = {
224-
title = 'No Loadouts Found',
225-
icon = 'backpack',
226-
disabled = true
227-
}
228-
else
229-
for _, loadout in pairs(response) do
230-
options[#options + 1] = {
231-
title = loadout.name,
232-
onSelect = function()
233-
TriggerServerEvent('sync_armory:getLoadout', loadout.loadoutId)
234-
end,
235-
icon = 'backpack',
236-
}
237-
end
238-
end
239-
options[#options + 1] = {
240-
title = 'Create Loadout',
241-
icon = 'plus',
242-
onSelect = function()
243-
local rows = {}
244-
rows[1] = {
245-
type = 'input',
246-
label = 'Name',
247-
required = true,
248-
}
249-
local selection = {}
250-
for _, weapon in pairs(Config.Weapons[type]) do
251-
selection[#selection + 1] ={
252-
label = weapon.label,
253-
value = weapon.item,
254-
}
255-
end
256-
rows[2] = {
257-
type = 'multi-select',
258-
label = 'Select Weapons',
259-
icon = 'gun',
260-
required = true,
261-
options = selection
262-
}
263-
local input = lib.inputDialog('Create Loadout', rows)
264-
if not input then return end
265-
local weapons = {}
266-
local selectedWeapons = input[2]
267-
---@diagnostic disable-next-line: param-type-mismatch
268-
for _, weapon in pairs(selectedWeapons) do
269-
weapons[#weapons + 1] = weapon
270-
end
271-
TriggerServerEvent('sync_armory:registerLoadout', {
272-
name = input[1],
273-
weapons = weapons
274-
})
275-
end
276-
}
277-
lib.registerContext({
278-
id = 'sync_armory:loadouts',
279-
title = Lang('armory_name'),
280-
menu = ('sync_armory:%s:main'):format(type),
281-
options = options
282-
})
283-
lib.showContext('sync_armory:loadouts')
284-
end,
285-
}
286-
end
287-
]]
288213
lib.registerContext({
289214
id = ('sync_armory:%s'):format(type),
290215
title = Lang('armory_name'),

config.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Config.Armor = {
4040
Config.Passwords = {
4141
['swat'] = 'CHANGE_ME', -- SWAT PASSWORD
4242
}
43-
Config.Loadouts = true -- Enable Loadouts
4443
Config.UseTarget = true -- Set to false to use markers
4544
Config.Locations = {
4645
['main'] = {

server.lua

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
lib.versionCheck('unitysync/sync_armory')
2-
CreateThread(function()
3-
local success, _ = pcall(MySQL.scalar.await, 'SELECT 1 FROM armory')
4-
if not success then
5-
MySQL.query([[
6-
CREATE TABLE `armory`(
7-
`loadoutId` AUTOINCREMENT NOT NULL,
8-
`owner` TINYTEXT NOT NULL,
9-
`loadout` TEXT NOT NULL,
10-
`name` TINYTEXT NOT NULL,
11-
)
12-
primary key (`loadoutId`)
13-
]])
14-
end
15-
end)
16-
172
local ESX = exports.es_extended:getSharedObject()
183
local inv = exports.ox_inventory
194
local webhook = 'CHANGE_ME' -- Set to false to disable webhook.
@@ -111,48 +96,4 @@ RegisterNetEvent('sync_armory:getItems', function(item, count)
11196
end
11297
end
11398
end
114-
end)
115-
116-
117-
RegisterNetEvent('sync_armory:registerLoadout', function(data)
118-
if not data or type(data) ~= 'table' then return end
119-
local xPlayer = ESX.GetPlayerFromId(source)
120-
if not xPlayer?.getJob().name == 'police' then return end
121-
122-
-- Todo: Add validation for adding loadout
123-
124-
MySQL.insert.await('INSERT INTO armory (owner, loadout, name) VALUES (@owner, @loadout)', {
125-
['@owner'] = xPlayer.identifier,
126-
['@loadout'] = json.encode(data.weapons),
127-
['@name'] = data.name
128-
})
129-
end)
130-
--[[ ! WIP ! has not been tested. likely non-functional
131-
RegisterNetEvent('sync_armory:getLoadout', function(loadoutId)
132-
local xPlayer = ESX.GetPlayerFromId(source)
133-
local response = MySQL.query.await('SELECT loadout FROM armory WHERE (loadoutId = @loadoutId AND owner = @owner)', {
134-
['@loadoutId'] = loadoutId,
135-
['@owner'] = xPlayer.identifier
136-
})
137-
if response[1] then
138-
for _, v in pairs(response[1]) do
139-
for __, weapons in pairs(Config.Weapons) do
140-
for ___, w in pairs(weapons) do
141-
if v == w.item then
142-
inv:AddItem(source, v, 1, {components = w.components})
143-
end
144-
end
145-
end
146-
end
147-
end
148-
end)
149-
150-
lib.callback.register('sync_armory:fetchLoadouts', function(source)
151-
local xPlayer = ESX.GetPlayerFromId(source)
152-
if not xPlayer?.getJob().name == 'police' then return end
153-
local response = MySQL.query.await('SELECT FROM armory WHERE owner = @owner', {
154-
['@owner'] = xPlayer.identifier
155-
})
156-
return response
157-
end)
158-
]]
99+
end)

0 commit comments

Comments
 (0)