├── html
├── sound.mp3
├── cloth
│ ├── dl.png
│ ├── heart.svg
│ ├── watch.svg
│ ├── shield.svg
│ ├── glasses.svg
│ ├── pants.svg
│ ├── shoes.svg
│ ├── vest.svg
│ ├── shirt.svg
│ ├── hat.svg
│ ├── jacket.svg
│ ├── mask.svg
│ └── chain.svg
├── idcard.png
├── verdana.ttf
├── VerdanaBold.ttf
├── ammo_images
│ ├── smg_ammo.png
│ ├── pistol_ammo.png
│ ├── rifle_ammo.png
│ └── shotgun_ammo.png
├── ui.html
└── css
│ └── main.css
├── __resource.lua
├── README.md
├── client
├── cloth.lua
└── main.lua
├── config.lua
└── server
└── main.lua
/html/sound.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/sound.mp3
--------------------------------------------------------------------------------
/html/cloth/dl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/cloth/dl.png
--------------------------------------------------------------------------------
/html/idcard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/idcard.png
--------------------------------------------------------------------------------
/html/verdana.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/verdana.ttf
--------------------------------------------------------------------------------
/html/VerdanaBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/VerdanaBold.ttf
--------------------------------------------------------------------------------
/html/ammo_images/smg_ammo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/ammo_images/smg_ammo.png
--------------------------------------------------------------------------------
/html/ammo_images/pistol_ammo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/ammo_images/pistol_ammo.png
--------------------------------------------------------------------------------
/html/ammo_images/rifle_ammo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/ammo_images/rifle_ammo.png
--------------------------------------------------------------------------------
/html/ammo_images/shotgun_ammo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AxisGe0/ax-inventory-v6/HEAD/html/ammo_images/shotgun_ammo.png
--------------------------------------------------------------------------------
/html/cloth/heart.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/__resource.lua:
--------------------------------------------------------------------------------
1 | resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"
2 |
3 | description 'Qbus:Inventory'
4 |
5 | server_scripts {
6 | "config.lua",
7 | "server/main.lua",
8 | }
9 |
10 | client_scripts {
11 | "config.lua",
12 | "client/main.lua",
13 | "client/cloth.lua"
14 | }
15 |
16 | ui_page {
17 | 'html/ui.html'
18 | }
19 |
20 | files {
21 | 'html/ui.html',
22 | 'html/css/main.css',
23 | 'html/js/app.js',
24 | 'html/images/*.png',
25 | 'html/images/*.jpg',
26 | 'html/ammo_images/*.png',
27 | 'html/attachment_images/*.png',
28 | 'html/*.ttf',
29 | 'html/cloth/*.png',
30 | 'html/cloth/*.svg',
31 | 'html/sound.mp3'
32 | }
--------------------------------------------------------------------------------
/html/cloth/watch.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/shield.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/html/cloth/glasses.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/pants.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **This is rework of qb-inventory**
2 |
3 | > **I made this inventory 5 months ago for my own roleplay server and i have decided to release this today because i am switching over to my own framework from qb and this inventory has no use for me anymore, all known glitches are fixed in this inventory and none are found**
4 |
5 | **Features**
6 | **-All Features that qb-inventory has +**
7 | **-real-time ped interface clothing menu**
8 | **-Player hud**
9 | **-Better user-interface**
10 | **-No Glitches**
11 |
12 | **Dependencies
13 | DP-Emotes: Link**
14 | **DP-Clothing: Link**
15 |
16 | So here it is
17 | **Github**
18 | **Preview**
19 |
20 | **This still uses ghmattisql,you can pr in github for oxmysql, Thanks**
21 |
--------------------------------------------------------------------------------
/html/cloth/shoes.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/vest.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/shirt.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/hat.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/jacket.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/cloth/mask.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/cloth.lua:
--------------------------------------------------------------------------------
1 | inClothMenu = false
2 | function OpenPedClothMenu()
3 | TriggerServerEvent("inventory:server:OpenInventory")
4 | SendNUIMessage({action = "cloth"})
5 | CreatePedScreen(true)
6 | end
7 | function CreatePedScreen(first)
8 | CreateThread(function()
9 | local heading = GetEntityHeading(PlayerPedId())
10 | SetFrontendActive(true)
11 | ActivateFrontendMenu(GetHashKey("FE_MENU_VERSION_JOINING_SCREEN"), true, -1)
12 | Wait(100)
13 | SetMouseCursorVisibleInMenus(false)
14 | PlayerPedPreview = ClonePed(PlayerPedId(), heading, true, false)
15 | local x, y, z = table.unpack(GetEntityCoords(PlayerPedPreview))
16 | SetEntityCoords(PlayerPedPreview, x, y, z - 10)
17 | FreezeEntityPosition(PlayerPedPreview, true)
18 | SetEntityVisible(PlayerPedPreview, false, false)
19 | NetworkSetEntityInvisibleToNetwork(PlayerPedPreview, false)
20 | Wait(200)
21 | SetPedAsNoLongerNeeded(PlayerPedPreview)
22 | GivePedToPauseMenu(PlayerPedPreview, 2)
23 | SetPauseMenuPedLighting(true)
24 | if first then
25 | SetPauseMenuPedSleepState(false)
26 | Wait(1000)
27 | SetPauseMenuPedSleepState(true)
28 | else
29 | SetPauseMenuPedSleepState(true)
30 | end
31 | end)
32 | end
33 | function DeletePedScreen()
34 | DeleteEntity(PlayerPedPreview)
35 | SetFrontendActive(false)
36 | end
37 | function RefreshPedScreen()
38 | if DoesEntityExist(PlayerPedPreview) then
39 | DeletePedScreen()
40 | Wait(500)
41 | if inInventory or inClothMenu then
42 | CreatePedScreen(false)
43 | end
44 | end
45 | end
46 | RegisterNUICallback("ChangeComponent",function(data)
47 | ExecuteCommand(data.component)
48 | Wait(1000)
49 | RefreshPedScreen()
50 | end)
51 | RegisterNUICallback("OpenClothMenu",function(data)
52 | if data.delete then
53 | OpenPedClothMenu()
54 | inClothMenu = true
55 | elseif not data.close then
56 | DeletePedScreen()
57 | inClothMenu = false
58 | end
59 | end)
--------------------------------------------------------------------------------
/html/cloth/chain.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/html/ui.html:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
Player
28 |

29 |
34 |
35 |
36 |
37 |

38 |
43 |
44 |
45 |
46 |
47 |
48 |

49 |
50 |
51 |
52 |

53 |
54 |
55 |
56 |
57 |
58 |
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 |
103 |
104 |
105 |
106 |
Pistol | 9mm
107 |
This is a water gun yaay ...
108 |
Serial Number 12345678
Durability
109 |

