11lib .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-
172local ESX = exports .es_extended :getSharedObject ()
183local inv = exports .ox_inventory
194local 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