110 |
Attachments
111 |
112 |
113 |
114 |
115 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/config.lua:
--------------------------------------------------------------------------------
1 | Config = {}
2 |
3 | local StringCharset = {}
4 | local NumberCharset = {}
5 |
6 | for i = 48, 57 do table.insert(NumberCharset, string.char(i)) end
7 | for i = 65, 90 do table.insert(StringCharset, string.char(i)) end
8 | for i = 97, 122 do table.insert(StringCharset, string.char(i)) end
9 |
10 | Config.RandomStr = function(length)
11 | if length > 0 then
12 | return Config.RandomStr(length-1) .. StringCharset[math.random(1, #StringCharset)]
13 | else
14 | return ''
15 | end
16 | end
17 |
18 | Config.RandomInt = function(length)
19 | if length > 0 then
20 | return Config.RandomInt(length-1) .. NumberCharset[math.random(1, #NumberCharset)]
21 | else
22 | return ''
23 | end
24 | end
25 |
26 | Config.VendingObjects = {
27 | "prop_vend_soda_01",
28 | "prop_vend_soda_02",
29 | "prop_vend_water_01"
30 | }
31 |
32 | Config.BinObjects = {
33 | "prop_bin_05a",
34 | }
35 |
36 | Config.VendingItem = {
37 | [1] = {
38 | name = "kurkakola",
39 | price = 4,
40 | amount = 50,
41 | info = {},
42 | type = "item",
43 | slot = 1,
44 | },
45 | [2] = {
46 | name = "water_bottle",
47 | price = 4,
48 | amount = 50,
49 | info = {},
50 | type = "item",
51 | slot = 2,
52 | },
53 | }
54 |
55 | Config.CraftingItems = {
56 | [1] = {
57 | name = "lockpick",
58 | amount = 50,
59 | info = {},
60 | costs = {
61 | ["metalscrap"] = 22,
62 | ["plastic"] = 32,
63 | },
64 | type = "item",
65 | slot = 1,
66 | threshold = 0,
67 | points = 1,
68 | },
69 | [2] = {
70 | name = "screwdriverset",
71 | amount = 50,
72 | info = {},
73 | costs = {
74 | ["metalscrap"] = 30,
75 | ["plastic"] = 42,
76 | },
77 | type = "item",
78 | slot = 2,
79 | threshold = 0,
80 | points = 2,
81 | },
82 | [3] = {
83 | name = "electronickit",
84 | amount = 50,
85 | info = {},
86 | costs = {
87 | ["metalscrap"] = 30,
88 | ["plastic"] = 45,
89 | ["aluminum"] = 28,
90 | },
91 | type = "item",
92 | slot = 3,
93 | threshold = 0,
94 | points = 3,
95 | },
96 | [4] = {
97 | name = "radioscanner",
98 | amount = 50,
99 | info = {},
100 | costs = {
101 | ["electronickit"] = 2,
102 | ["plastic"] = 52,
103 | ["steel"] = 40,
104 | },
105 | type = "item",
106 | slot = 4,
107 | threshold = 0,
108 | points = 4,
109 | },
110 | [5] = {
111 | name = "gatecrack",
112 | amount = 50,
113 | info = {},
114 | costs = {
115 | ["metalscrap"] = 10,
116 | ["plastic"] = 50,
117 | ["aluminum"] = 30,
118 | ["iron"] = 17,
119 | ["electronickit"] = 1,
120 | },
121 | type = "item",
122 | slot = 5,
123 | threshold = 120,
124 | points = 5,
125 | },
126 | [6] = {
127 | name = "handcuffs",
128 | amount = 50,
129 | info = {},
130 | costs = {
131 | ["metalscrap"] = 36,
132 | ["steel"] = 24,
133 | ["aluminum"] = 28,
134 | },
135 | type = "item",
136 | slot = 6,
137 | threshold = 160,
138 | points = 6,
139 | },
140 | [7] = {
141 | name = "repairkit",
142 | amount = 50,
143 | info = {},
144 | costs = {
145 | ["metalscrap"] = 32,
146 | ["steel"] = 43,
147 | ["plastic"] = 61,
148 | },
149 | type = "item",
150 | slot = 7,
151 | threshold = 200,
152 | points = 7,
153 | },
154 | [8] = {
155 | name = "pistol_ammo",
156 | amount = 50,
157 | info = {},
158 | costs = {
159 | ["metalscrap"] = 50,
160 | ["steel"] = 37,
161 | ["copper"] = 26,
162 | },
163 | type = "item",
164 | slot = 8,
165 | threshold = 250,
166 | points = 8,
167 | },
168 | [9] = {
169 | name = "ironoxide",
170 | amount = 50,
171 | info = {},
172 | costs = {
173 | ["iron"] = 60,
174 | ["glass"] = 30,
175 | },
176 | type = "item",
177 | slot = 9,
178 | threshold = 300,
179 | points = 9,
180 | },
181 | [10] = {
182 | name = "aluminumoxide",
183 | amount = 50,
184 | info = {},
185 | costs = {
186 | ["aluminum"] = 60,
187 | ["glass"] = 30,
188 | },
189 | type = "item",
190 | slot = 10,
191 | threshold = 300,
192 | points = 10,
193 | },
194 | [11] = {
195 | name = "armor",
196 | amount = 50,
197 | info = {},
198 | costs = {
199 | ["iron"] = 33,
200 | ["steel"] = 44,
201 | ["plastic"] = 55,
202 | ["aluminum"] = 22,
203 | },
204 | type = "item",
205 | slot = 11,
206 | threshold = 350,
207 | points = 11,
208 | },
209 | [12] = {
210 | name = "drill",
211 | amount = 50,
212 | info = {},
213 | costs = {
214 | ["iron"] = 50,
215 | ["steel"] = 50,
216 | ["screwdriverset"] = 3,
217 | ["advancedlockpick"] = 2,
218 | },
219 | type = "item",
220 | slot = 12,
221 | threshold = 1750,
222 | points = 12,
223 | },
224 | }
225 |
226 | Config.AttachmentCrafting = {
227 | ["location"] = {x = 88.91, y = 3743.88, z = 40.77, h = 66.5, r = 1.0},
228 | ["items"] = {
229 | [1] = {
230 | name = "pistol_extendedclip",
231 | amount = 50,
232 | info = {},
233 | costs = {
234 | ["metalscrap"] = 140,
235 | ["steel"] = 250,
236 | ["rubber"] = 60,
237 | },
238 | type = "item",
239 | slot = 1,
240 | threshold = 0,
241 | points = 1,
242 | },
243 | [2] = {
244 | name = "pistol_suppressor",
245 | amount = 50,
246 | info = {},
247 | costs = {
248 | ["metalscrap"] = 165,
249 | ["steel"] = 285,
250 | ["rubber"] = 75,
251 | },
252 | type = "item",
253 | slot = 2,
254 | threshold = 10,
255 | points = 2,
256 | },
257 | [3] = {
258 | name = "rifle_extendedclip",
259 | amount = 50,
260 | info = {},
261 | costs = {
262 | ["metalscrap"] = 190,
263 | ["steel"] = 305,
264 | ["rubber"] = 85,
265 | ["smg_extendedclip"] = 1,
266 | },
267 | type = "item",
268 | slot = 7,
269 | threshold = 25,
270 | points = 8,
271 | },
272 | [4] = {
273 | name = "rifle_drummag",
274 | amount = 50,
275 | info = {},
276 | costs = {
277 | ["metalscrap"] = 205,
278 | ["steel"] = 340,
279 | ["rubber"] = 110,
280 | ["smg_extendedclip"] = 2,
281 | },
282 | type = "item",
283 | slot = 8,
284 | threshold = 50,
285 | points = 8,
286 | },
287 | [5] = {
288 | name = "smg_flashlight",
289 | amount = 50,
290 | info = {},
291 | costs = {
292 | ["metalscrap"] = 230,
293 | ["steel"] = 365,
294 | ["rubber"] = 130,
295 | },
296 | type = "item",
297 | slot = 3,
298 | threshold = 75,
299 | points = 3,
300 | },
301 | [6] = {
302 | name = "smg_extendedclip",
303 | amount = 50,
304 | info = {},
305 | costs = {
306 | ["metalscrap"] = 255,
307 | ["steel"] = 390,
308 | ["rubber"] = 145,
309 | },
310 | type = "item",
311 | slot = 4,
312 | threshold = 100,
313 | points = 4,
314 | },
315 | [7] = {
316 | name = "smg_suppressor",
317 | amount = 50,
318 | info = {},
319 | costs = {
320 | ["metalscrap"] = 270,
321 | ["steel"] = 435,
322 | ["rubber"] = 155,
323 | },
324 | type = "item",
325 | slot = 5,
326 | threshold = 150,
327 | points = 5,
328 | },
329 | [8] = {
330 | name = "smg_scope",
331 | amount = 50,
332 | info = {},
333 | costs = {
334 | ["metalscrap"] = 300,
335 | ["steel"] = 469,
336 | ["rubber"] = 170,
337 | },
338 | type = "item",
339 | slot = 6,
340 | threshold = 200,
341 | points = 6,
342 | },
343 | }
344 | }
345 |
346 | Keys = {
347 | ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
348 | ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
349 | ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
350 | ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
351 | ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
352 | ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
353 | ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
354 | ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
355 | }
356 |
357 | MaxInventorySlots = 40
358 |
359 | BackEngineVehicles = {
360 | 'ninef',
361 | 'adder',
362 | 'vagner',
363 | 't20',
364 | 'infernus',
365 | 'zentorno',
366 | 'reaper',
367 | 'comet2',
368 | 'comet3',
369 | 'jester',
370 | 'jester2',
371 | 'cheetah',
372 | 'cheetah2',
373 | 'prototipo',
374 | 'turismor',
375 | 'pfister811',
376 | 'ardent',
377 | 'nero',
378 | 'nero2',
379 | 'tempesta',
380 | 'vacca',
381 | 'bullet',
382 | 'osiris',
383 | 'entityxf',
384 | 'turismo2',
385 | 'fmj',
386 | 're7b',
387 | 'tyrus',
388 | 'italigtb',
389 | 'penetrator',
390 | 'monroe',
391 | 'ninef2',
392 | 'stingergt',
393 | 'surfer',
394 | 'surfer2',
395 | 'comet3',
396 | }
397 |
398 | Config.MaximumAmmoValues = {
399 | ["pistol"] = 250,
400 | ["smg"] = 250,
401 | ["shotgun"] = 200,
402 | ["rifle"] = 250,
403 | }
--------------------------------------------------------------------------------
/html/css/main.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap);
2 | @import url(https://fonts.googleapis.com/css?family=Open+Sans:600&display=swap);
3 | @import url(https://fonts.googleapis.com/css?family=Lato&display=swap);
4 | @import url(https://fonts.googleapis.com/css?family=Balthazar&display=swap);
5 | @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap);
6 | @import url(https://fonts.googleapis.com/css?family=Roboto+Slab&display=swap);
7 | @font-face {
8 | font-family: Verdana;
9 | src: url(../verdana.ttf)
10 | }
11 |
12 | @font-face {
13 | font-family: 'Verdana Bold';
14 | src: url(../VerdanaBold.ttf)
15 | }
16 |
17 | body {
18 | user-select: none;
19 | overflow-y: hidden;
20 | overflow-x: hidden
21 | }
22 |
23 | p {
24 | margin: 0!important
25 | }
26 |
27 | :root {
28 | --main-label-color: 20, 10, 20
29 | }
30 |
31 | input[type=number]::-webkit-inner-spin-button,
32 | input[type=number]::-webkit-outer-spin-button {
33 | -webkit-appearance: none;
34 | margin: 0
35 | }
36 |
37 | ::-webkit-scrollbar {
38 | width: 7.5px
39 | }
40 |
41 | ::-webkit-scrollbar-thumb {
42 | background-color: #30465d
43 | }
44 |
45 | body {
46 | overflow-x: hidden
47 | }
48 |
49 | .inventorybg {
50 | width: 100%;
51 | height: 100%;
52 | align-items: center;
53 | overflow: hidden;
54 | display: block;
55 | background-repeat: no-repeat;
56 | background-size: 100% 100%;
57 | filter: blur(100px);
58 | opacity: .44;
59 | border: 1px solid rgba(200, 200, 200, .9);
60 | position: absolute;
61 | z-index: -1;
62 | background: #222831
63 | }
64 |
65 | #qbus-inventory {
66 | position: absolute;
67 | width: 100%;
68 | height: 100%;
69 | left: 0;
70 | display: none
71 | }
72 |
73 | .inv-background {
74 | background-color: transparent;
75 | width: 100%;
76 | height: 100%;
77 | position: absolute;
78 | top: 0;
79 | left: 0;
80 | z-index: -1
81 | }
82 |
83 | @keyframes axis {
84 | from {
85 | margin-top: 100%
86 | }
87 | to {
88 | margin-top: 0
89 | }
90 | }
91 |
92 | .inv-container {
93 | position: absolute;
94 | width: 100%;
95 | height: 100%;
96 | animation: axis .3s
97 | }
98 |
99 | .player-inventory {
100 | position: absolute;
101 | top: 30%;
102 | left: 10.2%;
103 | width: 31.5%;
104 | max-width: 31.5%;
105 | height: 53.16%;
106 | max-height: 54.16%;
107 | float: left;
108 | overflow-x: hidden;
109 | overflow-y: scroll;
110 | z-index: 100
111 | }
112 |
113 | .other-inventory {
114 | position: absolute;
115 | top: 30%;
116 | right: 10.2%;
117 | width: 31.5%;
118 | max-width: 31.5%;
119 | height: 53.16%;
120 | max-height: 54.16%;
121 | float: left;
122 | overflow-x: hidden;
123 | overflow-y: scroll;
124 | z-index: 100
125 | }
126 |
127 | .ply-hotbar-inventory {
128 | position: absolute;
129 | bottom: 10%;
130 | left: 35.5%;
131 | z-index: 105
132 | }
133 |
134 | .player-inventory>.item-slot>.item-slot-key p {
135 | position: absolute;
136 | background: #fff;
137 | color: #000;
138 | padding: .3vh;
139 | padding-left: .5vh;
140 | padding-right: .5vh;
141 | text-align: left;
142 | font-size: 1.1vh;
143 | line-height: 1.8vh;
144 | font-family: 'Verdana Bold'
145 | }
146 |
147 | .inv-options {
148 | margin: 18% auto;
149 | background-color: transparent;
150 | right: 0;
151 | width: 9%;
152 | left: 3vh;
153 | border-radius: 8px;
154 | padding-bottom: 30px
155 | }
156 |
157 | .combine-option-container {
158 | display: none;
159 | position: absolute;
160 | margin: 0 auto;
161 | left: 0;
162 | right: 0;
163 | width: 9%;
164 | top: 60%;
165 | left: 3vh
166 | }
167 |
168 | .item-slot {
169 | position: relative;
170 | width: 10.5vh;
171 | height: 13.5vh;
172 | float: left;
173 | margin-left: 2px;
174 | margin-bottom: 2px;
175 | background-color: rgba(0, 0, 0, .15);
176 | border: 1px solid rgba(255, 255, 255, .1);
177 | transition: opacity .2s;
178 | opacity: 1
179 | }
180 |
181 | .item-slot-hoverClass {
182 | opacity: .6
183 | }
184 |
185 | .inv-option-item {
186 | margin-top: 20%
187 | }
188 |
189 | .btn-inv {
190 | width: 100%!important;
191 | max-width: 100%!important;
192 | padding: 10%!important;
193 | background-color: rgba(235, 235, 235, 0)
194 | }
195 |
196 | #item-amount {
197 | color: #fff;
198 | text-align: center;
199 | font-size: 1.25vh;
200 | font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
201 | outline: 0
202 | }
203 |
204 | .ammo-info-block {
205 | position: absolute;
206 | margin: 0 auto;
207 | left: 0;
208 | right: 0;
209 | width: 22vh;
210 | height: 11vh;
211 | background-color: rgba(235, 235, 235, .08);
212 | border: 1px solid rgba(255, 255, 255, .01);
213 | top: 2vh
214 | }
215 |
216 | .ammo-info-header {
217 | width: 100%;
218 | color: #fff;
219 | font-family: 'Open Sans', sans-serif;
220 | background-color: rgba(0, 0, 0, .192);
221 | font-size: 1.2vh;
222 | padding: .4vh;
223 | text-align: center
224 | }
225 |
226 | .ammo-info {
227 | position: relative;
228 | color: #fff;
229 | font-family: 'Open Sans', sans-serif;
230 | font-weight: 200;
231 | font-size: 1.3vh;
232 | margin-left: .8vh;
233 | margin-top: .4vh;
234 | margin-bottom: .25vh;
235 | top: .6vh
236 | }
237 |
238 | .ammo-info span {
239 | margin-right: 1vh;
240 | float: right
241 | }
242 |
243 | .inv-option-item>p {
244 | color: #fff;
245 | text-align: center;
246 | line-height: 4.5vh;
247 | text-transform: uppercase;
248 | font-size: 1.1vh;
249 | font-family: Verdana
250 | }
251 |
252 | .inv-option-item {
253 | width: 80%;
254 | height: 4.5%;
255 | border: 1px solid rgba(255, 255, 255, .01);
256 | border-radius: 7px;
257 | color: #fff;
258 | transition: background-color .1s linear
259 | }
260 |
261 | .inv-option-item:hover {
262 | background-color: transparent
263 | }
264 |
265 | .btn-combine {
266 | position: relative;
267 | margin-top: 20%;
268 | width: 80%;
269 | height: 50px;
270 | background-color: #466887;
271 | border: 1px solid rgba(255, 255, 255, .01);
272 | color: #fff;
273 | transition: background-color .1s linear;
274 | border-radius: 7px
275 | }
276 |
277 | .btn-combine>p {
278 | color: #fff;
279 | text-align: center;
280 | line-height: 48px;
281 | text-transform: uppercase;
282 | font-size: 1.1vh;
283 | font-family: Verdana
284 | }
285 |
286 | .btn-combine:hover {
287 | background-color: transparent
288 | }
289 |
290 | .item-slot-amount {
291 | position: absolute;
292 | top: .3vh;
293 | right: .3vw
294 | }
295 |
296 | .item-slot-amount p {
297 | color: #fff;
298 | text-align: right;
299 | font-size: 11px
300 | }
301 |
302 | .item-slot-label {
303 | position: absolute;
304 | bottom: 0;
305 | width: 100%;
306 | background-color: rgba(0, 0, 0, .35);
307 | min-height: 3.2vh;
308 | height: auto
309 | }
310 |
311 | .item-slot-label p {
312 | color: #f7f7f7;
313 | font-size: .95vh;
314 | line-height: 2.2vh;
315 | text-align: center;
316 | text-transform: uppercase;
317 | font-family: Verdana;
318 | font-variant: small-caps
319 | }
320 |
321 | .item-slot-quality {
322 | position: absolute;
323 | bottom: 0;
324 | width: 100%;
325 | height: .8vh;
326 | background-color: rgba(32, 6, 6, .15);
327 | border-radius: 0 0 8px 8px
328 | }
329 |
330 | .item-slot-quality-bar {
331 | z-index: 1;
332 | position: absolute;
333 | bottom: 0;
334 | width: 0%;
335 | color: transparent;
336 | height: 100%;
337 | background-color: rgba(111, 195, 111, .8);
338 | box-shadow: inset 0 0 .25vh 0 rgba(0, 0, 0, .2)
339 | }
340 |
341 | .item-slot-quality p {
342 | color: transparent;
343 | font-size: .8vh;
344 | text-align: center;
345 | text-transform: uppercase;
346 | line-height: 1.3vh;
347 | font-family: 'Verdana Bold'
348 | }
349 |
350 | .item-slot-img {
351 | max-width: 100%;
352 | max-height: 100%;
353 | padding: .5vw
354 | }
355 |
356 | .item-slot-img img {
357 | display: block;
358 | position: relative;
359 | margin: 0 auto;
360 | margin-top: 21%;
361 | width: auto;
362 | height: auto;
363 | max-width: 100%;
364 | max-height: 100%
365 | }
366 |
367 | .ui-draggable-dragging {
368 | background: rgba(20, 20, 20, .7)
369 | }
370 |
371 | .player-inv-info {
372 | position: absolute;
373 | left: 10.3%;
374 | top: 22.5%;
375 | width: 28.8%
376 | }
377 |
378 | #player-inv-label {
379 | position: relative;
380 | color: #fff;
381 | font-size: 18px;
382 | font-family: Lato, monospace;
383 | font-weight: 700;
384 | letter-spacing: .1vh;
385 | bottom: 15px;
386 | float: left
387 | }
388 |
389 | #player-inv-weight {
390 | top: 60%;
391 | left: 5%;
392 | position: absolute;
393 | color: #fff;
394 | font-size: 11px;
395 | letter-spacing: .1vh;
396 | float: left
397 | }
398 |
399 | #other-inv-label {
400 | position: relative;
401 | color: #fff;
402 | font-size: 18px;
403 | font-family: Lato, monospace;
404 | font-weight: 700;
405 | letter-spacing: .1vh;
406 | bottom: 15px;
407 | float: left
408 | }
409 |
410 | #other-inv-weight {
411 | top: 60%;
412 | left: 5%;
413 | position: absolute;
414 | color: #fff;
415 | font-size: 11px;
416 | letter-spacing: .1vh;
417 | float: left
418 | }
419 |
420 | .player-inv-weight {
421 | position: absolute;
422 | left: 38%;
423 | top: 12%
424 | }
425 |
426 | .player-inv-weight p {
427 | color: #fff;
428 | font-size: 12px;
429 | font-family: 'Roboto Mono', monospace
430 | }
431 |
432 | .other-inv-info {
433 | position: absolute;
434 | left: 58.3%;
435 | top: 22.5%;
436 | width: 28.8%
437 | }
438 |
439 | .ply-iteminfo-container {
440 | visibility: hidden;
441 | font-family: 'Open Sans';
442 | display: none;
443 | position: absolute;
444 | bottom: 3%;
445 | margin: 0 auto;
446 | left: 0;
447 | right: 0;
448 | width: 35vh;
449 | height: 23vh
450 | }
451 |
452 | .item-info-title {
453 | font-family: sans-serif;
454 | font-size: 1.8vh;
455 | color: #fff;
456 | font-family: 'Open Sans';
457 | padding-top: 5px;
458 | padding-left: 5px
459 | }
460 |
461 | .item-info-line {
462 | position: absolute;
463 | font-family: 'Open Sans';
464 | width: 100%;
465 | background-color: #fff;
466 | height: .1vh;
467 | top: 4.5vh
468 | }
469 |
470 | .item-info-description {
471 | font-size: 1.1vh;
472 | font-family: 'Open Sans';
473 | color: #fff;
474 | padding-top: 3vh;
475 | padding-left: .5vh
476 | }
477 |
478 | .itemboxes-container {
479 | height: 130px;
480 | min-width: 110px;
481 | max-width: 550px;
482 | width: fit-content;
483 | position: absolute;
484 | left: 47%;
485 | bottom: 20%;
486 | overflow: hidden
487 | }
488 |
489 | .template {
490 | display: none
491 | }
492 |
493 | .itembox-container {
494 | display: none;
495 | position: relative;
496 | float: left;
497 | margin: 0 auto;
498 | margin-right: 1vh;
499 | width: 110px;
500 | height: 130px;
501 | background-color: rgba(0, 0, 0, .2);
502 | border: 1px solid rgba(255, 255, 255, .05)
503 | }
504 |
505 | #itembox-action {
506 | position: absolute;
507 | background-color: #fff;
508 | padding: 4px;
509 | top: 0;
510 | left: 0
511 | }
512 |
513 | #itembox-action>p {
514 | font-size: 10px;
515 | font-family: 'Verdana Bold'
516 | }
517 |
518 | #itembox-label {
519 | position: absolute;
520 | bottom: 0;
521 | width: 100%;
522 | background-color: rgba(0, 0, 0, .35);
523 | min-height: 2.2vh;
524 | height: fit-content
525 | }
526 |
527 | #itembox-label>p {
528 | color: #f7f7f7;
529 | font-size: 11.5px;
530 | line-height: 2.1vh;
531 | text-align: center;
532 | text-transform: lowercase;
533 | font-family: Verdana, Geneva, Tahoma, sans-serif;
534 | font-variant: small-caps
535 | }
536 |
537 | .requiredItem-container {
538 | display: none;
539 | position: absolute;
540 | height: 100vh;
541 | width: 100vw
542 | }
543 |
544 | .requiredItem-box {
545 | position: relative;
546 | top: 70%;
547 | left: 42%;
548 | width: 110px;
549 | height: 130px;
550 | background-color: rgba(0, 0, 0, .2);
551 | border: 1px solid rgba(255, 255, 255, .1);
552 | float: left;
553 | margin-left: 20px
554 | }
555 |
556 | #requiredItem-action {
557 | position: absolute;
558 | left: 0;
559 | top: 0;
560 | background-color: #fff;
561 | padding: 3px;
562 | font-size: 10px;
563 | font-family: 'Verdana Bold'
564 | }
565 |
566 | #requiredItem-label {
567 | position: absolute;
568 | bottom: 0;
569 | width: 100%;
570 | background-color: rgba(24, 0, 0, .2);
571 | height: 21px
572 | }
573 |
574 | #requiredItem-label>p {
575 | color: #fff;
576 | font-size: 11px;
577 | text-align: center;
578 | text-transform: uppercase;
579 | line-height: 19px
580 | }
581 |
582 | .z-hotbar-inventory {
583 | display: none;
584 | position: absolute;
585 | bottom: 0;
586 | margin: 0 auto;
587 | left: 0;
588 | right: 0;
589 | width: fit-content;
590 | z-index: 105
591 | }
592 |
593 | .z-hotbar-inventory>.z-hotbar-item-slot>.z-hotbar-item-slot-key p {
594 | position: absolute;
595 | background: #fff;
596 | color: #000;
597 | padding: .3vh;
598 | padding-left: .5vh;
599 | padding-right: .5vh;
600 | text-align: left;
601 | font-size: 1.1vh;
602 | line-height: 1.8vh;
603 | font-family: 'Verdana Bold'
604 | }
605 |
606 | .z-hotbar-item-slot {
607 | position: relative;
608 | width: 10vh;
609 | height: 13.5vh;
610 | float: left;
611 | margin-left: 15px;
612 | margin-bottom: 2px;
613 | background-color: rgba(255, 255, 255, .03);
614 | border: 1px solid rgba(255, 255, 255, .1);
615 | transition: opacity .2s;
616 | opacity: 1
617 | }
618 |
619 | .z-hotbar-item-slot-amount {
620 | position: absolute;
621 | top: .3vh;
622 | right: .3vw
623 | }
624 |
625 | .z-hotbar-item-slot-amount p {
626 | color: #fff;
627 | text-align: right;
628 | font-size: 10px
629 | }
630 |
631 | .z-hotbar-item-slot-label {
632 | position: absolute;
633 | bottom: 0;
634 | width: 100%;
635 | background-color: rgba(0, 0, 0, .35);
636 | min-height: 2.2vh;
637 | height: fit-content
638 | }
639 |
640 | .z-hotbar-item-slot-label p {
641 | color: #f7f7f7;
642 | font-size: 11.5px;
643 | line-height: 2.1vh;
644 | text-align: center;
645 | text-transform: lowercase;
646 | font-family: Verdana, Geneva, Tahoma, sans-serif;
647 | font-variant: small-caps
648 | }
649 |
650 | .z-hotbar-item-slot-img {
651 | max-width: 100%;
652 | max-height: 100%;
653 | padding: .5vw
654 | }
655 |
656 | .z-hotbar-item-slot-img img {
657 | margin-top: 21%;
658 | display: block;
659 | width: auto;
660 | height: auto;
661 | max-width: 100%;
662 | max-height: 100%
663 | }
664 |
665 | .ammo-container {
666 | position: absolute;
667 | background-color: rgba(20, 18, 32, .2);
668 | width: 3.25%;
669 | height: 44.16%;
670 | top: 26%;
671 | left: 6%
672 | }
673 |
674 | .ammo-container-header {
675 | position: absolute;
676 | top: 0;
677 | width: 100%;
678 | height: 5vh;
679 | background-color: rgba(120, 10, 20, .5);
680 | text-align: center;
681 | color: rgba(216, 216, 216, .897)
682 | }
683 |
684 | .ammo-container-header>i {
685 | line-height: 5vh;
686 | font-size: 1.8vh
687 | }
688 |
689 | .ammo-box {
690 | position: relative;
691 | width: 100%;
692 | height: 6vh;
693 | top: 5vh;
694 | background-color: rgba(0, 0, 0, .4);
695 | margin-bottom: .5vh;
696 | margin-top: .5vh
697 | }
698 |
699 | .ammo-box>img {
700 | position: absolute;
701 | top: .15vh;
702 | left: .2vh;
703 | width: 5.25vh;
704 | opacity: .25
705 | }
706 |
707 | .ammo-box>span {
708 | position: absolute;
709 | color: rgba(255, 255, 255, .95);
710 | font-size: .93vh;
711 | bottom: 0;
712 | right: 0;
713 | margin: .3vh;
714 | font-family: 'Source Code Pro', monospace
715 | }
716 |
717 | .ammo-box-amount {
718 | position: absolute;
719 | width: 100%;
720 | background-color: rgba(36, 36, 36, .4);
721 | bottom: 0;
722 | max-height: 100%
723 | }
724 |
725 | #pistol_ammo>.ammo-box-amount {
726 | height: 0%
727 | }
728 |
729 | #smg_ammo>.ammo-box-amount {
730 | height: 0%
731 | }
732 |
733 | #shotgun_ammo>.ammo-box-amount {
734 | height: 0%
735 | }
736 |
737 | #rifle_ammo>.ammo-box-amount {
738 | height: 0%
739 | }
740 |
741 | .weapon-attachments-container {
742 | position: absolute;
743 | left: -100vw;
744 | width: 100%;
745 | height: 100%;
746 | background-color: rgba(0, 0, 0, .5)
747 | }
748 |
749 | .weapon-attachments-container-title {
750 | position: absolute;
751 | margin: 5vh;
752 | font-size: 3vh;
753 | color: #fff;
754 | font-family: 'Source Sans Pro'
755 | }
756 |
757 | .weapon-attachments-container-description {
758 | position: absolute;
759 | margin: 5vh;
760 | top: 5vh;
761 | font-size: 1.7vh;
762 | color: rgba(255, 255, 255, .8);
763 | font-family: 'Source Sans Pro'
764 | }
765 |
766 | .weapon-attachments-container-details {
767 | position: absolute;
768 | margin: 5vh;
769 | top: 9vh;
770 | font-size: 1.4vh;
771 | color: rgba(255, 255, 255, .8);
772 | font-family: 'Source Sans Pro'
773 | }
774 |
775 | .weapon-attachments-container-detail-durability {
776 | height: 1.5vh;
777 | width: 10vh;
778 | background-color: rgba(0, 0, 0, .3);
779 | border-radius: .2vh
780 | }
781 |
782 | .weapon-attachments-container-detail-durability-total {
783 | height: 100%;
784 | width: 50%;
785 | background-color: #27ae60
786 | }
787 |
788 | .weapon-attachments-container-image {
789 | position: absolute;
790 | margin: 0 auto;
791 | left: 0;
792 | right: 0;
793 | top: 32%;
794 | width: 50%
795 | }
796 |
797 | .weapon-attachments {
798 | position: absolute;
799 | bottom: 0;
800 | left: 0;
801 | margin: 5vh;
802 | width: 50vh;
803 | height: 12.5vh
804 | }
805 |
806 | .weapon-attachments-title {
807 | position: absolute;
808 | bottom: 14vh;
809 | left: 0;
810 | margin: 5vh;
811 | color: rgba(255, 255, 255, .8)
812 | }
813 |
814 | .weapon-attachment {
815 | position: relative;
816 | height: 12.5vh;
817 | width: 10.5vh;
818 | background-color: rgba(0, 0, 0, .3);
819 | border: 1px solid #4b4b4b;
820 | margin-right: 1vh;
821 | float: left;
822 | transition: .05s linear
823 | }
824 |
825 | .weapon-attachment:hover {
826 | background-color: rgba(0, 0, 0, .4);
827 | border: 1px solid #1d1d1d;
828 | transition: .05s linear
829 | }
830 |
831 | .weapon-attachment-label {
832 | position: absolute;
833 | bottom: 0;
834 | width: 100%;
835 | background-color: rgba(var(--main-label-color), .3);
836 | padding: 2.1%
837 | }
838 |
839 | .weapon-attachment-label>p {
840 | color: #fff;
841 | font-size: 1.1vh;
842 | text-align: center;
843 | text-transform: uppercase;
844 | line-height: 1.9vh;
845 | font-family: 'Source Code Pro', monospace;
846 | font-weight: 100
847 | }
848 |
849 | .weapon-attachment-img {
850 | max-width: 100%;
851 | max-height: 100%;
852 | padding: .5vw
853 | }
854 |
855 | .weapon-attachment-img>img {
856 | display: block;
857 | position: relative;
858 | margin: 0 auto;
859 | margin-top: 10%;
860 | width: auto;
861 | height: auto;
862 | max-width: 100%;
863 | max-height: 100%
864 | }
865 |
866 | .weapon-attachments-remove {
867 | position: absolute;
868 | width: 6.5vh;
869 | height: 6.5vh;
870 | background-color: #0f0f0f;
871 | border-radius: 1vh;
872 | margin: 0 auto;
873 | left: 0;
874 | right: 0;
875 | bottom: 20vh;
876 | text-align: center;
877 | color: #fff;
878 | font-size: 2vh;
879 | transition: background-color .05s linear
880 | }
881 |
882 | .weapon-attachments-remove:hover {
883 | background-color: #121212
884 | }
885 |
886 | .weapon-attachments-remove>i {
887 | line-height: 6.5vh
888 | }
889 |
890 | .weapon-attachments-remove-hover {
891 | background-color: #27ae60
892 | }
893 |
894 | .weapon-dragging-class {
895 | animation: ShakeEffect .75s;
896 | animation-iteration-count: infinite
897 | }
898 |
899 | @keyframes ShakeEffect {
900 | 0% {
901 | transform: translate(1px, 1px) rotate(0)
902 | }
903 | 10% {
904 | transform: translate(-1px, -2px) rotate(-1deg)
905 | }
906 | 20% {
907 | transform: translate(-3px, 0) rotate(1deg)
908 | }
909 | 30% {
910 | transform: translate(3px, 2px) rotate(0)
911 | }
912 | 40% {
913 | transform: translate(1px, -1px) rotate(1deg)
914 | }
915 | 50% {
916 | transform: translate(-1px, 2px) rotate(-1deg)
917 | }
918 | 60% {
919 | transform: translate(-3px, 1px) rotate(0)
920 | }
921 | 70% {
922 | transform: translate(3px, 1px) rotate(-1deg)
923 | }
924 | 80% {
925 | transform: translate(-1px, -1px) rotate(1deg)
926 | }
927 | 90% {
928 | transform: translate(1px, 2px) rotate(0)
929 | }
930 | 100% {
931 | transform: translate(1px, -2px) rotate(-1deg)
932 | }
933 | }
934 |
935 | .weapon-attachments-back {
936 | position: absolute;
937 | bottom: 0;
938 | right: 0;
939 | width: 10vh;
940 | height: 6vh;
941 | margin: 5vh;
942 | background-color: #0f0f0f;
943 | border-radius: .2vh;
944 | text-align: center;
945 | line-height: 6vh;
946 | color: #fff;
947 | font-family: 'Source Code Pro', monospace;
948 | transition: .05s linear
949 | }
950 |
951 | .weapon-attachments-back:hover {
952 | background-color: #121212
953 | }
954 |
955 | .tooltip {
956 | position: absolute;
957 | z-index: 1070;
958 | display: block;
959 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
960 | font-style: normal;
961 | font-weight: 400;
962 | line-height: 1.42857143;
963 | line-break: auto;
964 | text-align: left;
965 | text-align: start;
966 | text-decoration: none;
967 | text-shadow: none;
968 | text-transform: none;
969 | letter-spacing: normal;
970 | word-break: normal;
971 | word-spacing: normal;
972 | word-wrap: normal;
973 | white-space: normal;
974 | font-size: 12px;
975 | opacity: 0;
976 | animation: fadeIn 1s
977 | }
978 |
979 | .tooltip-inner {
980 | background-color: #2e465c!important;
981 | color: #fff!important;
982 | max-width: 300px!important;
983 | padding: .25rem .5rem!important;
984 | color: #fff!important;
985 | text-align: center!important;
986 | border-radius: .25rem!important
987 | }
988 |
989 | .tooltip.top .tooltip-arrow {
990 | border-top-color: #2e465c
991 | }
992 |
993 | .tooltip.right .tooltip-arrow {
994 | border-right-color: #2e465c
995 | }
996 |
997 | .tooltip.left .tooltip-arrow {
998 | border-bottom-color: #2e465c
999 | }
1000 |
1001 | .tooltip.bottom .tooltip-arrow {
1002 | border-bottom-color: #2e465c
1003 | }
1004 |
1005 | .item-slot:after {
1006 | content: "";
1007 | position: absolute;
1008 | top: 0;
1009 | left: 0;
1010 | width: 100%;
1011 | height: 0%;
1012 | background-color: rgba(255, 255, 255, .4);
1013 | transition: none;
1014 | transition: all .2s ease-in
1015 | }
1016 |
1017 | .item-slot:hover:after {
1018 | height: 100%;
1019 | background-color: transparent;
1020 | transition: all .5s ease-out
1021 | }
1022 |
1023 | .healthbar {
1024 | position: absolute;
1025 | top: 30%;
1026 | left: 7.5%;
1027 | width: 2.2%;
1028 | height: 4%;
1029 | background-color: rgba(0, 0, 0, .3);
1030 | border-radius: .3vw
1031 | }
1032 |
1033 | .shieldbar {
1034 | position: absolute;
1035 | top: 35%;
1036 | left: 7.5%;
1037 | width: 2.2%;
1038 | height: 4%;
1039 | background-color: rgba(0, 0, 0, .3);
1040 | border-radius: .3vw
1041 | }
1042 |
1043 | .health,
1044 | .shield {
1045 | position: absolute;
1046 | bottom: 0;
1047 | background-color: #2e465c;
1048 | width: 100%;
1049 | height: 100%;
1050 | border-radius: .3vw
1051 | }
1052 |
1053 | #barIcon {
1054 | position: absolute;
1055 | top: 0;
1056 | left: .2vh;
1057 | padding: 1vh;
1058 | z-index: 102
1059 | }
1060 |
1061 | #clothswitch {
1062 | position: absolute;
1063 | left: 49.05vw;
1064 | top: 75%;
1065 | z-index: 10
1066 | }
1067 |
1068 | #glasses,
1069 | #hat,
1070 | #mask,
1071 | #pants,
1072 | #shirt,
1073 | #shoes,
1074 | #top,
1075 | #vest,
1076 | #watch {
1077 | width: 3vw;
1078 | border: .4vh solid rgba(180, 180, 180, .651);
1079 | border-radius: 50%;
1080 | padding: 1vh
1081 | }
1082 |
1083 | #glasses:hover,
1084 | #hat:hover,
1085 | #mask:hover,
1086 | #pants:hover,
1087 | #shirt:hover,
1088 | #shoes:hover,
1089 | #top:hover,
1090 | #vest:hover,
1091 | #watch:hover {
1092 | opacity: .5
1093 | }
1094 |
--------------------------------------------------------------------------------
/client/main.lua:
--------------------------------------------------------------------------------
1 | QBCore = nil
2 |
3 | inInventory = false
4 | hotbarOpen = false
5 |
6 | local inventoryTest = {}
7 | local currentWeapon = nil
8 | local CurrentWeaponData = {}
9 | local currentOtherInventory = nil
10 |
11 | local Drops = {}
12 | local CurrentDrop = 0
13 | local DropsNear = {}
14 |
15 | local CurrentVehicle = nil
16 | local CurrentGlovebox = nil
17 | local CurrentStash = nil
18 | local isCrafting = false
19 |
20 | local showTrunkPos = false
21 | Citizen.CreateThread(function ()
22 | Citizen.Wait(2000)
23 | while true do
24 | Citizen.Wait(0)
25 | HideHudComponentThisFrame(19)
26 | HideHudComponentThisFrame(20)
27 | BlockWeaponWheelThisFrame()
28 | DisableControlAction(0, 37,true)
29 | end
30 | end)
31 | Citizen.CreateThread(function()
32 | while true do
33 |
34 | Citizen.Wait(10)
35 | if QBCore == nil then
36 | TriggerEvent("QBCore:GetObject", function(obj) QBCore = obj end)
37 | Citizen.Wait(200)
38 | end
39 | end
40 | end)
41 |
42 | RegisterNetEvent('inventory:client:CheckOpenState')
43 | AddEventHandler('inventory:client:CheckOpenState', function(type, id, label)
44 | local name = QBCore.Shared.SplitStr(label, "-")[2]
45 | if type == "stash" then
46 | if name ~= CurrentStash or CurrentStash == nil then
47 | TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id)
48 | end
49 | elseif type == "trunk" then
50 | if name ~= CurrentVehicle or CurrentVehicle == nil then
51 | TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id)
52 | end
53 | elseif type == "glovebox" then
54 | if name ~= CurrentGlovebox or CurrentGlovebox == nil then
55 | TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id)
56 | end
57 | end
58 | end)
59 |
60 | RegisterNetEvent('weapons:client:SetCurrentWeapon')
61 | AddEventHandler('weapons:client:SetCurrentWeapon', function(data, bool)
62 | if data ~= false then
63 | CurrentWeaponData = data
64 | else
65 | CurrentWeaponData = {}
66 | end
67 | end)
68 |
69 | function GetClosestVending()
70 | local ped = GetPlayerPed(-1)
71 | local pos = GetEntityCoords(ped)
72 | local object = nil
73 | for _, machine in pairs(Config.VendingObjects) do
74 | local ClosestObject = GetClosestObjectOfType(pos.x, pos.y, pos.z, 50.0, GetHashKey(machine), 0, 0, 0)
75 | if ClosestObject ~= 0 and ClosestObject ~= nil then
76 | if object == nil then
77 | object = ClosestObject
78 | end
79 | end
80 | end
81 | return object
82 | end
83 | RegisterNetEvent('randPickupAnim')
84 | AddEventHandler('randPickupAnim', function()
85 | while not HasAnimDictLoaded("pickup_object") do RequestAnimDict("pickup_object") Wait(100) end
86 | TaskPlayAnim(PlayerPedId(),'pickup_object', 'putdown_low',5.0, 1.5, 1.0, 48, 0.0, 0, 0, 0)
87 | Wait(1000)
88 | ClearPedSecondaryTask(PlayerPedId())
89 | end)
90 |
91 | function PlayToggleEmote()
92 | ExecuteCommand('e backpack')
93 | Dict = "anim@heists@ornate_bank@grab_cash" Anim = "intro" Move = 51 Dur = 1600
94 | local Ped = PlayerPedId()
95 | while not HasAnimDictLoaded(Dict) do RequestAnimDict(Dict) Wait(100) end
96 | if IsPedInAnyVehicle(Ped) then Move = 51 end
97 | TaskPlayAnim(Ped, Dict, Anim, 3.0, 3.0, Dur, Move, 0, false, false, false)
98 | local Pause = Dur-500 if Pause < 500 then Pause = 500 end
99 | Wait(Pause) -- Lets wait for the emote to play for a bit then do the callback.
100 | ExecuteCommand('e c')
101 | end
102 |
103 |
104 | function DrawText3Ds(x, y, z, text)
105 | SetTextScale(0.35, 0.35)
106 | SetTextFont(4)
107 | SetTextProportional(1)
108 | SetTextColour(255, 255, 255, 215)
109 | SetTextEntry("STRING")
110 | SetTextCentre(true)
111 | AddTextComponentString(text)
112 | SetDrawOrigin(x,y,z, 0)
113 | DrawText(0.0, 0.0)
114 | local factor = (string.len(text)) / 370
115 | DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
116 | ClearDrawOrigin()
117 | end
118 |
119 | --[[Citizen.CreateThread(function()
120 | while true do
121 | local ped = GetPlayerPed(-1)
122 | local pos = GetEntityCoords(ped)
123 | local inRange = false
124 | local VendingMachine = GetClosestVending()
125 |
126 | if VendingMachine ~= nil then
127 | local VendingPos = GetEntityCoords(VendingMachine)
128 | local Distance = GetDistanceBetweenCoords(pos, VendingPos.x, VendingPos.y, VendingPos.z, true)
129 | if Distance < 20 then
130 | inRange = true
131 | if Distance < 1.5 then
132 | DrawText3Ds(VendingPos.x, VendingPos.y, VendingPos.z, '~g~E~w~ - Buy drinks')
133 | if IsControlJustPressed(0, Keys["E"]) then
134 | local ShopItems = {}
135 | ShopItems.label = "Drankautomaat"
136 | ShopItems.items = Config.VendingItem
137 | ShopItems.slots = #Config.VendingItem
138 | TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems)
139 | end
140 | end
141 | end
142 | end
143 |
144 | if not inRange then
145 | Citizen.Wait(1000)
146 | end
147 |
148 | Citizen.Wait(1)
149 | end
150 | end)]]
151 |
152 | Citizen.CreateThread(function()
153 | while true do
154 |
155 | Citizen.Wait(7)
156 | if showTrunkPos and not inInventory then
157 | local vehicle = QBCore.Functions.GetClosestVehicle()
158 | if vehicle ~= 0 and vehicle ~= nil then
159 | local pos = GetEntityCoords(GetPlayerPed(-1))
160 | local vehpos = GetEntityCoords(vehicle)
161 | if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, vehpos.x, vehpos.y, vehpos.z, true) < 5.0) and not IsPedInAnyVehicle(GetPlayerPed(-1)) then
162 | local drawpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, -2.5, 0)
163 | if (IsBackEngine(GetEntityModel(vehicle))) then
164 | drawpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, 2.5, 0)
165 | end
166 | QBCore.Functions.DrawText3D(drawpos.x, drawpos.y, drawpos.z, "Trunk")
167 | if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, drawpos) < 2.0) and not IsPedInAnyVehicle(GetPlayerPed(-1)) then
168 | CurrentVehicle = GetVehicleNumberPlateText(vehicle)
169 | showTrunkPos = false
170 | end
171 | else
172 | showTrunkPos = false
173 | end
174 | end
175 | end
176 | end
177 | end)
178 | RegisterNetEvent('khol:hotbar')
179 | AddEventHandler('khol:hotbar', function(itemData, type)
180 | ToggleHotbar(true)
181 | Wait(1500)
182 | ToggleHotbar(false)
183 | end)
184 | Citizen.CreateThread(function()
185 | while true do
186 | Citizen.Wait(0)
187 |
188 | DisableControlAction(0, Keys["K"], true)
189 | DisableControlAction(0, Keys["1"], true)
190 | DisableControlAction(0, Keys["2"], true)
191 | DisableControlAction(0, Keys["3"], true)
192 | DisableControlAction(0, Keys["4"], true)
193 | DisableControlAction(0, Keys["5"], true)
194 | if IsDisabledControlJustPressed(0, Keys["K"]) and not isCrafting then
195 | PlayToggleEmote()
196 | QBCore.Functions.GetPlayerData(function(PlayerData)
197 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
198 | local curVeh = nil
199 | if IsPedInAnyVehicle(GetPlayerPed(-1)) then
200 | local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
201 | CurrentGlovebox = GetVehicleNumberPlateText(vehicle)
202 | curVeh = vehicle
203 | CurrentVehicle = nil
204 | else
205 | local vehicle = QBCore.Functions.GetClosestVehicle()
206 | if vehicle ~= 0 and vehicle ~= nil then
207 | local pos = GetEntityCoords(GetPlayerPed(-1))
208 | local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, -2.5, 0)
209 | if (IsBackEngine(GetEntityModel(vehicle))) then
210 | trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, 2.5, 0)
211 | end
212 | if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, trunkpos) < 2.0) and not IsPedInAnyVehicle(GetPlayerPed(-1)) then
213 | if GetVehicleDoorLockStatus(vehicle) < 2 then
214 | CurrentVehicle = GetVehicleNumberPlateText(vehicle)
215 | curVeh = vehicle
216 | CurrentGlovebox = nil
217 | else
218 | QBCore.Functions.Notify("Vehicle is locked..", "error")
219 | return
220 | end
221 | else
222 | CurrentVehicle = nil
223 | end
224 | else
225 | CurrentVehicle = nil
226 | end
227 | end
228 |
229 | if CurrentVehicle ~= nil then
230 | local maxweight = 0
231 | local slots = 0
232 | if GetVehicleClass(curVeh) == 0 then
233 | maxweight = 38000
234 | slots = 30
235 | elseif GetVehicleClass(curVeh) == 1 then
236 | maxweight = 50000
237 | slots = 40
238 | elseif GetVehicleClass(curVeh) == 2 then
239 | maxweight = 75000
240 | slots = 50
241 | elseif GetVehicleClass(curVeh) == 3 then
242 | maxweight = 42000
243 | slots = 35
244 | elseif GetVehicleClass(curVeh) == 4 then
245 | maxweight = 38000
246 | slots = 30
247 | elseif GetVehicleClass(curVeh) == 5 then
248 | maxweight = 30000
249 | slots = 25
250 | elseif GetVehicleClass(curVeh) == 6 then
251 | maxweight = 30000
252 | slots = 25
253 | elseif GetVehicleClass(curVeh) == 7 then
254 | maxweight = 30000
255 | slots = 25
256 | elseif GetVehicleClass(curVeh) == 8 then
257 | maxweight = 15000
258 | slots = 15
259 | elseif GetVehicleClass(curVeh) == 9 then
260 | maxweight = 60000
261 | slots = 35
262 | elseif GetVehicleClass(curVeh) == 12 then
263 | maxweight = 120000
264 | slots = 35
265 | else
266 | maxweight = 60000
267 | slots = 35
268 | end
269 | local other = {
270 | maxweight = maxweight,
271 | slots = slots,
272 | }
273 | TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other)
274 | OpenTrunk()
275 | elseif CurrentGlovebox ~= nil then
276 | TriggerServerEvent("inventory:server:OpenInventory", "glovebox", CurrentGlovebox)
277 | elseif CurrentDrop ~= 0 then
278 | TriggerServerEvent("inventory:server:OpenInventory", "drop", CurrentDrop)
279 | else
280 | TriggerServerEvent("inventory:server:OpenInventory")
281 | end
282 | end
283 | end)
284 | end
285 | DisableControlAction(0, 37)
286 | if IsDisabledControlJustReleased(1, 37) then
287 | TriggerEvent('khol:hotbar')
288 | end
289 |
290 | if IsDisabledControlJustReleased(0, Keys["1"]) then
291 | QBCore.Functions.GetPlayerData(function(PlayerData)
292 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
293 | TriggerServerEvent("inventory:server:UseItemSlot", 1)
294 | end
295 | end)
296 | Wait(500)
297 | end
298 |
299 | if IsDisabledControlJustReleased(0, Keys["2"]) then
300 | QBCore.Functions.GetPlayerData(function(PlayerData)
301 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
302 | TriggerServerEvent("inventory:server:UseItemSlot", 2)
303 | end
304 | end)
305 | Wait(500)
306 | end
307 |
308 | if IsDisabledControlJustReleased(0, Keys["3"]) then
309 | QBCore.Functions.GetPlayerData(function(PlayerData)
310 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
311 | TriggerServerEvent("inventory:server:UseItemSlot", 3)
312 | end
313 | end)
314 | Wait(500)
315 | end
316 |
317 | if IsDisabledControlJustReleased(0, Keys["4"]) then
318 | QBCore.Functions.GetPlayerData(function(PlayerData)
319 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
320 | TriggerServerEvent("inventory:server:UseItemSlot", 4)
321 | end
322 | end)
323 | Wait(500)
324 | end
325 |
326 | if IsDisabledControlJustReleased(0, Keys["5"]) then
327 | QBCore.Functions.GetPlayerData(function(PlayerData)
328 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
329 | TriggerServerEvent("inventory:server:UseItemSlot", 5)
330 | end
331 | end)
332 | Wait(500)
333 | end
334 |
335 | --[[ if IsDisabledControlJustReleased(0, Keys["6"]) then
336 | QBCore.Functions.GetPlayerData(function(PlayerData)
337 | if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] then
338 | TriggerServerEvent("inventory:server:UseItemSlot", 41)
339 | end
340 | end)
341 | end]]--
342 | end
343 | end)
344 |
345 | RegisterNetEvent('inventory:client:ItemBox')
346 | AddEventHandler('inventory:client:ItemBox', function(itemData, type)
347 | SendNUIMessage({
348 | action = "itemBox",
349 | item = itemData,
350 | type = type
351 | })
352 | end)
353 |
354 | RegisterNetEvent('inventory:client:requiredItems')
355 | AddEventHandler('inventory:client:requiredItems', function(items, bool)
356 | local itemTable = {}
357 | if bool then
358 | for k, v in pairs(items) do
359 | table.insert(itemTable, {
360 | item = items[k].name,
361 | label = QBCore.Shared.Items[items[k].name]["label"],
362 | image = items[k].image,
363 | })
364 | end
365 | end
366 |
367 | SendNUIMessage({
368 | action = "requiredItem",
369 | items = itemTable,
370 | toggle = bool
371 | })
372 | end)
373 |
374 | Citizen.CreateThread(function()
375 | while true do
376 |
377 | Citizen.Wait(1)
378 | if DropsNear ~= nil then
379 | for k, v in pairs(DropsNear) do
380 | if DropsNear[k] ~= nil then
381 | DrawMarker(2, v.coords.x, v.coords.y, v.coords.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.15, 120, 10, 20, 155, false, false, false, 1, false, false, false)
382 | end
383 | end
384 | end
385 | end
386 | end)
387 |
388 | Citizen.CreateThread(function()
389 | while true do
390 |
391 | if Drops ~= nil and next(Drops) ~= nil then
392 | local pos = GetEntityCoords(GetPlayerPed(-1), true)
393 | for k, v in pairs(Drops) do
394 | if Drops[k] ~= nil then
395 | if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, v.coords.x, v.coords.y, v.coords.z, true) < 7.5 then
396 | DropsNear[k] = v
397 | if GetDistanceBetweenCoords(pos.x, pos.y, pos.z, v.coords.x, v.coords.y, v.coords.z, true) < 2 then
398 | CurrentDrop = k
399 | else
400 | CurrentDrop = nil
401 | end
402 | else
403 | DropsNear[k] = nil
404 | end
405 | end
406 | end
407 | else
408 | DropsNear = {}
409 | end
410 | Citizen.Wait(500)
411 | end
412 | end)
413 |
414 | RegisterNetEvent("QBCore:Client:OnPlayerLoaded")
415 | AddEventHandler("QBCore:Client:OnPlayerLoaded", function()
416 | --TriggerServerEvent("inventory:server:LoadDrops")
417 | end)
418 |
419 | RegisterNetEvent('inventory:server:RobPlayer')
420 | AddEventHandler('inventory:server:RobPlayer', function(TargetId)
421 | SendNUIMessage({
422 | action = "RobMoney",
423 | TargetId = TargetId,
424 | })
425 | end)
426 |
427 | RegisterNUICallback('RobMoney', function(data, cb)
428 | TriggerServerEvent("police:server:RobPlayer", data.TargetId)
429 | end)
430 |
431 | RegisterNUICallback('Notify', function(data, cb)
432 | QBCore.Functions.Notify(data.message, data.type)
433 | end)
434 |
435 | RegisterNetEvent("inventory:client:OpenInventory")
436 | AddEventHandler("inventory:client:OpenInventory", function(PlayerAmmo, inventory, other)
437 | if not IsEntityDead(GetPlayerPed(-1)) then
438 | --TriggerScreenblurFadeIn(0)
439 | ToggleHotbar(false)
440 | SetNuiFocus(true, true)
441 | if other ~= nil then
442 | currentOtherInventory = other.name
443 | end
444 | SendNUIMessage({
445 | action = "open",
446 | inventory = inventory,
447 | slots = MaxInventorySlots,
448 | other = other,
449 | maxweight = QBCore.Config.Player.MaxWeight,
450 | Ammo = PlayerAmmo,
451 | maxammo = Config.MaximumAmmoValues,
452 | maxammo = Config.MaximumAmmoValues,
453 | aaa = QBCore.Functions.GetPlayerData().charinfo.firstname..' '..QBCore.Functions.GetPlayerData().charinfo.lastname,
454 | charhealth = GetEntityHealth(GetPlayerPed(-1))-100,
455 | chararmor = GetPedArmour(GetPlayerPed(-1))
456 | })
457 | inInventory = true
458 | end
459 | end)
460 | RegisterNUICallback("GiveItem", function(data, cb)
461 | local player, distance = GetClosestPlayer()
462 | if player ~= -1 and distance < 2.5 then
463 | local playerPed = GetPlayerPed(player)
464 | local playerId = GetPlayerServerId(player)
465 | local plyCoords = GetEntityCoords(playerPed)
466 | local pos = GetEntityCoords(GetPlayerPed(-1))
467 | local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, plyCoords.x, plyCoords.y, plyCoords.z, true)
468 | if dist < 2.5 then
469 | SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true)
470 | TriggerServerEvent("inventory:server:GiveItem", playerId, data.inventory, data.item, data.amount)
471 | print(data.amount)
472 | else
473 | QBCore.Functions.Notify("No one nearby!", "error")
474 | end
475 | else
476 | QBCore.Functions.Notify("No one nearby!", "error")
477 | end
478 | end)
479 | function GetClosestPlayer()
480 | local closestPlayers = QBCore.Functions.GetPlayersFromCoords()
481 | local closestDistance = -1
482 | local closestPlayer = -1
483 | local coords = GetEntityCoords(GetPlayerPed(-1))
484 |
485 | for i=1, #closestPlayers, 1 do
486 | if closestPlayers[i] ~= PlayerId() then
487 | local pos = GetEntityCoords(GetPlayerPed(closestPlayers[i]))
488 | local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, coords.x, coords.y, coords.z, true)
489 |
490 | if closestDistance == -1 or closestDistance > distance then
491 | closestPlayer = closestPlayers[i]
492 | closestDistance = distance
493 | end
494 | end
495 | end
496 |
497 | return closestPlayer, closestDistance
498 | end
499 | RegisterNetEvent("inventory:client:ShowTrunkPos")
500 | AddEventHandler("inventory:client:ShowTrunkPos", function()
501 | showTrunkPos = true
502 | end)
503 |
504 | RegisterNetEvent("inventory:client:UpdatePlayerInventory")
505 | AddEventHandler("inventory:client:UpdatePlayerInventory", function(isError)
506 | SendNUIMessage({
507 | action = "update",
508 | inventory = QBCore.Functions.GetPlayerData().items,
509 | maxweight = QBCore.Config.Player.MaxWeight,
510 | slots = MaxInventorySlots,
511 | error = isError,
512 | })
513 | end)
514 |
515 | RegisterNetEvent("inventory:client:CraftItems")
516 | AddEventHandler("inventory:client:CraftItems", function(itemName, itemCosts, amount, toSlot, points)
517 | SendNUIMessage({
518 | action = "close",
519 | })
520 | isCrafting = true
521 | QBCore.Functions.Progressbar("repair_vehicle", "Crafting..", (math.random(2000, 5000) * amount), false, true, {
522 | disableMovement = true,
523 | disableCarMovement = true,
524 | disableMouse = false,
525 | disableCombat = true,
526 | }, {
527 | animDict = "mini@repair",
528 | anim = "fixing_a_player",
529 | flags = 16,
530 | }, {}, {}, function() -- Done
531 | StopAnimTask(GetPlayerPed(-1), "mini@repair", "fixing_a_player", 1.0)
532 | TriggerServerEvent("inventory:server:CraftItems", itemName, itemCosts, amount, toSlot, points)
533 | TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add')
534 | isCrafting = false
535 | end, function() -- Cancel
536 | StopAnimTask(GetPlayerPed(-1), "mini@repair", "fixing_a_player", 1.0)
537 | QBCore.Functions.Notify("Failed!", "error")
538 | isCrafting = false
539 | end)
540 | end)
541 |
542 | RegisterNetEvent('inventory:client:CraftAttachment')
543 | AddEventHandler('inventory:client:CraftAttachment', function(itemName, itemCosts, amount, toSlot, points)
544 | SendNUIMessage({
545 | action = "close",
546 | })
547 | isCrafting = true
548 | QBCore.Functions.Progressbar("repair_vehicle", "Crafting..", (math.random(2000, 5000) * amount), false, true, {
549 | disableMovement = true,
550 | disableCarMovement = true,
551 | disableMouse = false,
552 | disableCombat = true,
553 | }, {
554 | animDict = "mini@repair",
555 | anim = "fixing_a_player",
556 | flags = 16,
557 | }, {}, {}, function() -- Done
558 | StopAnimTask(GetPlayerPed(-1), "mini@repair", "fixing_a_player", 1.0)
559 | TriggerServerEvent("inventory:server:CraftAttachment", itemName, itemCosts, amount, toSlot, points)
560 | TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add')
561 | isCrafting = false
562 | end, function() -- Cancel
563 | StopAnimTask(GetPlayerPed(-1), "mini@repair", "fixing_a_player", 1.0)
564 | QBCore.Functions.Notify("Failed!", "error")
565 | isCrafting = false
566 | end)
567 | end)
568 |
569 | RegisterNetEvent("inventory:client:PickupSnowballs")
570 | AddEventHandler("inventory:client:PickupSnowballs", function()
571 | LoadAnimDict('anim@mp_snowball')
572 | TaskPlayAnim(GetPlayerPed(-1), 'anim@mp_snowball', 'pickup_snowball', 3.0, 3.0, -1, 0, 1, 0, 0, 0)
573 | QBCore.Functions.Progressbar("pickupsnowball", "Sneeuwballen oprapen..", 1500, false, true, {
574 | disableMovement = true,
575 | disableCarMovement = true,
576 | disableMouse = false,
577 | disableCombat = true,
578 | }, {}, {}, {}, function() -- Done
579 | ClearPedTasks(GetPlayerPed(-1))
580 | TriggerServerEvent('QBCore:Server:AddItem', "snowball", 1)
581 | TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items["snowball"], "add")
582 | end, function() -- Cancel
583 | ClearPedTasks(GetPlayerPed(-1))
584 | QBCore.Functions.Notify("Canceled..", "error")
585 | end)
586 | end)
587 |
588 | RegisterNetEvent("inventory:client:UseSnowball")
589 | AddEventHandler("inventory:client:UseSnowball", function(amount)
590 | GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("weapon_snowball"), amount, false, false)
591 | SetPedAmmo(GetPlayerPed(-1), GetHashKey("weapon_snowball"), amount)
592 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("weapon_snowball"), true)
593 | end)
594 |
595 | RegisterNetEvent("inventory:client:UseWeapon")
596 | AddEventHandler("inventory:client:UseWeapon", function(weaponData, shootbool)
597 | local weaponName = tostring(weaponData.name)
598 | if currentWeapon == weaponName then
599 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("WEAPON_UNARMED"), true)
600 | RemoveAllPedWeapons(GetPlayerPed(-1), true)
601 | TriggerEvent('weapons:client:SetCurrentWeapon', nil, shootbool)
602 | currentWeapon = nil
603 | elseif weaponName == "weapon_stickybomb" then
604 | GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(weaponName), ammo, false, false)
605 | SetPedAmmo(GetPlayerPed(-1), GetHashKey(weaponName), 1)
606 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey(weaponName), true)
607 | TriggerServerEvent('QBCore:Server:RemoveItem', weaponName, 1)
608 | TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
609 | currentWeapon = weaponName
610 | elseif weaponName == "weapon_snowball" then
611 | GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(weaponName), ammo, false, false)
612 | SetPedAmmo(GetPlayerPed(-1), GetHashKey(weaponName), 10)
613 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey(weaponName), true)
614 | TriggerServerEvent('QBCore:Server:RemoveItem', weaponName, 1)
615 | TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
616 | currentWeapon = weaponName
617 | else
618 | TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
619 | QBCore.Functions.TriggerCallback("weapon:server:GetWeaponAmmo", function(result)
620 | local ammo = tonumber(result)
621 | if weaponName == "weapon_fireextinguisher" then
622 | ammo = 4000
623 | end
624 | GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(weaponName), ammo, false, false)
625 | SetPedAmmo(GetPlayerPed(-1), GetHashKey(weaponName), ammo)
626 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey(weaponName), true)
627 | if weaponData.info.attachments ~= nil then
628 | for _, attachment in pairs(weaponData.info.attachments) do
629 | GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey(weaponName), GetHashKey(attachment.component))
630 | end
631 | end
632 | currentWeapon = weaponName
633 | end, CurrentWeaponData)
634 | end
635 | end)
636 |
637 | WeaponAttachments = {
638 | ["WEAPON_SNSPISTOL"] = {
639 | ["extendedclip"] = {
640 | component = "COMPONENT_SNSPISTOL_CLIP_02",
641 | label = "Extended Clip",
642 | item = "pistol_extendedclip",
643 | },
644 | },
645 | ["WEAPON_VINTAGEPISTOL"] = {
646 | ["suppressor"] = {
647 | component = "COMPONENT_AT_PI_SUPP",
648 | label = "Suppressor",
649 | item = "pistol_suppressor",
650 | },
651 | ["extendedclip"] = {
652 | component = "COMPONENT_VINTAGEPISTOL_CLIP_02",
653 | label = "Extended Clip",
654 | item = "pistol_extendedclip",
655 | },
656 | },
657 | ["WEAPON_MICROSMG"] = {
658 | ["suppressor"] = {
659 | component = "COMPONENT_AT_AR_SUPP_02",
660 | label = "Suppressor",
661 | item = "smg_suppressor",
662 | },
663 | ["extendedclip"] = {
664 | component = "COMPONENT_MICROSMG_CLIP_02",
665 | label = "Extended Clip",
666 | item = "smg_extendedclip",
667 | },
668 | ["flashlight"] = {
669 | component = "COMPONENT_AT_PI_FLSH",
670 | label = "Flashlight",
671 | item = "smg_flashlight",
672 | },
673 | ["scope"] = {
674 | component = "COMPONENT_AT_SCOPE_MACRO",
675 | label = "Scope",
676 | item = "smg_scope",
677 | },
678 | },
679 | ["WEAPON_MINISMG"] = {
680 | ["extendedclip"] = {
681 | component = "COMPONENT_MINISMG_CLIP_02",
682 | label = "Extended Clip",
683 | item = "smg_extendedclip",
684 | },
685 | },
686 | ["WEAPON_COMPACTRIFLE"] = {
687 | ["extendedclip"] = {
688 | component = "COMPONENT_COMPACTRIFLE_CLIP_02",
689 | label = "Extended Clip",
690 | item = "rifle_extendedclip",
691 | },
692 | ["drummag"] = {
693 | component = "COMPONENT_COMPACTRIFLE_CLIP_03",
694 | label = "Drum Mag",
695 | item = "rifle_drummag",
696 | },
697 | },
698 | }
699 |
700 | function FormatWeaponAttachments(itemdata)
701 | local attachments = {}
702 | itemdata.name = itemdata.name:upper()
703 | if itemdata.info.attachments ~= nil and next(itemdata.info.attachments) ~= nil then
704 | for k, v in pairs(itemdata.info.attachments) do
705 | if WeaponAttachments[itemdata.name] ~= nil then
706 | for key, value in pairs(WeaponAttachments[itemdata.name]) do
707 | if value.component == v.component then
708 | table.insert(attachments, {
709 | attachment = key,
710 | label = value.label
711 | })
712 | end
713 | end
714 | end
715 | end
716 | end
717 | return attachments
718 | end
719 |
720 | RegisterNUICallback('GetWeaponData', function(data, cb)
721 | local data = {
722 | WeaponData = QBCore.Shared.Items[data.weapon],
723 | AttachmentData = FormatWeaponAttachments(data.ItemData)
724 | }
725 | cb(data)
726 | end)
727 |
728 | RegisterNUICallback('RemoveAttachment', function(data, cb)
729 | local WeaponData = QBCore.Shared.Items[data.WeaponData.name]
730 | local Attachment = WeaponAttachments[WeaponData.name:upper()][data.AttachmentData.attachment]
731 |
732 | QBCore.Functions.TriggerCallback('weapons:server:RemoveAttachment', function(NewAttachments)
733 | if NewAttachments ~= false then
734 | local Attachies = {}
735 | RemoveWeaponComponentFromPed(GetPlayerPed(-1), GetHashKey(data.WeaponData.name), GetHashKey(Attachment.component))
736 | for k, v in pairs(NewAttachments) do
737 | for wep, pew in pairs(WeaponAttachments[WeaponData.name:upper()]) do
738 | if v.component == pew.component then
739 | table.insert(Attachies, {
740 | attachment = pew.item,
741 | label = pew.label,
742 | })
743 | end
744 | end
745 | end
746 | local DJATA = {
747 | Attachments = Attachies,
748 | WeaponData = WeaponData,
749 | }
750 | cb(DJATA)
751 | else
752 | RemoveWeaponComponentFromPed(GetPlayerPed(-1), GetHashKey(data.WeaponData.name), GetHashKey(Attachment.component))
753 | cb({})
754 | end
755 | end, data.AttachmentData, data.WeaponData)
756 | end)
757 |
758 | RegisterNetEvent("inventory:client:CheckWeapon")
759 | AddEventHandler("inventory:client:CheckWeapon", function(weaponName)
760 | if currentWeapon == weaponName then
761 | TriggerEvent('weapons:ResetHolster')
762 | SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("WEAPON_UNARMED"), true)
763 | RemoveAllPedWeapons(GetPlayerPed(-1), true)
764 | currentWeapon = nil
765 | end
766 | end)
767 |
768 | RegisterNetEvent("inventory:client:AddDropItem")
769 | AddEventHandler("inventory:client:AddDropItem", function(dropId, player)
770 | local coords = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(player)))
771 | local forward = GetEntityForwardVector(GetPlayerPed(GetPlayerFromServerId(player)))
772 | local x, y, z = table.unpack(coords + forward * 0.5)
773 | Drops[dropId] = {
774 | id = dropId,
775 | coords = {
776 | x = x,
777 | y = y,
778 | z = z - 0.3,
779 | },
780 | }
781 | end)
782 |
783 | RegisterNetEvent("inventory:client:RemoveDropItem")
784 | AddEventHandler("inventory:client:RemoveDropItem", function(dropId)
785 | Drops[dropId] = nil
786 | end)
787 |
788 | RegisterNetEvent("inventory:client:DropItemAnim")
789 | AddEventHandler("inventory:client:DropItemAnim", function()
790 | SendNUIMessage({
791 | action = "close",
792 | })
793 | RequestAnimDict("pickup_object")
794 | while not HasAnimDictLoaded("pickup_object") do
795 | Citizen.Wait(7)
796 | end
797 | TaskPlayAnim(GetPlayerPed(-1), "pickup_object" ,"pickup_low" ,8.0, -8.0, -1, 1, 0, false, false, false )
798 | Citizen.Wait(2000)
799 | ClearPedTasks(GetPlayerPed(-1))
800 | end)
801 |
802 | --[[RegisterNetEvent("inventory:client:ShowId")
803 | AddEventHandler("inventory:client:ShowId", function(sourceId, citizenid, character)
804 | local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(sourceId)), false)
805 | local pos = GetEntityCoords(GetPlayerPed(-1), false)
806 | if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true) < 2.0) then
807 | local gender = "Man"
808 | if character.gender == 1 then
809 | gender = "Vrouw"
810 | end
811 | TriggerEvent('chat:addMessage', {
812 | template = '{0}:
CSN: {1}
First Name: {2}
Last Name: {3}
Birth Date: {4}
Sex: {5}
Nationality: {6}
Job: {7}
',
813 | args = {'ID-Card', character.citizenid, character.firstname, character.lastname, character.birthdate, gender, character.nationality,character.job}
814 | })
815 | end
816 | end)
817 |
818 | RegisterNetEvent("inventory:client:ShowDriverLicense")
819 | AddEventHandler("inventory:client:ShowDriverLicense", function(sourceId, citizenid, character)
820 | local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(sourceId)), false)
821 | local pos = GetEntityCoords(GetPlayerPed(-1), false)
822 | if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true) < 2.0) then
823 | TriggerEvent('chat:addMessage', {
824 | template = '{0}:
First Name: {1}
Last Name: {2}
Birth Date: {3}
Licenses: {4}
',
825 | args = {'Drivers license', character.firstname, character.lastname, character.birthdate, character.type}
826 | })
827 | end
828 | end)]]
829 |
830 | RegisterNetEvent("inventory:client:SetCurrentStash")
831 | AddEventHandler("inventory:client:SetCurrentStash", function(stash)
832 | CurrentStash = stash
833 | end)
834 |
835 | RegisterNUICallback('getCombineItem', function(data, cb)
836 | cb(QBCore.Shared.Items[data.item])
837 | end)
838 |
839 | RegisterNUICallback("CloseInventory", function(data, cb)
840 | if currentOtherInventory == "none-inv" then
841 | CurrentDrop = 0
842 | CurrentVehicle = nil
843 | CurrentGlovebox = nil
844 | CurrentStash = nil
845 | --TriggerScreenblurFadeOut(0)
846 | SetNuiFocus(false, false)
847 | inInventory = false
848 | ClearPedTasks(GetPlayerPed(-1))
849 | DeletePedScreen()
850 | return
851 | end
852 | if CurrentVehicle ~= nil then
853 | CloseTrunk()
854 | TriggerServerEvent("inventory:server:SaveInventory", "trunk", CurrentVehicle)
855 | CurrentVehicle = nil
856 | elseif CurrentGlovebox ~= nil then
857 | TriggerServerEvent("inventory:server:SaveInventory", "glovebox", CurrentGlovebox)
858 | CurrentGlovebox = nil
859 | elseif CurrentStash ~= nil then
860 | TriggerServerEvent("inventory:server:SaveInventory", "stash", CurrentStash)
861 | CurrentStash = nil
862 | else
863 | TriggerServerEvent("inventory:server:SaveInventory", "drop", CurrentDrop)
864 | CurrentDrop = 0
865 | end
866 | --TriggerScreenblurFadeOut(0)
867 | SetNuiFocus(false, false)
868 | inInventory = false
869 | TriggerEvent('randPickupAnim')
870 | DeletePedScreen()
871 | end)
872 | RegisterNUICallback("UseItem", function(data, cb)
873 | TriggerServerEvent("inventory:server:UseItem", data.inventory, data.item)
874 | end)
875 |
876 | RegisterNUICallback("combineItem", function(data)
877 | Citizen.Wait(150)
878 | TriggerServerEvent('inventory:server:combineItem', data.reward, data.fromItem, data.toItem)
879 | TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[data.reward], 'add')
880 | end)
881 |
882 | RegisterNUICallback('combineWithAnim', function(data)
883 | local combineData = data.combineData
884 | local aDict = combineData.anim.dict
885 | local aLib = combineData.anim.lib
886 | local animText = combineData.anim.text
887 | local animTimeout = combineData.anim.timeOut
888 |
889 | QBCore.Functions.Progressbar("combine_anim", animText, animTimeout, false, true, {
890 | disableMovement = false,
891 | disableCarMovement = true,
892 | disableMouse = false,
893 | disableCombat = true,
894 | }, {
895 | animDict = aDict,
896 | anim = aLib,
897 | flags = 16,
898 | }, {}, {}, function() -- Done
899 | StopAnimTask(GetPlayerPed(-1), aDict, aLib, 1.0)
900 | end, function() -- Cancel
901 | StopAnimTask(GetPlayerPed(-1), aDict, aLib, 1.0)
902 | QBCore.Functions.Notify("Mislukt!", "error")
903 | end)
904 | TriggerServerEvent('inventory:server:combineItem', combineData.reward, data.requiredItem, data.usedItem)
905 | TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[combineData.reward], 'add')
906 | end)
907 |
908 | RegisterNUICallback("SetInventoryData", function(data, cb)
909 | TriggerServerEvent("inventory:server:SetInventoryData", data.fromInventory, data.toInventory, data.fromSlot, data.toSlot, data.fromAmount, data.toAmount)
910 | end)
911 |
912 | RegisterNUICallback("PlayDropSound", function(data, cb)
913 | SendNUIMessage({
914 | action = 'sound'
915 | })
916 | end)
917 | RegisterNUICallback("PlayDropFail", function(data, cb)
918 | SendNUIMessage({
919 | action = 'sound'
920 | })
921 | end)
922 |
923 | function OpenTrunk()
924 | local vehicle = QBCore.Functions.GetClosestVehicle()
925 | while (not HasAnimDictLoaded("amb@prop_human_bum_bin@idle_b")) do
926 | RequestAnimDict("amb@prop_human_bum_bin@idle_b")
927 | Citizen.Wait(100)
928 | end
929 | TaskPlayAnim(GetPlayerPed(-1), "amb@prop_human_bum_bin@idle_b", "idle_d", 4.0, 4.0, -1, 50, 0, false, false, false)
930 | if (IsBackEngine(GetEntityModel(vehicle))) then
931 | SetVehicleDoorOpen(vehicle, 4, false, false)
932 | else
933 | SetVehicleDoorOpen(vehicle, 5, false, false)
934 | end
935 | end
936 |
937 | function CloseTrunk()
938 | local vehicle = QBCore.Functions.GetClosestVehicle()
939 | while (not HasAnimDictLoaded("amb@prop_human_bum_bin@idle_b")) do
940 | RequestAnimDict("amb@prop_human_bum_bin@idle_b")
941 | Citizen.Wait(100)
942 | end
943 | TaskPlayAnim(GetPlayerPed(-1), "amb@prop_human_bum_bin@idle_b", "exit", 4.0, 4.0, -1, 50, 0, false, false, false)
944 | if (IsBackEngine(GetEntityModel(vehicle))) then
945 | SetVehicleDoorShut(vehicle, 4, false)
946 | else
947 | SetVehicleDoorShut(vehicle, 5, false)
948 | end
949 | end
950 |
951 | function IsBackEngine(vehModel)
952 | for _, model in pairs(BackEngineVehicles) do
953 | if GetHashKey(model) == vehModel then
954 | return true
955 | end
956 | end
957 | return false
958 | end
959 |
960 | function ToggleHotbar(toggle)
961 | local HotbarItems = {
962 | [1] = QBCore.Functions.GetPlayerData().items[1],
963 | [2] = QBCore.Functions.GetPlayerData().items[2],
964 | [3] = QBCore.Functions.GetPlayerData().items[3],
965 | [4] = QBCore.Functions.GetPlayerData().items[4],
966 | [5] = QBCore.Functions.GetPlayerData().items[5],
967 | [41] = QBCore.Functions.GetPlayerData().items[41],
968 | }
969 | for k,v in pairs(HotbarItems) do
970 | if v.image ~= nil and v.name ~= nil then
971 | if v.image == 'placeholder.png' then
972 | v.image = v.name..'.png' or v.name..'.jpg'
973 | end
974 | if type(v.info) == 'string' then
975 | v.info = {}
976 | end
977 | if not string.find(v.name,'weapon') then
978 | if v.info.quality == nil then
979 | v.info.quality = 100
980 | end
981 | end
982 | end
983 | end
984 | if toggle then
985 | SendNUIMessage({
986 | action = "toggleHotbar",
987 | open = true,
988 | items = HotbarItems
989 | })
990 | else
991 | SendNUIMessage({
992 | action = "toggleHotbar",
993 | open = false,
994 | })
995 | end
996 | end
997 |
998 | function LoadAnimDict( dict )
999 | while ( not HasAnimDictLoaded( dict ) ) do
1000 | RequestAnimDict( dict )
1001 | Citizen.Wait( 5 )
1002 | end
1003 | end
1004 |
1005 | function closeInventory()
1006 | isInInventory = false
1007 | ClearPedSecondaryTask(PlayerPedId())
1008 | SetNuiFocus(false, false)
1009 | SendNUIMessage({
1010 | action = "close",
1011 | })
1012 | ClearPedTasks(PlayerPedId())
1013 | end
1014 | RegisterCommand('closeinv', function()
1015 | closeInventory()
1016 | end, false)
--------------------------------------------------------------------------------
/server/main.lua:
--------------------------------------------------------------------------------
1 | QBCore = nil
2 | TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
3 |
4 | Drops = {}
5 | Trunks = {}
6 | Gloveboxes = {}
7 | Stashes = {}
8 | ShopItems = {}
9 |
10 | RegisterServerEvent("inventory:server:LoadDrops")
11 | AddEventHandler('inventory:server:LoadDrops', function()
12 | local src = source
13 | if next(Drops) ~= nil then
14 | TriggerClientEvent("inventory:client:AddDropItem", -1, dropId, source)
15 | TriggerClientEvent("inventory:client:AddDropItem", src, Drops)
16 | end
17 | end)
18 |
19 | RegisterServerEvent("inventory:server:addTrunkItems")
20 | AddEventHandler('inventory:server:addTrunkItems', function(plate, items)
21 | Trunks[plate] = {}
22 | Trunks[plate].items = items
23 | end)
24 |
25 | RegisterServerEvent("inventory:server:combineItem")
26 | AddEventHandler('inventory:server:combineItem', function(item, fromItem, toItem)
27 | local src = source
28 | local ply = QBCore.Functions.GetPlayer(src)
29 | if ply.Functions.GetItemByName(fromItem) ~= nil and ply.Functions.GetItemByName(toItem) ~= nil then
30 | ply.Functions.AddItem(item, 1)
31 | ply.Functions.RemoveItem(fromItem, 1)
32 | ply.Functions.RemoveItem(toItem, 1)
33 | else
34 | DropPlayer(src, "You Have Been Auto Kicked For Exploting Glitches")
35 | end
36 | end)
37 |
38 | RegisterServerEvent("inventory:server:CraftItems")
39 | AddEventHandler('inventory:server:CraftItems', function(itemName, itemCosts, amount, toSlot, points)
40 | local src = source
41 | local Player = QBCore.Functions.GetPlayer(src)
42 | local amount = tonumber(amount)
43 | if itemName ~= nil and itemCosts ~= nil then
44 | for k, v in pairs(itemCosts) do
45 | Player.Functions.RemoveItem(k, (v*amount))
46 | end
47 | Player.Functions.AddItem(itemName, amount, toSlot)
48 | Player.Functions.SetMetaData("craftingrep", Player.PlayerData.metadata["craftingrep"]+(points*amount))
49 | TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, false)
50 | end
51 | end)
52 |
53 | RegisterServerEvent('inventory:server:CraftAttachment')
54 | AddEventHandler('inventory:server:CraftAttachment', function(itemName, itemCosts, amount, toSlot, points)
55 | local src = source
56 | local Player = QBCore.Functions.GetPlayer(src)
57 | local amount = tonumber(amount)
58 | if itemName ~= nil and itemCosts ~= nil then
59 | for k, v in pairs(itemCosts) do
60 | Player.Functions.RemoveItem(k, (v*amount))
61 | end
62 | Player.Functions.AddItem(itemName, amount, toSlot)
63 | Player.Functions.SetMetaData("attachmentcraftingrep", Player.PlayerData.metadata["attachmentcraftingrep"]+(points*amount))
64 | TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, false)
65 | end
66 | end)
67 |
68 | RegisterServerEvent("inventory:server:SetIsOpenState")
69 | AddEventHandler('inventory:server:SetIsOpenState', function(IsOpen, type, id)
70 | if not IsOpen then
71 | if type == "stash" then
72 | Stashes[id].isOpen = false
73 | elseif type == "trunk" then
74 | Trunks[id].isOpen = false
75 | elseif type == "glovebox" then
76 | Gloveboxes[id].isOpen = false
77 | end
78 | end
79 | end)
80 | RegisterServerEvent("inventory:server:GiveItem")
81 | AddEventHandler('inventory:server:GiveItem', function(name, inventory, item, amount)
82 | local src = source
83 | local Player = QBCore.Functions.GetPlayer(src)
84 | local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(name))
85 | local Target = OtherPlayer.PlayerData.charinfo.firstname..' '..OtherPlayer.PlayerData.charinfo.lastname
86 | local YourName = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
87 | if amount ~= 0 then
88 | if Player.Functions.RemoveItem(item.name, amount,false, item.info) and OtherPlayer.Functions.AddItem(item.name, amount,false, item.info) then
89 | TriggerClientEvent('QBCore:Notify', src, "You Sent "..item.label..' To '..Target)
90 | TriggerClientEvent('inventory:client:ItemBox',src, QBCore.Shared.Items[item.name], "remove")
91 | TriggerClientEvent('QBCore:Notify', name, "You Received "..item.label..' From '..YourName)
92 | TriggerClientEvent('inventory:client:ItemBox',name, QBCore.Shared.Items[item.name], "add")
93 | end
94 | end
95 | end)
96 | RegisterServerEvent("inventory:server:OpenInventory")
97 | AddEventHandler('inventory:server:OpenInventory', function(name, id, other)
98 | local src = source
99 | local Player = QBCore.Functions.GetPlayer(src)
100 | local PlayerAmmo = {}
101 | QBCore.Functions.ExecuteSql(false, "SELECT * FROM `playerammo` WHERE `citizenid` = '"..Player.PlayerData.citizenid.."'", function(ammo)
102 | if ammo[1] ~= nil then
103 | PlayerAmmo = json.decode(ammo[1].ammo)
104 | end
105 |
106 | if name ~= nil and id ~= nil then
107 | local secondInv = {}
108 | if name == "stash" then
109 | if Stashes[id] ~= nil then
110 | if Stashes[id].isOpen then
111 | local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
112 | if Target ~= nil then
113 | TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
114 | else
115 | Stashes[id].isOpen = false
116 | end
117 | end
118 | end
119 | local maxweight = 1000000
120 | local slots = 50
121 | if other ~= nil then
122 | maxweight = other.maxweight ~= nil and other.maxweight or 1000000
123 | slots = other.slots ~= nil and other.slots or 50
124 | end
125 | secondInv.name = "stash-"..id
126 | secondInv.label = "Stash-"..id
127 | secondInv.maxweight = maxweight
128 | secondInv.inventory = {}
129 | secondInv.slots = slots
130 | if Stashes[id] ~= nil and Stashes[id].isOpen then
131 | secondInv.name = "none-inv"
132 | secondInv.label = "Stash-None"
133 | secondInv.maxweight = 1000000
134 | secondInv.inventory = {}
135 | secondInv.slots = 0
136 | else
137 | local stashItems = GetStashItems(id)
138 | if next(stashItems) ~= nil then
139 | secondInv.inventory = stashItems
140 | Stashes[id] = {}
141 | Stashes[id].items = stashItems
142 | Stashes[id].isOpen = src
143 | Stashes[id].label = secondInv.label
144 | else
145 | Stashes[id] = {}
146 | Stashes[id].items = {}
147 | Stashes[id].isOpen = src
148 | Stashes[id].label = secondInv.label
149 | end
150 | end
151 | elseif name == "trunk" then
152 | if Trunks[id] ~= nil then
153 | if Trunks[id].isOpen then
154 | local Target = QBCore.Functions.GetPlayer(Trunks[id].isOpen)
155 | if Target ~= nil then
156 | TriggerClientEvent('inventory:client:CheckOpenState', Trunks[id].isOpen, name, id, Trunks[id].label)
157 | else
158 | Trunks[id].isOpen = false
159 | end
160 | end
161 | end
162 | secondInv.name = "trunk-"..id
163 | secondInv.label = "Trunk-"..id
164 | secondInv.maxweight = other.maxweight ~= nil and other.maxweight or 60000
165 | secondInv.inventory = {}
166 | secondInv.slots = other.slots ~= nil and other.slots or 50
167 | if (Trunks[id] ~= nil and Trunks[id].isOpen) or (QBCore.Shared.SplitStr(id, "PLZI")[2] ~= nil and Player.PlayerData.job.name ~= "police") then
168 | secondInv.name = "none-inv"
169 | secondInv.label = "Trunk-None"
170 | secondInv.maxweight = other.maxweight ~= nil and other.maxweight or 60000
171 | secondInv.inventory = {}
172 | secondInv.slots = 0
173 | else
174 | if id ~= nil then
175 | local ownedItems = GetOwnedVehicleItems(id)
176 | if IsVehicleOwned(id) and next(ownedItems) ~= nil then
177 | secondInv.inventory = ownedItems
178 | Trunks[id] = {}
179 | Trunks[id].items = ownedItems
180 | Trunks[id].isOpen = src
181 | Trunks[id].label = secondInv.label
182 | elseif Trunks[id] ~= nil and not Trunks[id].isOpen then
183 | secondInv.inventory = Trunks[id].items
184 | Trunks[id].isOpen = src
185 | Trunks[id].label = secondInv.label
186 | else
187 | Trunks[id] = {}
188 | Trunks[id].items = {}
189 | Trunks[id].isOpen = src
190 | Trunks[id].label = secondInv.label
191 | end
192 | end
193 | end
194 | elseif name == "glovebox" then
195 | if Gloveboxes[id] ~= nil then
196 | if Gloveboxes[id].isOpen then
197 | local Target = QBCore.Functions.GetPlayer(Gloveboxes[id].isOpen)
198 | if Target ~= nil then
199 | TriggerClientEvent('inventory:client:CheckOpenState', Gloveboxes[id].isOpen, name, id, Gloveboxes[id].label)
200 | else
201 | Gloveboxes[id].isOpen = false
202 | end
203 | end
204 | end
205 | secondInv.name = "glovebox-"..id
206 | secondInv.label = "Glovebox-"..id
207 | secondInv.maxweight = 10000
208 | secondInv.inventory = {}
209 | secondInv.slots = 5
210 | if Gloveboxes[id] ~= nil and Gloveboxes[id].isOpen then
211 | secondInv.name = "none-inv"
212 | secondInv.label = "Glovebox-None"
213 | secondInv.maxweight = 10000
214 | secondInv.inventory = {}
215 | secondInv.slots = 0
216 | else
217 | local ownedItems = GetOwnedVehicleGloveboxItems(id)
218 | if Gloveboxes[id] ~= nil and not Gloveboxes[id].isOpen then
219 | secondInv.inventory = Gloveboxes[id].items
220 | Gloveboxes[id].isOpen = src
221 | Gloveboxes[id].label = secondInv.label
222 | elseif IsVehicleOwned(id) and next(ownedItems) ~= nil then
223 | secondInv.inventory = ownedItems
224 | Gloveboxes[id] = {}
225 | Gloveboxes[id].items = ownedItems
226 | Gloveboxes[id].isOpen = src
227 | Gloveboxes[id].label = secondInv.label
228 | else
229 | Gloveboxes[id] = {}
230 | Gloveboxes[id].items = {}
231 | Gloveboxes[id].isOpen = src
232 | Gloveboxes[id].label = secondInv.label
233 | end
234 | end
235 | elseif name == "shop" then
236 | secondInv.name = "itemshop-"..id
237 | secondInv.label = other.label
238 | secondInv.maxweight = 900000
239 | secondInv.inventory = SetupShopItems(id, other.items)
240 | ShopItems[id] = {}
241 | ShopItems[id].items = other.items
242 | secondInv.slots = #other.items
243 | elseif name == "traphouse" then
244 | secondInv.name = "traphouse-"..id
245 | secondInv.label = other.label
246 | secondInv.maxweight = 900000
247 | secondInv.inventory = other.items
248 | secondInv.slots = other.slots
249 | elseif name == "crafting" then
250 | secondInv.name = "crafting"
251 | secondInv.label = other.label
252 | secondInv.maxweight = 900000
253 | secondInv.inventory = other.items
254 | secondInv.slots = #other.items
255 | elseif name == "attachment_crafting" then
256 | secondInv.name = "attachment_crafting"
257 | secondInv.label = other.label
258 | secondInv.maxweight = 900000
259 | secondInv.inventory = other.items
260 | secondInv.slots = #other.items
261 | elseif name == "otherplayer" then
262 | local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(id))
263 | if OtherPlayer ~= nil then
264 | secondInv.name = "otherplayer-"..id
265 | secondInv.label = "Player-"..id
266 | secondInv.maxweight = QBCore.Config.Player.MaxWeight
267 | secondInv.inventory = OtherPlayer.PlayerData.items
268 | if Player.PlayerData.job.name == "police" and Player.PlayerData.job.onduty then
269 | secondInv.slots = QBCore.Config.Player.MaxInvSlots
270 | else
271 | secondInv.slots = QBCore.Config.Player.MaxInvSlots - 1
272 | end
273 | Citizen.Wait(250)
274 | end
275 | else
276 | if Drops[id] ~= nil and not Drops[id].isOpen then
277 | secondInv.name = id
278 | secondInv.label = "Dropped-"..tostring(id)
279 | secondInv.maxweight = 100000
280 | secondInv.inventory = Drops[id].items
281 | secondInv.slots = 30
282 | Drops[id].isOpen = src
283 | Drops[id].label = secondInv.label
284 | else
285 | secondInv.name = "none-inv"
286 | secondInv.label = "Dropped-None"
287 | secondInv.maxweight = 100000
288 | secondInv.inventory = {}
289 | secondInv.slots = 0
290 | --Drops[id].label = secondInv.label
291 | end
292 | end
293 | for k,v in pairs(Player.PlayerData.items) do
294 | if v.image == 'placeholder.png' then
295 | v.image = v.name..'.png' or v.name..'.jpg'
296 | end
297 | if type(v.info) == 'string' then
298 | v.info = {}
299 | end
300 | if not string.find(v.name,'weapon') then
301 | if v.info.quality == nil then
302 | v.info.quality = 100
303 | end
304 | end
305 | end
306 | for k,v in pairs(secondInv.inventory) do
307 | if v.image == 'placeholder.png' then
308 | v.image = v.name..'.png' or v.name..'.jpg'
309 | end
310 | if type(v.info) == 'string' then
311 | v.info = {}
312 | end
313 | if not string.find(v.name,'weapon') then
314 | if v.info.quality == nil then
315 | v.info.quality = 100
316 | end
317 | end
318 | end
319 | TriggerClientEvent("inventory:client:OpenInventory", src, PlayerAmmo, Player.PlayerData.items, secondInv)
320 | else
321 | for k,v in pairs(Player.PlayerData.items) do
322 | if v.image == 'placeholder.png' then
323 | v.image = v.name..'.png' or v.name..'.jpg'
324 | end
325 | if type(v.info) == 'string' then
326 | v.info = {}
327 | end
328 | if not string.find(v.name,'weapon') then
329 | if v.info.quality == nil then
330 | v.info.quality = 100
331 | end
332 | end
333 | end
334 | TriggerClientEvent("inventory:client:OpenInventory", src, PlayerAmmo, Player.PlayerData.items)
335 | end
336 | end)
337 | end)
338 |
339 | RegisterServerEvent("inventory:server:SaveInventory")
340 | AddEventHandler('inventory:server:SaveInventory', function(type, id)
341 | if type == "trunk" then
342 | if (IsVehicleOwned(id)) then
343 | SaveOwnedVehicleItems(id, Trunks[id].items)
344 | else
345 | Trunks[id].isOpen = false
346 | end
347 | elseif type == "glovebox" then
348 | if (IsVehicleOwned(id)) then
349 | SaveOwnedGloveboxItems(id, Gloveboxes[id].items)
350 | else
351 | Gloveboxes[id].isOpen = false
352 | end
353 | elseif type == "stash" then
354 | SaveStashItems(id, Stashes[id].items)
355 | elseif type == "drop" then
356 | if Drops[id] ~= nil then
357 | Drops[id].isOpen = false
358 | if Drops[id].items == nil or next(Drops[id].items) == nil then
359 | Drops[id] = nil
360 | TriggerClientEvent("inventory:client:RemoveDropItem", -1, id)
361 | end
362 | end
363 | end
364 | end)
365 |
366 | RegisterServerEvent("inventory:server:UseItemSlot")
367 | AddEventHandler('inventory:server:UseItemSlot', function(slot)
368 | local src = source
369 | local Player = QBCore.Functions.GetPlayer(src)
370 | local itemData = Player.Functions.GetItemBySlot(slot)
371 |
372 | if itemData ~= nil then
373 | local itemInfo = QBCore.Shared.Items[itemData.name]
374 | if itemData.type == "weapon" then
375 | if itemData.info.quality ~= nil then
376 | if itemData.info.quality > 0 then
377 | TriggerClientEvent("inventory:client:UseWeapon", src, itemData, true)
378 | else
379 | TriggerClientEvent("inventory:client:UseWeapon", src, itemData, false)
380 | end
381 | else
382 | TriggerClientEvent("inventory:client:UseWeapon", src, itemData, true)
383 | end
384 | TriggerClientEvent('inventory:client:ItemBox', src, itemInfo, "use")
385 | elseif itemData.useable then
386 | TriggerClientEvent("QBCore:Client:UseItem", src, itemData)
387 | TriggerClientEvent('inventory:client:ItemBox', src, itemInfo, "use")
388 | end
389 | end
390 | end)
391 |
392 | RegisterServerEvent("inventory:server:UseItem")
393 | AddEventHandler('inventory:server:UseItem', function(inventory, item)
394 | local src = source
395 | local Player = QBCore.Functions.GetPlayer(src)
396 | if inventory == "player" or inventory == "hotbar" then
397 | local itemData = Player.Functions.GetItemBySlot(item.slot)
398 | if itemData ~= nil then
399 | TriggerClientEvent("QBCore:Client:UseItem", src, itemData)
400 | end
401 | end
402 | end)
403 |
404 | RegisterServerEvent("inventory:server:SetInventoryData")
405 | AddEventHandler('inventory:server:SetInventoryData', function(fromInventory, toInventory, fromSlot, toSlot, fromAmount, toAmount)
406 | local src = source
407 | local Player = QBCore.Functions.GetPlayer(src)
408 | local fromSlot = tonumber(fromSlot)
409 | local toSlot = tonumber(toSlot)
410 |
411 | if (fromInventory == "player" or fromInventory == "hotbar") and (QBCore.Shared.SplitStr(toInventory, "-")[1] == "itemshop" or toInventory == "crafting") then
412 | return
413 | end
414 |
415 | if fromInventory == "player" or fromInventory == "hotbar" then
416 | local fromItemData = Player.Functions.GetItemBySlot(fromSlot)
417 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
418 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
419 | if toInventory == "player" or toInventory == "hotbar" then
420 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
421 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
422 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
423 | --Player.PlayerData.items[toSlot] = fromItemData
424 | if toItemData ~= nil then
425 | --Player.PlayerData.items[fromSlot] = toItemData
426 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
427 | if toItemData.name ~= fromItemData.name then
428 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
429 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
430 | end
431 | else
432 | --Player.PlayerData.items[fromSlot] = nil
433 | end
434 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
435 | elseif QBCore.Shared.SplitStr(toInventory, "-")[1] == "otherplayer" then
436 | local playerId = tonumber(QBCore.Shared.SplitStr(toInventory, "-")[2])
437 | local OtherPlayer = QBCore.Functions.GetPlayer(playerId)
438 | local toItemData = OtherPlayer.PlayerData.items[toSlot]
439 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
440 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
441 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
442 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="citizen2", name=itemInfo["name"], amount=fromAmount, target=OtherPlayer.PlayerData.citizenid})
443 | TriggerEvent("qb-log:server:CreateLog", "robbing", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** to player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
444 | OtherPlayer.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
445 | elseif QBCore.Shared.SplitStr(toInventory, "-")[1] == "trunk" then
446 | local plate = QBCore.Shared.SplitStr(toInventory, "-")[2]
447 | local toItemData = Trunks[plate].items[toSlot]
448 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
449 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
450 | --Player.PlayerData.items[toSlot] = fromItemData
451 | if toItemData ~= nil then
452 | --Player.PlayerData.items[fromSlot] = toItemData
453 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
454 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
455 | if toItemData.name ~= fromItemData.name then
456 | RemoveFromTrunk(plate, fromSlot, itemInfo["name"], toAmount)
457 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
458 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="trunk1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=plate})
459 | TriggerEvent("qb-log:server:CreateLog", "trunk", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
460 | end
461 | else
462 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
463 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="trunk2", name=fromItemData.name, amount=fromAmount, target=plate})
464 | TriggerEvent("qb-log:server:CreateLog", "trunk", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
465 | end
466 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
467 | AddToTrunk(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
468 | elseif QBCore.Shared.SplitStr(toInventory, "-")[1] == "glovebox" then
469 | local plate = QBCore.Shared.SplitStr(toInventory, "-")[2]
470 | local toItemData = Gloveboxes[plate].items[toSlot]
471 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
472 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
473 | --Player.PlayerData.items[toSlot] = fromItemData
474 | if toItemData ~= nil then
475 | --Player.PlayerData.items[fromSlot] = toItemData
476 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
477 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
478 | if toItemData.name ~= fromItemData.name then
479 | RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], toAmount)
480 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
481 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="glovebox1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=plate})
482 | TriggerEvent("qb-log:server:CreateLog", "glovebox", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
483 | end
484 | else
485 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
486 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="glovebox2", name=fromItemData.name, amount=fromAmount, target=plate})
487 | TriggerEvent("qb-log:server:CreateLog", "glovebox", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
488 | end
489 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
490 | AddToGlovebox(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
491 | elseif QBCore.Shared.SplitStr(toInventory, "-")[1] == "stash" then
492 | local stashId = QBCore.Shared.SplitStr(toInventory, "-")[2]
493 | local toItemData = Stashes[stashId].items[toSlot]
494 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
495 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
496 | --Player.PlayerData.items[toSlot] = fromItemData
497 | if toItemData ~= nil then
498 | --Player.PlayerData.items[fromSlot] = toItemData
499 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
500 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
501 | if toItemData.name ~= fromItemData.name then
502 | RemoveFromStash(stashId, fromSlot, itemInfo["name"], toAmount)
503 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
504 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="stash1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=stashId})
505 | TriggerEvent("qb-log:server:CreateLog", "stash", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - stash: *" .. stashId .. "*")
506 | end
507 | else
508 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
509 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="stash2", name=fromItemData.name, amount=fromAmount, target=stashId})
510 | TriggerEvent("qb-log:server:CreateLog", "stash", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - stash: *" .. stashId .. "*")
511 | end
512 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
513 | AddToStash(stashId, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
514 | elseif QBCore.Shared.SplitStr(toInventory, "-")[1] == "traphouse" then
515 | -- Traphouse
516 | local traphouseId = QBCore.Shared.SplitStr(toInventory, "-")[2]
517 | local toItemData = exports['qb-traphouses']:GetInventoryData(traphouseId, toSlot)
518 | local IsItemValid = exports['qb-traphouses']:CanItemBeSaled(fromItemData.name:lower())
519 | if IsItemValid then
520 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
521 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
522 | if toItemData ~= nil then
523 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
524 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
525 | if toItemData.name ~= fromItemData.name then
526 | exports['qb-traphouses']:RemoveHouseItem(traphouseId, fromSlot, itemInfo["name"], toAmount)
527 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
528 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="traphouse1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=traphouseId})
529 | TriggerEvent("qb-log:server:CreateLog", "traphouse", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - traphouse: *" .. traphouseId .. "*")
530 | end
531 | else
532 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
533 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="traphouse2", name=fromItemData.name, amount=fromAmount, target=traphouseId})
534 | TriggerEvent("qb-log:server:CreateLog", "traphouse", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - traphouse: *" .. traphouseId .. "*")
535 | end
536 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
537 | exports['qb-traphouses']:AddHouseItem(traphouseId, toSlot, itemInfo["name"], fromAmount, fromItemData.info, src)
538 | else
539 | TriggerClientEvent('QBCore:Notify', src, "You can\'t sell this item..", 'error')
540 | end
541 | else
542 | -- drop
543 | toInventory = tonumber(toInventory)
544 | if toInventory == nil or toInventory == 0 then
545 | CreateNewDrop(src, fromSlot, toSlot, fromAmount)
546 | else
547 | local toItemData = Drops[toInventory].items[toSlot]
548 | Player.Functions.RemoveItem(fromItemData.name, fromAmount, fromSlot)
549 | TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
550 | if toItemData ~= nil then
551 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
552 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
553 | if toItemData.name ~= fromItemData.name then
554 | Player.Functions.AddItem(toItemData.name, toAmount, fromSlot, toItemData.info)
555 | RemoveFromDrop(toInventory, fromSlot, itemInfo["name"], toAmount)
556 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="drop1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=toInventory})
557 | TriggerEvent("qb-log:server:CreateLog", "drop", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - dropid: *" .. toInventory .. "*")
558 | end
559 | else
560 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
561 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="drop2", name=fromItemData.name, amount=fromAmount, target=toInventory})
562 | TriggerEvent("qb-log:server:CreateLog", "drop", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - dropid: *" .. toInventory .. "*")
563 | end
564 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
565 | AddToDrop(toInventory, toSlot, itemInfo["name"], fromAmount, fromItemData.info)
566 | if itemInfo["name"] == "radio" then
567 | TriggerClientEvent('qb-radio:onRadioDrop', src)
568 | end
569 | end
570 | end
571 | else
572 | TriggerClientEvent("QBCore:Notify", src, "You doesn\'t have this item!", "error")
573 | end
574 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "otherplayer" then
575 | local playerId = tonumber(QBCore.Shared.SplitStr(fromInventory, "-")[2])
576 | local OtherPlayer = QBCore.Functions.GetPlayer(playerId)
577 | local fromItemData = OtherPlayer.PlayerData.items[fromSlot]
578 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
579 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
580 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
581 | if toInventory == "player" or toInventory == "hotbar" then
582 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
583 | OtherPlayer.Functions.RemoveItem(itemInfo["name"], fromAmount, fromSlot)
584 | TriggerClientEvent("inventory:client:CheckWeapon", OtherPlayer.PlayerData.source, fromItemData.name)
585 | if toItemData ~= nil then
586 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
587 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
588 | if toItemData.name ~= fromItemData.name then
589 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
590 | OtherPlayer.Functions.AddItem(itemInfo["name"], toAmount, fromSlot, toItemData.info)
591 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2citizen1", toName=itemInfo["name"], toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=OtherPlayer.PlayerData.citizenid})
592 | TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** from player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | *"..OtherPlayer.PlayerData.source.."*)")
593 | end
594 | else
595 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2citizen2", name=fromItemData.name, amount=fromAmount, target=OtherPlayer.PlayerData.citizenid})
596 | TriggerEvent("qb-log:server:CreateLog", "robbing", "Retrieved Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) took item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** from player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | *"..OtherPlayer.PlayerData.source.."*)")
597 | end
598 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
599 | else
600 | local toItemData = OtherPlayer.PlayerData.items[toSlot]
601 | OtherPlayer.Functions.RemoveItem(itemInfo["name"], fromAmount, fromSlot)
602 | --Player.PlayerData.items[toSlot] = fromItemData
603 | if toItemData ~= nil then
604 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
605 | --Player.PlayerData.items[fromSlot] = toItemData
606 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
607 | if toItemData.name ~= fromItemData.name then
608 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
609 | OtherPlayer.Functions.RemoveItem(itemInfo["name"], toAmount, toSlot)
610 | OtherPlayer.Functions.AddItem(itemInfo["name"], toAmount, fromSlot, toItemData.info)
611 | end
612 | else
613 | --Player.PlayerData.items[fromSlot] = nil
614 | end
615 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
616 | OtherPlayer.Functions.AddItem(itemInfo["name"], fromAmount, toSlot, fromItemData.info)
617 | end
618 | else
619 | TriggerClientEvent("QBCore:Notify", src, "Item doesn\'t exist??", "error")
620 | end
621 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "trunk" then
622 | local plate = QBCore.Shared.SplitStr(fromInventory, "-")[2]
623 | local fromItemData = Trunks[plate].items[fromSlot]
624 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
625 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
626 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
627 | if toInventory == "player" or toInventory == "hotbar" then
628 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
629 | RemoveFromTrunk(plate, fromSlot, itemInfo["name"], fromAmount)
630 | if toItemData ~= nil then
631 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
632 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
633 | if toItemData.name ~= fromItemData.name then
634 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
635 | AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
636 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2trunk1", toName=itemInfo["name"], toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=plate})
637 | TriggerEvent("qb-log:server:CreateLog", "trunk", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** plate: *" .. plate .. "*")
638 | else
639 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2trunk3", name=toItemData.name, amount=toAmount, target=plate})
640 | TriggerEvent("qb-log:server:CreateLog", "trunk", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from plate: *" .. plate .. "*")
641 | end
642 | else
643 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2trunk2", name=fromItemData.name, amount=fromAmount, target=plate})
644 | TriggerEvent("qb-log:server:CreateLog", "trunk", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) reveived item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** plate: *" .. plate .. "*")
645 | end
646 | SaveOwnedVehicleItems(plate,Trunks[plate].items)
647 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
648 | else
649 | local toItemData = Trunks[plate].items[toSlot]
650 | RemoveFromTrunk(plate, fromSlot, itemInfo["name"], fromAmount)
651 | --Player.PlayerData.items[toSlot] = fromItemData
652 | if toItemData ~= nil then
653 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
654 | --Player.PlayerData.items[fromSlot] = toItemData
655 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
656 | if toItemData.name ~= fromItemData.name then
657 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
658 | RemoveFromTrunk(plate, toSlot, itemInfo["name"], toAmount)
659 | AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
660 | end
661 | else
662 | --Player.PlayerData.items[fromSlot] = nil
663 | end
664 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
665 | AddToTrunk(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
666 | end
667 | else
668 | TriggerClientEvent("QBCore:Notify", src, "Item doesn\'t exist??", "error")
669 | end
670 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "glovebox" then
671 | local plate = QBCore.Shared.SplitStr(fromInventory, "-")[2]
672 | local fromItemData = Gloveboxes[plate].items[fromSlot]
673 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
674 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
675 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
676 | if toInventory == "player" or toInventory == "hotbar" then
677 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
678 | RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], fromAmount)
679 | if toItemData ~= nil then
680 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
681 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
682 | if toItemData.name ~= fromItemData.name then
683 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
684 | AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
685 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2glovebox1", toName=itemInfo["name"], toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=plate})
686 | TriggerEvent("qb-log:server:CreateLog", "glovebox", "Swapped", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src..")* swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** plate: *" .. plate .. "*")
687 | else
688 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2glovebox3", name=toItemData.name, amount=toAmount, target=plate})
689 | TriggerEvent("qb-log:server:CreateLog", "glovebox", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from plate: *" .. plate .. "*")
690 | end
691 | else
692 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2glovebox2", name=fromItemData.name, amount=fromAmount, target=plate})
693 | TriggerEvent("qb-log:server:CreateLog", "glovebox", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) reveived item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** plate: *" .. plate .. "*")
694 | end
695 | SaveOwnedGloveboxItems(plate,Gloveboxes[plate].items)
696 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
697 | else
698 | local toItemData = Gloveboxes[plate].items[toSlot]
699 | RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], fromAmount)
700 | --Player.PlayerData.items[toSlot] = fromItemData
701 | if toItemData ~= nil then
702 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
703 | --Player.PlayerData.items[fromSlot] = toItemData
704 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
705 | if toItemData.name ~= fromItemData.name then
706 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
707 | RemoveFromGlovebox(plate, toSlot, itemInfo["name"], toAmount)
708 | AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
709 | end
710 | else
711 | --Player.PlayerData.items[fromSlot] = nil
712 | end
713 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
714 | AddToGlovebox(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
715 | end
716 | else
717 | TriggerClientEvent("QBCore:Notify", src, "Item doesn\'t exist??", "error")
718 | end
719 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "stash" then
720 | local stashId = QBCore.Shared.SplitStr(fromInventory, "-")[2]
721 | local fromItemData = Stashes[stashId].items[fromSlot]
722 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
723 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
724 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
725 | if toInventory == "player" or toInventory == "hotbar" then
726 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
727 | RemoveFromStash(stashId, fromSlot, itemInfo["name"], fromAmount)
728 | if toItemData ~= nil then
729 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
730 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
731 | if toItemData.name ~= fromItemData.name then
732 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
733 | AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
734 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=stashId})
735 | TriggerEvent("qb-log:server:CreateLog", "stash", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** stash: *" .. stashId .. "*")
736 | else
737 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash3", name=toItemData.name, amount=toAmount, target=stashId})
738 | TriggerEvent("qb-log:server:CreateLog", "stash", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from stash: *" .. stashId .. "*")
739 | end
740 | else
741 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash2", name=fromItemData.name, amount=fromAmount, target=stashId})
742 | TriggerEvent("qb-log:server:CreateLog", "stash", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) reveived item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** stash: *" .. stashId .. "*")
743 | end
744 | SaveStashItems(stashId, Stashes[stashId].items)
745 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
746 | else
747 | local toItemData = Stashes[stashId].items[toSlot]
748 | RemoveFromStash(stashId, fromSlot, itemInfo["name"], fromAmount)
749 | --Player.PlayerData.items[toSlot] = fromItemData
750 | if toItemData ~= nil then
751 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
752 | --Player.PlayerData.items[fromSlot] = toItemData
753 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
754 | if toItemData.name ~= fromItemData.name then
755 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
756 | RemoveFromStash(stashId, toSlot, itemInfo["name"], toAmount)
757 | AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info)
758 | end
759 | else
760 | --Player.PlayerData.items[fromSlot] = nil
761 | end
762 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
763 | AddToStash(stashId, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info)
764 | end
765 | else
766 | TriggerClientEvent("QBCore:Notify", src, "Item doesn\'t exist??", "error")
767 | end
768 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "traphouse" then
769 | local traphouseId = QBCore.Shared.SplitStr(fromInventory, "-")[2]
770 | local fromItemData = exports['qb-traphouses']:GetInventoryData(traphouseId, fromSlot)
771 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
772 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
773 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
774 | if toInventory == "player" or toInventory == "hotbar" then
775 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
776 | exports['qb-traphouses']:RemoveHouseItem(traphouseId, fromSlot, itemInfo["name"], fromAmount)
777 | if toItemData ~= nil then
778 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
779 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
780 | if toItemData.name ~= fromItemData.name then
781 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
782 | exports['qb-traphouses']:AddHouseItem(traphouseId, fromSlot, itemInfo["name"], toAmount, toItemData.info, src)
783 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=traphouseId})
784 | TriggerEvent("qb-log:server:CreateLog", "stash", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** stash: *" .. traphouseId .. "*")
785 | else
786 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash3", name=toItemData.name, amount=toAmount, target=traphouseId})
787 | TriggerEvent("qb-log:server:CreateLog", "stash", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from stash: *" .. traphouseId .. "*")
788 | end
789 | else
790 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2stash2", name=fromItemData.name, amount=fromAmount, target=traphouseId})
791 | TriggerEvent("qb-log:server:CreateLog", "stash", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) reveived item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** stash: *" .. traphouseId .. "*")
792 | end
793 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
794 | else
795 | local toItemData = exports['qb-traphouses']:GetInventoryData(traphouseId, toSlot)
796 | exports['qb-traphouses']:RemoveHouseItem(traphouseId, fromSlot, itemInfo["name"], fromAmount)
797 | if toItemData ~= nil then
798 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
799 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
800 | if toItemData.name ~= fromItemData.name then
801 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
802 | exports['qb-traphouses']:RemoveHouseItem(traphouseId, toSlot, itemInfo["name"], toAmount)
803 | exports['qb-traphouses']:AddHouseItem(traphouseId, fromSlot, itemInfo["name"], toAmount, toItemData.info, src)
804 | end
805 | end
806 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
807 | exports['qb-traphouses']:AddHouseItem(traphouseId, toSlot, itemInfo["name"], fromAmount, fromItemData.info, src)
808 | end
809 | else
810 | TriggerClientEvent("QBCore:Notify", src, "Item doesn't exist??", "error")
811 | end
812 | elseif QBCore.Shared.SplitStr(fromInventory, "-")[1] == "itemshop" then
813 | local shopType = QBCore.Shared.SplitStr(fromInventory, "-")[2]
814 | local itemData = ShopItems[shopType].items[fromSlot]
815 | local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
816 | local bankBalance = Player.PlayerData.money["bank"]
817 | local price = tonumber((itemData.price*fromAmount))
818 |
819 | if QBCore.Shared.SplitStr(shopType, "_")[1] == "Dealer" then
820 | if QBCore.Shared.SplitStr(itemData.name, "_")[1] == "weapon" then
821 | price = tonumber(itemData.price)
822 | if Player.Functions.RemoveMoney("cash", price, "dealer-item-bought") then
823 | itemData.info.serie = tostring(Config.RandomInt(2) .. Config.RandomStr(3) .. Config.RandomInt(1) .. Config.RandomStr(2) .. Config.RandomInt(3) .. Config.RandomStr(4))
824 | Player.Functions.AddItem(itemData.name, 1, toSlot, itemData.info)
825 | TriggerClientEvent('qb-drugs:client:updateDealerItems', src, itemData, 1)
826 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " bought!", "success")
827 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="dealer", name=itemInfo["name"], amount=1, paymentType="cash", price=price})
828 | TriggerEvent("qb-log:server:CreateLog", "dealers", "Dealer item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
829 | else
830 | TriggerClientEvent('QBCore:Notify', src, "You don\'t have enough cash..", "error")
831 | end
832 | else
833 | if Player.Functions.RemoveMoney("cash", price, "dealer-item-bought") then
834 | Player.Functions.AddItem(itemData.name, fromAmount, toSlot, itemData.info)
835 | TriggerClientEvent('qb-drugs:client:updateDealerItems', src, itemData, fromAmount)
836 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " ingekocht!", "success")
837 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="dealer", name=itemInfo["name"], amount=fromAmount, paymentType="cash", price=price})
838 | TriggerEvent("qb-log:server:CreateLog", "dealers", "Dealer item gekocht", "green", "**"..GetPlayerName(src) .. "** heeft een " .. itemInfo["label"] .. " bought for $"..price)
839 | else
840 | TriggerClientEvent('QBCore:Notify', src, "You don't have enough cash..", "error")
841 | end
842 | end
843 | elseif QBCore.Shared.SplitStr(shopType, "_")[1] == "Itemshop" then
844 | if Player.Functions.RemoveMoney("cash", price, "itemshop-bought-item") then
845 | Player.Functions.AddItem(itemData.name, fromAmount, toSlot, itemData.info)
846 | TriggerClientEvent('qb-shops:client:UpdateShop', src, QBCore.Shared.SplitStr(shopType, "_")[2], itemData, fromAmount)
847 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " bought!", "success")
848 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="itemshop", name=itemInfo["name"], amount=fromAmount, paymentType="cash", price=price})
849 | TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
850 | elseif bankBalance >= price then
851 | Player.Functions.RemoveMoney("bank", price, "itemshop-bought-item")
852 | Player.Functions.AddItem(itemData.name, fromAmount, toSlot, itemData.info)
853 | TriggerClientEvent('qb-shops:client:UpdateShop', src, QBCore.Shared.SplitStr(shopType, "_")[2], itemData, fromAmount)
854 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " bought!", "success")
855 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="itemshop", name=itemInfo["name"], amount=fromAmount, paymentType="bank", price=price})
856 | TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
857 | else
858 | TriggerClientEvent('QBCore:Notify', src, "You don't have enough cash..", "error")
859 | end
860 | else
861 | if Player.Functions.RemoveMoney("cash", price, "unkown-itemshop-bought-item") then
862 | Player.Functions.AddItem(itemData.name, fromAmount, toSlot, itemData.info)
863 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " bought!", "success")
864 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="other", name=itemInfo["name"], amount=fromAmount, paymentType="cash", price=price})
865 | TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
866 | elseif bankBalance >= price then
867 | Player.Functions.RemoveMoney("bank", price, "unkown-itemshop-bought-item")
868 | Player.Functions.AddItem(itemData.name, fromAmount, toSlot, itemData.info)
869 | TriggerClientEvent('QBCore:Notify', src, itemInfo["label"] .. " bought!", "success")
870 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemshop", {type="other", name=itemInfo["name"], amount=fromAmount, paymentType="bank", price=price})
871 | TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
872 | else
873 | TriggerClientEvent('QBCore:Notify', src, "You don\'t have enough cash..", "error")
874 | end
875 | end
876 | elseif fromInventory == "crafting" then
877 | local itemData = Config.CraftingItems[fromSlot]
878 | if hasCraftItems(src, itemData.costs, fromAmount) then
879 | TriggerClientEvent("inventory:client:CraftItems", src, itemData.name, itemData.costs, fromAmount, toSlot, itemData.points)
880 | else
881 | TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, true)
882 | TriggerClientEvent('QBCore:Notify', src, "You don't have the right items..", "error")
883 | end
884 | elseif fromInventory == "attachment_crafting" then
885 | local itemData = Config.AttachmentCrafting["items"][fromSlot]
886 | if hasCraftItems(src, itemData.costs, fromAmount) then
887 | TriggerClientEvent("inventory:client:CraftAttachment", src, itemData.name, itemData.costs, fromAmount, toSlot, itemData.points)
888 | else
889 | TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, true)
890 | TriggerClientEvent('QBCore:Notify', src, "You don't have the right items..", "error")
891 | end
892 | else
893 | -- drop
894 | fromInventory = tonumber(fromInventory)
895 | local fromItemData = Drops[fromInventory].items[fromSlot]
896 | local fromAmount = tonumber(fromAmount) ~= nil and tonumber(fromAmount) or fromItemData.amount
897 | if fromItemData ~= nil and fromItemData.amount >= fromAmount then
898 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
899 | if toInventory == "player" or toInventory == "hotbar" then
900 | local toItemData = Player.Functions.GetItemBySlot(toSlot)
901 | RemoveFromDrop(fromInventory, fromSlot, itemInfo["name"], fromAmount)
902 | if toItemData ~= nil then
903 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
904 | if toItemData.name ~= fromItemData.name then
905 | Player.Functions.RemoveItem(toItemData.name, toAmount, toSlot)
906 | AddToDrop(fromInventory, toSlot, itemInfo["name"], toAmount, toItemData.info)
907 | if itemInfo["name"] == "radio" then
908 | TriggerClientEvent('qb-radio:onRadioDrop', src)
909 | end
910 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2drop1", toName=toItemData.name, toAmount=toAmount, fromName=fromItemData.name, fromAmount=fromAmount, target=fromInventory})
911 | TriggerEvent("qb-log:server:CreateLog", "drop", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** - dropid: *" .. fromInventory .. "*")
912 | else
913 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2drop3", name=toItemData.name, amount=toAmount, target=fromInventory})
914 | TriggerEvent("qb-log:server:CreateLog", "drop", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** - from dropid: *" .. fromInventory .. "*")
915 | end
916 | else
917 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="2drop2", name=fromItemData.name, amount=fromAmount, target=fromInventory})
918 | TriggerEvent("qb-log:server:CreateLog", "drop", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) reveived item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** - dropid: *" .. fromInventory .. "*")
919 | end
920 | Player.Functions.AddItem(fromItemData.name, fromAmount, toSlot, fromItemData.info)
921 | else
922 | toInventory = tonumber(toInventory)
923 | local toItemData = Drops[toInventory].items[toSlot]
924 | RemoveFromDrop(fromInventory, fromSlot, itemInfo["name"], fromAmount)
925 | --Player.PlayerData.items[toSlot] = fromItemData
926 | if toItemData ~= nil then
927 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
928 | --Player.PlayerData.items[fromSlot] = toItemData
929 | local toAmount = tonumber(toAmount) ~= nil and tonumber(toAmount) or toItemData.amount
930 | if toItemData.name ~= fromItemData.name then
931 | local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
932 | RemoveFromDrop(toInventory, toSlot, itemInfo["name"], toAmount)
933 | AddToDrop(fromInventory, fromSlot, itemInfo["name"], toAmount, toItemData.info)
934 | if itemInfo["name"] == "radio" then
935 | TriggerClientEvent('qb-radio:onRadioDrop', src)
936 | end
937 | end
938 | else
939 | --Player.PlayerData.items[fromSlot] = nil
940 | end
941 | local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
942 | AddToDrop(toInventory, toSlot, itemInfo["name"], fromAmount, fromItemData.info)
943 | if itemInfo["name"] == "radio" then
944 | TriggerClientEvent('qb-radio:onRadioDrop', src)
945 | end
946 | end
947 | else
948 | TriggerClientEvent("QBCore:Notify", src, "Item doesn't exist??", "error")
949 | end
950 | end
951 | end)
952 |
953 | function hasCraftItems(source, CostItems, amount)
954 | local Player = QBCore.Functions.GetPlayer(source)
955 | for k, v in pairs(CostItems) do
956 | if Player.Functions.GetItemByName(k) ~= nil then
957 | if Player.Functions.GetItemByName(k).amount < (v * amount) then
958 | return false
959 | end
960 | else
961 | return false
962 | end
963 | end
964 | return true
965 | end
966 |
967 | function IsVehicleOwned(plate)
968 | local val = false
969 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `player_vehicles` WHERE `plate` = '"..plate.."'", function(result)
970 | if (result[1] ~= nil) then
971 | val = true
972 | else
973 | val = false
974 | end
975 | end)
976 | return val
977 | end
978 |
979 | local function escape_str(s)
980 | local in_char = {'\\', '"', '/', '\b', '\f', '\n', '\r', '\t'}
981 | local out_char = {'\\', '"', '/', 'b', 'f', 'n', 'r', 't'}
982 | for i, c in ipairs(in_char) do
983 | s = s:gsub(c, '\\' .. out_char[i])
984 | end
985 | return s
986 | end
987 |
988 | -- Shop Items
989 | function SetupShopItems(shop, shopItems)
990 | local items = {}
991 | if shopItems ~= nil and next(shopItems) ~= nil then
992 | for k, item in pairs(shopItems) do
993 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
994 | items[item.slot] = {
995 | name = itemInfo["name"],
996 | amount = tonumber(item.amount),
997 | info = item.info ~= nil and item.info or "",
998 | label = itemInfo["label"],
999 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1000 | weight = itemInfo["weight"],
1001 | type = itemInfo["type"],
1002 | unique = itemInfo["unique"],
1003 | useable = itemInfo["useable"],
1004 | price = item.price,
1005 | image = itemInfo["image"],
1006 | slot = item.slot,
1007 | }
1008 | end
1009 | end
1010 | return items
1011 | end
1012 |
1013 | -- Stash Items
1014 | function GetStashItems(stashId)
1015 | local items = {}
1016 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `stashitems` WHERE `stash` = '"..stashId.."'", function(result)
1017 | if result[1] ~= nil then
1018 | for k, item in pairs(result) do
1019 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1020 | items[item.slot] = {
1021 | name = itemInfo["name"],
1022 | amount = tonumber(item.amount),
1023 | info = json.decode(item.info) ~= nil and json.decode(item.info) or "",
1024 | label = itemInfo["label"],
1025 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1026 | weight = itemInfo["weight"],
1027 | type = itemInfo["type"],
1028 | unique = itemInfo["unique"],
1029 | useable = itemInfo["useable"],
1030 | image = itemInfo["image"],
1031 | slot = item.slot,
1032 | }
1033 | end
1034 | QBCore.Functions.ExecuteSql(false, "DELETE FROM `stashitems` WHERE `stash` = '"..stashId.."'")
1035 | else
1036 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `stashitemsnew` WHERE `stash` = '"..stashId.."'", function(result)
1037 | if result[1] ~= nil then
1038 | if result[1].items ~= nil then
1039 | result[1].items = json.decode(result[1].items)
1040 | if result[1].items ~= nil then
1041 | for k, item in pairs(result[1].items) do
1042 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1043 | items[item.slot] = {
1044 | name = itemInfo["name"],
1045 | amount = tonumber(item.amount),
1046 | info = item.info ~= nil and item.info or "",
1047 | label = itemInfo["label"],
1048 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1049 | weight = itemInfo["weight"],
1050 | type = itemInfo["type"],
1051 | unique = itemInfo["unique"],
1052 | useable = itemInfo["useable"],
1053 | image = itemInfo["image"],
1054 | slot = item.slot,
1055 | }
1056 | end
1057 | end
1058 | end
1059 | end
1060 | end)
1061 | end
1062 | end)
1063 | return items
1064 | end
1065 |
1066 | QBCore.Functions.CreateCallback('qb-inventory:server:GetStashItems', function(source, cb, stashId)
1067 | cb(GetStashItems(stashId))
1068 | end)
1069 |
1070 | RegisterServerEvent('qb-inventory:server:SaveStashItems')
1071 | AddEventHandler('qb-inventory:server:SaveStashItems', function(stashId, items)
1072 | local opti = {}
1073 | for slot, item in pairs(items) do
1074 | table.insert(opti, {
1075 | name = item.name,
1076 | amount = item.amount,
1077 | info = item.info,
1078 | type = item.type,
1079 | slot = item.slot,
1080 | })
1081 | end
1082 | Wait(200)
1083 | local items = opti
1084 | QBCore.Functions.ExecuteSql(false, "SELECT * FROM `stashitemsnew` WHERE `stash` = '"..stashId.."'", function(result)
1085 | if result[1] ~= nil then
1086 | QBCore.Functions.ExecuteSql(false, "UPDATE `stashitemsnew` SET `items` = '"..json.encode(items).."' WHERE `stash` = '"..stashId.."'")
1087 | else
1088 | QBCore.Functions.ExecuteSql(false, "INSERT INTO `stashitemsnew` (`stash`, `items`) VALUES ('"..stashId.."', '"..json.encode(items).."')")
1089 | end
1090 | end)
1091 | end)
1092 |
1093 | function SaveStashItems(stashId, items)
1094 | local opti = {}
1095 | if Stashes[stashId].label ~= "Stash-None" then
1096 | if items ~= nil then
1097 | for slot, item in pairs(items) do
1098 | table.insert(opti, {
1099 | name = item.name,
1100 | amount = item.amount,
1101 | info = item.info,
1102 | type = item.type,
1103 | slot = item.slot,
1104 | })
1105 | end
1106 | local items = opti
1107 | QBCore.Functions.ExecuteSql(false, "SELECT * FROM `stashitemsnew` WHERE `stash` = '"..stashId.."'", function(result)
1108 | if result[1] ~= nil then
1109 | QBCore.Functions.ExecuteSql(false, "UPDATE `stashitemsnew` SET `items` = '"..json.encode(items).."' WHERE `stash` = '"..stashId.."'")
1110 | Stashes[stashId].isOpen = false
1111 | else
1112 | QBCore.Functions.ExecuteSql(false, "INSERT INTO `stashitemsnew` (`stash`, `items`) VALUES ('"..stashId.."', '"..json.encode(items).."')")
1113 | Stashes[stashId].isOpen = false
1114 | end
1115 | end)
1116 | end
1117 | end
1118 | end
1119 |
1120 | function AddToStash(stashId, slot, otherslot, itemName, amount, info)
1121 | local amount = tonumber(amount)
1122 | local ItemData = QBCore.Shared.Items[itemName]
1123 | if not ItemData.unique then
1124 | if Stashes[stashId].items[slot] ~= nil and Stashes[stashId].items[slot].name == itemName then
1125 | Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount + amount
1126 | else
1127 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1128 | Stashes[stashId].items[slot] = {
1129 | name = itemInfo["name"],
1130 | amount = amount,
1131 | info = info ~= nil and info or "",
1132 | label = itemInfo["label"],
1133 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1134 | weight = itemInfo["weight"],
1135 | type = itemInfo["type"],
1136 | unique = itemInfo["unique"],
1137 | useable = itemInfo["useable"],
1138 | image = itemInfo["image"],
1139 | slot = slot,
1140 | }
1141 | end
1142 | else
1143 | if Stashes[stashId].items[slot] ~= nil and Stashes[stashId].items[slot].name == itemName then
1144 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1145 | Stashes[stashId].items[otherslot] = {
1146 | name = itemInfo["name"],
1147 | amount = amount,
1148 | info = info ~= nil and info or "",
1149 | label = itemInfo["label"],
1150 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1151 | weight = itemInfo["weight"],
1152 | type = itemInfo["type"],
1153 | unique = itemInfo["unique"],
1154 | useable = itemInfo["useable"],
1155 | image = itemInfo["image"],
1156 | slot = otherslot,
1157 | }
1158 | else
1159 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1160 | Stashes[stashId].items[slot] = {
1161 | name = itemInfo["name"],
1162 | amount = amount,
1163 | info = info ~= nil and info or "",
1164 | label = itemInfo["label"],
1165 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1166 | weight = itemInfo["weight"],
1167 | type = itemInfo["type"],
1168 | unique = itemInfo["unique"],
1169 | useable = itemInfo["useable"],
1170 | image = itemInfo["image"],
1171 | slot = slot,
1172 | }
1173 | end
1174 | end
1175 | end
1176 |
1177 | function RemoveFromStash(stashId, slot, itemName, amount)
1178 | local amount = tonumber(amount)
1179 | if Stashes[stashId].items[slot] ~= nil and Stashes[stashId].items[slot].name == itemName then
1180 | if Stashes[stashId].items[slot].amount > amount then
1181 | Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount - amount
1182 | else
1183 | Stashes[stashId].items[slot] = nil
1184 | if next(Stashes[stashId].items) == nil then
1185 | Stashes[stashId].items = {}
1186 | end
1187 | end
1188 | else
1189 | Stashes[stashId].items[slot] = nil
1190 | if Stashes[stashId].items == nil then
1191 | Stashes[stashId].items[slot] = nil
1192 | end
1193 | end
1194 | end
1195 |
1196 | -- Trunk items
1197 | function GetOwnedVehicleItems(plate)
1198 | local items = {}
1199 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `trunkitems` WHERE `plate` = '"..plate.."'", function(result)
1200 | if result[1] ~= nil then
1201 | for k, item in pairs(result) do
1202 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1203 | items[item.slot] = {
1204 | name = itemInfo["name"],
1205 | amount = tonumber(item.amount),
1206 | info = json.decode(item.info) ~= nil and json.decode(item.info) or "",
1207 | label = itemInfo["label"],
1208 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1209 | weight = itemInfo["weight"],
1210 | type = itemInfo["type"],
1211 | unique = itemInfo["unique"],
1212 | useable = itemInfo["useable"],
1213 | image = itemInfo["image"],
1214 | slot = item.slot,
1215 | }
1216 | end
1217 | QBCore.Functions.ExecuteSql(false, "DELETE FROM `trunkitems` WHERE `plate` = '"..plate.."'")
1218 | else
1219 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `trunkitemsnew` WHERE `plate` = '"..plate.."'", function(result)
1220 | if result[1] ~= nil then
1221 | if result[1].items ~= nil then
1222 | result[1].items = json.decode(result[1].items)
1223 | if result[1].items ~= nil then
1224 | for k, item in pairs(result[1].items) do
1225 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1226 | items[item.slot] = {
1227 | name = itemInfo["name"],
1228 | amount = tonumber(item.amount),
1229 | info = item.info ~= nil and item.info or "",
1230 | label = itemInfo["label"],
1231 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1232 | weight = itemInfo["weight"],
1233 | type = itemInfo["type"],
1234 | unique = itemInfo["unique"],
1235 | useable = itemInfo["useable"],
1236 | image = itemInfo["image"],
1237 | slot = item.slot,
1238 | }
1239 | end
1240 | end
1241 | end
1242 | end
1243 | end)
1244 | end
1245 | end)
1246 | return items
1247 | end
1248 |
1249 | function SaveOwnedVehicleItems(plate, items)
1250 | local opti = {}
1251 | if Trunks[plate].label ~= "Trunk-None" then
1252 | if items ~= nil then
1253 | for slot, item in pairs(items) do
1254 | table.insert(opti, {
1255 | name = item.name,
1256 | amount = item.amount,
1257 | info = item.info,
1258 | type = item.type,
1259 | slot = item.slot,
1260 | })
1261 | end
1262 | local items = opti
1263 | QBCore.Functions.ExecuteSql(false, "SELECT * FROM `trunkitemsnew` WHERE `plate` = '"..plate.."'", function(result)
1264 | if result[1] ~= nil then
1265 | QBCore.Functions.ExecuteSql(false, "UPDATE `trunkitemsnew` SET `items` = '"..json.encode(items).."' WHERE `plate` = '"..plate.."'", function(result)
1266 | Trunks[plate].isOpen = false
1267 | end)
1268 | else
1269 | QBCore.Functions.ExecuteSql(false, "INSERT INTO `trunkitemsnew` (`plate`, `items`) VALUES ('"..plate.."', '"..json.encode(items).."')", function(result)
1270 | Trunks[plate].isOpen = false
1271 | end)
1272 | end
1273 | end)
1274 | end
1275 | end
1276 | end
1277 |
1278 | function AddToTrunk(plate, slot, otherslot, itemName, amount, info)
1279 | local amount = tonumber(amount)
1280 | local ItemData = QBCore.Shared.Items[itemName]
1281 |
1282 | if not ItemData.unique then
1283 | if Trunks[plate].items[slot] ~= nil and Trunks[plate].items[slot].name == itemName then
1284 | Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount + amount
1285 | else
1286 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1287 | Trunks[plate].items[slot] = {
1288 | name = itemInfo["name"],
1289 | amount = amount,
1290 | info = info ~= nil and info or "",
1291 | label = itemInfo["label"],
1292 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1293 | weight = itemInfo["weight"],
1294 | type = itemInfo["type"],
1295 | unique = itemInfo["unique"],
1296 | useable = itemInfo["useable"],
1297 | image = itemInfo["image"],
1298 | slot = slot,
1299 | }
1300 | end
1301 | else
1302 | if Trunks[plate].items[slot] ~= nil and Trunks[plate].items[slot].name == itemName then
1303 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1304 | Trunks[plate].items[otherslot] = {
1305 | name = itemInfo["name"],
1306 | amount = amount,
1307 | info = info ~= nil and info or "",
1308 | label = itemInfo["label"],
1309 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1310 | weight = itemInfo["weight"],
1311 | type = itemInfo["type"],
1312 | unique = itemInfo["unique"],
1313 | useable = itemInfo["useable"],
1314 | image = itemInfo["image"],
1315 | slot = otherslot,
1316 | }
1317 | else
1318 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1319 | Trunks[plate].items[slot] = {
1320 | name = itemInfo["name"],
1321 | amount = amount,
1322 | info = info ~= nil and info or "",
1323 | label = itemInfo["label"],
1324 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1325 | weight = itemInfo["weight"],
1326 | type = itemInfo["type"],
1327 | unique = itemInfo["unique"],
1328 | useable = itemInfo["useable"],
1329 | image = itemInfo["image"],
1330 | slot = slot,
1331 | }
1332 | end
1333 | end
1334 | end
1335 |
1336 | function RemoveFromTrunk(plate, slot, itemName, amount)
1337 | if Trunks[plate].items[slot] ~= nil and Trunks[plate].items[slot].name == itemName then
1338 | if Trunks[plate].items[slot].amount > amount then
1339 | Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount - amount
1340 | else
1341 | Trunks[plate].items[slot] = nil
1342 | if next(Trunks[plate].items) == nil then
1343 | Trunks[plate].items = {}
1344 | end
1345 | end
1346 | else
1347 | Trunks[plate].items[slot]= nil
1348 | if Trunks[plate].items == nil then
1349 | Trunks[plate].items[slot] = nil
1350 | end
1351 | end
1352 | end
1353 |
1354 | -- Glovebox items
1355 | function GetOwnedVehicleGloveboxItems(plate)
1356 | local items = {}
1357 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `gloveboxitems` WHERE `plate` = '"..plate.."'", function(result)
1358 | if result[1] ~= nil then
1359 | for k, item in pairs(result) do
1360 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1361 | items[item.slot] = {
1362 | name = itemInfo["name"],
1363 | amount = tonumber(item.amount),
1364 | info = json.decode(item.info) ~= nil and json.decode(item.info) or "",
1365 | label = itemInfo["label"],
1366 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1367 | weight = itemInfo["weight"],
1368 | type = itemInfo["type"],
1369 | unique = itemInfo["unique"],
1370 | useable = itemInfo["useable"],
1371 | image = itemInfo["image"],
1372 | slot = item.slot,
1373 | }
1374 | end
1375 | QBCore.Functions.ExecuteSql(false, "DELETE FROM `gloveboxitems` WHERE `plate` = '"..plate.."'")
1376 | else
1377 | QBCore.Functions.ExecuteSql(true, "SELECT * FROM `gloveboxitemsnew` WHERE `plate` = '"..plate.."'", function(result)
1378 | if result[1] ~= nil then
1379 | if result[1].items ~= nil then
1380 | result[1].items = json.decode(result[1].items)
1381 | if result[1].items ~= nil then
1382 | for k, item in pairs(result[1].items) do
1383 | local itemInfo = QBCore.Shared.Items[item.name:lower()]
1384 | items[item.slot] = {
1385 | name = itemInfo["name"],
1386 | amount = tonumber(item.amount),
1387 | info = item.info ~= nil and item.info or "",
1388 | label = itemInfo["label"],
1389 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1390 | weight = itemInfo["weight"],
1391 | type = itemInfo["type"],
1392 | unique = itemInfo["unique"],
1393 | useable = itemInfo["useable"],
1394 | image = itemInfo["image"],
1395 | slot = item.slot,
1396 | }
1397 | end
1398 | end
1399 | end
1400 | end
1401 | end)
1402 | end
1403 | end)
1404 | return items
1405 | end
1406 |
1407 | function SaveOwnedGloveboxItems(plate, items)
1408 | local opti = {}
1409 | if Gloveboxes[plate].label ~= "Glovebox-None" then
1410 | if items ~= nil then
1411 | for slot, item in pairs(items) do
1412 | table.insert(opti, {
1413 | name = item.name,
1414 | amount = item.amount,
1415 | info = item.info,
1416 | type = item.type,
1417 | slot = item.slot,
1418 | })
1419 | end
1420 | local items = opti
1421 | QBCore.Functions.ExecuteSql(false, "SELECT * FROM `gloveboxitemsnew` WHERE `plate` = '"..plate.."'", function(result)
1422 | if result[1] ~= nil then
1423 | QBCore.Functions.ExecuteSql(false, "UPDATE `gloveboxitemsnew` SET `items` = '"..json.encode(items).."' WHERE `plate` = '"..plate.."'", function(result)
1424 | Gloveboxes[plate].isOpen = false
1425 | end)
1426 | else
1427 | QBCore.Functions.ExecuteSql(false, "INSERT INTO `gloveboxitemsnew` (`plate`, `items`) VALUES ('"..plate.."', '"..json.encode(items).."')", function(result)
1428 | Gloveboxes[plate].isOpen = false
1429 | end)
1430 | end
1431 | end)
1432 | end
1433 | end
1434 | end
1435 |
1436 | function AddToGlovebox(plate, slot, otherslot, itemName, amount, info)
1437 | local amount = tonumber(amount)
1438 | local ItemData = QBCore.Shared.Items[itemName]
1439 |
1440 | if not ItemData.unique then
1441 | if Gloveboxes[plate].items[slot] ~= nil and Gloveboxes[plate].items[slot].name == itemName then
1442 | Gloveboxes[plate].items[slot].amount = Gloveboxes[plate].items[slot].amount + amount
1443 | else
1444 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1445 | Gloveboxes[plate].items[slot] = {
1446 | name = itemInfo["name"],
1447 | amount = amount,
1448 | info = info ~= nil and info or "",
1449 | label = itemInfo["label"],
1450 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1451 | weight = itemInfo["weight"],
1452 | type = itemInfo["type"],
1453 | unique = itemInfo["unique"],
1454 | useable = itemInfo["useable"],
1455 | image = itemInfo["image"],
1456 | slot = slot,
1457 | }
1458 | end
1459 | else
1460 | if Gloveboxes[plate].items[slot] ~= nil and Gloveboxes[plate].items[slot].name == itemName then
1461 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1462 | Gloveboxes[plate].items[otherslot] = {
1463 | name = itemInfo["name"],
1464 | amount = amount,
1465 | info = info ~= nil and info or "",
1466 | label = itemInfo["label"],
1467 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1468 | weight = itemInfo["weight"],
1469 | type = itemInfo["type"],
1470 | unique = itemInfo["unique"],
1471 | useable = itemInfo["useable"],
1472 | image = itemInfo["image"],
1473 | slot = otherslot,
1474 | }
1475 | else
1476 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1477 | Gloveboxes[plate].items[slot] = {
1478 | name = itemInfo["name"],
1479 | amount = amount,
1480 | info = info ~= nil and info or "",
1481 | label = itemInfo["label"],
1482 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1483 | weight = itemInfo["weight"],
1484 | type = itemInfo["type"],
1485 | unique = itemInfo["unique"],
1486 | useable = itemInfo["useable"],
1487 | image = itemInfo["image"],
1488 | slot = slot,
1489 | }
1490 | end
1491 | end
1492 | end
1493 |
1494 | function RemoveFromGlovebox(plate, slot, itemName, amount)
1495 | if Gloveboxes[plate].items[slot] ~= nil and Gloveboxes[plate].items[slot].name == itemName then
1496 | if Gloveboxes[plate].items[slot].amount > amount then
1497 | Gloveboxes[plate].items[slot].amount = Gloveboxes[plate].items[slot].amount - amount
1498 | else
1499 | Gloveboxes[plate].items[slot] = nil
1500 | if next(Gloveboxes[plate].items) == nil then
1501 | Gloveboxes[plate].items = {}
1502 | end
1503 | end
1504 | else
1505 | Gloveboxes[plate].items[slot]= nil
1506 | if Gloveboxes[plate].items == nil then
1507 | Gloveboxes[plate].items[slot] = nil
1508 | end
1509 | end
1510 | end
1511 |
1512 | -- Drop items
1513 | function AddToDrop(dropId, slot, itemName, amount, info)
1514 | local amount = tonumber(amount)
1515 | if Drops[dropId].items[slot] ~= nil and Drops[dropId].items[slot].name == itemName then
1516 | Drops[dropId].items[slot].amount = Drops[dropId].items[slot].amount + amount
1517 | else
1518 | local itemInfo = QBCore.Shared.Items[itemName:lower()]
1519 | Drops[dropId].items[slot] = {
1520 | name = itemInfo["name"],
1521 | amount = amount,
1522 | info = info ~= nil and info or "",
1523 | label = itemInfo["label"],
1524 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1525 | weight = itemInfo["weight"],
1526 | type = itemInfo["type"],
1527 | unique = itemInfo["unique"],
1528 | useable = itemInfo["useable"],
1529 | image = itemInfo["image"],
1530 | slot = slot,
1531 | id = dropId,
1532 | }
1533 | end
1534 | end
1535 |
1536 | function RemoveFromDrop(dropId, slot, itemName, amount)
1537 | if Drops[dropId].items[slot] ~= nil and Drops[dropId].items[slot].name == itemName then
1538 | if Drops[dropId].items[slot].amount > amount then
1539 | Drops[dropId].items[slot].amount = Drops[dropId].items[slot].amount - amount
1540 | else
1541 | Drops[dropId].items[slot] = nil
1542 | if next(Drops[dropId].items) == nil then
1543 | Drops[dropId].items = {}
1544 | --TriggerClientEvent("inventory:client:RemoveDropItem", -1, dropId)
1545 | end
1546 | end
1547 | else
1548 | Drops[dropId].items[slot] = nil
1549 | if Drops[dropId].items == nil then
1550 | Drops[dropId].items[slot] = nil
1551 | --TriggerClientEvent("inventory:client:RemoveDropItem", -1, dropId)
1552 | end
1553 | end
1554 | end
1555 |
1556 | function CreateDropId()
1557 | if Drops ~= nil then
1558 | local id = math.random(10000, 99999)
1559 | local dropid = id
1560 | while Drops[dropid] ~= nil do
1561 | id = math.random(10000, 99999)
1562 | dropid = id
1563 | end
1564 | return dropid
1565 | else
1566 | local id = math.random(10000, 99999)
1567 | local dropid = id
1568 | return dropid
1569 | end
1570 | end
1571 |
1572 | function CreateNewDrop(source, fromSlot, toSlot, itemAmount)
1573 | local Player = QBCore.Functions.GetPlayer(source)
1574 | local itemData = Player.Functions.GetItemBySlot(fromSlot)
1575 | if Player.Functions.RemoveItem(itemData.name, itemAmount, itemData.slot) then
1576 | TriggerClientEvent("inventory:client:CheckWeapon", source, itemData.name)
1577 | local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
1578 | local dropId = CreateDropId()
1579 | Drops[dropId] = {}
1580 | Drops[dropId].items = {}
1581 |
1582 | Drops[dropId].items[toSlot] = {
1583 | name = itemInfo["name"],
1584 | amount = itemAmount,
1585 | info = itemData.info ~= nil and itemData.info or "",
1586 | label = itemInfo["label"],
1587 | description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
1588 | weight = itemInfo["weight"],
1589 | type = itemInfo["type"],
1590 | unique = itemInfo["unique"],
1591 | useable = itemInfo["useable"],
1592 | image = itemInfo["image"],
1593 | slot = toSlot,
1594 | id = dropId,
1595 | }
1596 | TriggerEvent("qb-log:server:sendLog", Player.PlayerData.citizenid, "itemswapped", {type="3drop", name=itemData.name, amount=itemAmount})
1597 | TriggerEvent("qb-log:server:CreateLog", "drop", "New Item Drop", "red", "**".. GetPlayerName(source) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..source.."*) dropped new item; name: **"..itemData.name.."**, amount: **" .. itemAmount .. "**")
1598 | TriggerClientEvent("inventory:client:DropItemAnim", source)
1599 | TriggerClientEvent("inventory:client:AddDropItem", -1, dropId, source)
1600 | if itemData.name:lower() == "radio" then
1601 | TriggerClientEvent('qb-radio:onRadioDrop', source)
1602 | end
1603 | else
1604 | TriggerClientEvent("QBCore:Notify", src, "You don't have this item!", "error")
1605 | return
1606 | end
1607 | end
1608 |
1609 | QBCore.Commands.Add("inv", "Open your inventory", {}, false, function(source, args)
1610 | local Player = QBCore.Functions.GetPlayer(source)
1611 | TriggerClientEvent("inventory:client:OpenInventory", source, Player.PlayerData.items)
1612 | end)
1613 |
1614 | QBCore.Commands.Add("resetinv", "Reset inventory (in case of -None)", {{name="type", help="stash/trunk/glovebox"},{name="id/plate", help="ID of stash or license plate"}}, true, function(source, args)
1615 | local invType = args[1]:lower()
1616 | table.remove(args, 1)
1617 | local invId = table.concat(args, " ")
1618 | if invType ~= nil and invId ~= nil then
1619 | if invType == "trunk" then
1620 | if Trunks[invId] ~= nil then
1621 | Trunks[invId].isOpen = false
1622 | end
1623 | elseif invType == "glovebox" then
1624 | if Gloveboxes[invId] ~= nil then
1625 | Gloveboxes[invId].isOpen = false
1626 | end
1627 | elseif invType == "stash" then
1628 | if Stashes[invId] ~= nil then
1629 | Stashes[invId].isOpen = false
1630 | end
1631 | else
1632 | TriggerClientEvent('QBCore:Notify', source, "Not a valid type..", "error")
1633 | end
1634 | else
1635 | TriggerClientEvent('QBCore:Notify', source, "Argumenten not filled out correctly..", "error")
1636 | end
1637 | end, "admin")
1638 |
1639 | -- QBCore.Commands.Add("setnui", "Zet nui aan/ui (0/1)", {}, true, function(source, args)
1640 | -- if tonumber(args[1]) == 1 then
1641 | -- TriggerClientEvent("inventory:client:EnableNui", src)
1642 | -- else
1643 | -- TriggerClientEvent("inventory:client:DisableNui", src)
1644 | -- end
1645 | -- end)
1646 |
1647 | QBCore.Commands.Add("trunkpos", "Shows trunk position", {}, false, function(source, args)
1648 | TriggerClientEvent("inventory:client:ShowTrunkPos", source)
1649 | end)
1650 |
1651 | QBCore.Commands.Add("steal", "Rob a player", {}, false, function(source, args)
1652 | TriggerClientEvent("police:client:RobPlayer", source)
1653 | end)
1654 |
1655 | QBCore.Commands.Add("giveitem", "Give item to a player", {{name="id", help="Plaer ID"},{name="item", help="Name of the item (not a label)"}, {name="amount", help="Amount of items"}}, true, function(source, args)
1656 | local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
1657 | local amount = tonumber(args[3])
1658 | local itemData = QBCore.Shared.Items[tostring(args[2]):lower()]
1659 | if Player ~= nil then
1660 | if amount > 0 then
1661 | if itemData ~= nil then
1662 | -- check iteminfo
1663 | local info = {}
1664 | if itemData["name"] == "id_card" then
1665 | info.citizenid = Player.PlayerData.citizenid
1666 | info.firstname = Player.PlayerData.charinfo.firstname
1667 | info.lastname = Player.PlayerData.charinfo.lastname
1668 | info.birthdate = Player.PlayerData.charinfo.birthdate
1669 | info.gender = Player.PlayerData.charinfo.gender
1670 | info.nationality = Player.PlayerData.charinfo.nationality
1671 | info.job = Player.PlayerData.job.label
1672 | elseif itemData["type"] == "weapon" then
1673 | amount = 1
1674 | info.serie = tostring(Config.RandomInt(2) .. Config.RandomStr(3) .. Config.RandomInt(1) .. Config.RandomStr(2) .. Config.RandomInt(3) .. Config.RandomStr(4))
1675 | elseif itemData["name"] == "harness" then
1676 | info.uses = 20
1677 | elseif itemData["name"] == "markedbills" then
1678 | info.worth = math.random(5000, 10000)
1679 | elseif itemData["name"] == "labkey" then
1680 | info.lab = exports["qb-methlab"]:GenerateRandomLab()
1681 | elseif itemData["name"] == "printerdocument" then
1682 | info.url = "https://cdn.discordapp.com/attachments/645995539208470549/707609551733522482/image0.png"
1683 | end
1684 |
1685 | if Player.Functions.AddItem(itemData["name"], amount, false, info) then
1686 | TriggerClientEvent('QBCore:Notify', source, "You have givwen " ..GetPlayerName(tonumber(args[1])).." " .. itemData["name"] .. " ("..amount.. ")", "success")
1687 | else
1688 | TriggerClientEvent('QBCore:Notify', source, "Can't give item!", "error")
1689 | end
1690 | else
1691 | TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Item doesn't exist!")
1692 | end
1693 | else
1694 | TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Amount must be higher than 0!")
1695 | end
1696 | else
1697 | TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
1698 | end
1699 | end, "admin")
1700 |
1701 | QBCore.Commands.Add("randomitems", "Krijg wat random items (voor testen)", {}, false, function(source, args)
1702 | local Player = QBCore.Functions.GetPlayer(source)
1703 | local filteredItems = {}
1704 | for k, v in pairs(QBCore.Shared.Items) do
1705 | if QBCore.Shared.Items[k]["type"] ~= "weapon" then
1706 | table.insert(filteredItems, v)
1707 | end
1708 | end
1709 | for i = 1, 10, 1 do
1710 | local randitem = filteredItems[math.random(1, #filteredItems)]
1711 | local amount = math.random(1, 10)
1712 | if randitem["unique"] then
1713 | amount = 1
1714 | end
1715 | if Player.Functions.AddItem(randitem["name"], amount) then
1716 | TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[randitem["name"]], 'add')
1717 | Citizen.Wait(500)
1718 | end
1719 | end
1720 | end, "god")
1721 | QBCore.Functions.CreateUseableItem("id_card", function(source, item)
1722 | local Player = QBCore.Functions.GetPlayer(source)
1723 | if (Player.PlayerData.job.name == "police" or
1724 | Player.PlayerData.job.name == "police1" or
1725 | Player.PlayerData.job.name == "police2" or
1726 | Player.PlayerData.job.name == "police3" or
1727 | Player.PlayerData.job.name == "police4" or
1728 | Player.PlayerData.job.name == "police5" or
1729 | Player.PlayerData.job.name == "police6" or
1730 | Player.PlayerData.job.name == "police7" or
1731 | Player.PlayerData.job.name == "police8") then
1732 | if Player.Functions.GetItemBySlot(item.slot) ~= nil then
1733 | TriggerClientEvent("inventory:client:ShowId", -1, source, Player.PlayerData.citizenid, item.info)
1734 | TriggerClientEvent('usebadge:gc',source)
1735 | end
1736 | else
1737 | if Player.Functions.GetItemBySlot(item.slot) ~= nil then
1738 | TriggerClientEvent("inventory:client:ShowId", -1, source, Player.PlayerData.citizenid, item.info)
1739 | end
1740 | end
1741 | end)
1742 |
1743 | --[[QBCore.Functions.CreateUseableItem("id_card", function(source, item)
1744 | local Player = QBCore.Functions.GetPlayer(source)
1745 | if Player.Functions.GetItemBySlot(item.slot) ~= nil then
1746 | TriggerClientEvent("inventory:client:ShowId", -1, source, Player.PlayerData.citizenid, item.info)
1747 | end
1748 | end)]]
1749 |
1750 | QBCore.Functions.CreateUseableItem("snowball", function(source, item)
1751 | local Player = QBCore.Functions.GetPlayer(source)
1752 | local itemData = Player.Functions.GetItemBySlot(item.slot)
1753 | if Player.Functions.GetItemBySlot(item.slot) ~= nil then
1754 | TriggerClientEvent("inventory:client:UseSnowball", source, itemData.amount)
1755 | end
1756 | end)
1757 |
1758 | QBCore.Functions.CreateUseableItem("driver_license", function(source, item)
1759 | local Player = QBCore.Functions.GetPlayer(source)
1760 | if Player.Functions.GetItemBySlot(item.slot) ~= nil then
1761 | TriggerClientEvent("inventory:client:ShowDriverLicense", -1, source, Player.PlayerData.citizenid, item.info)
1762 | end
1763 | end)
1764 |
1765 | AddEventHandler('playerDropped', function(reason)
1766 | local src = source
1767 | local opti = {}
1768 | local Player = QBCore.Functions.GetPlayer(source)
1769 | if Player then
1770 | else
1771 | return
1772 | end
1773 | Player.Functions.SetInventory(Player.PlayerData.items)
1774 | for k,item in pairs(Player.PlayerData.items) do
1775 | table.insert(opti, {
1776 | name = item.name,
1777 | amount = item.amount,
1778 | info = item.info,
1779 | type = item.type,
1780 | slot = item.slot,
1781 | })
1782 | end
1783 | print('^2'..GetPlayerName(src)..': Saved Inventory')
1784 | QBCore.Functions.ExecuteSql(true, "UPDATE `players` SET `inventory` = '"..QBCore.EscapeSqli(json.encode(opti)).."' WHERE `citizenid` = '"..Player.PlayerData.citizenid.."'")
1785 | end)
--------------------------------------------------------------------------------