Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ElclarkKuhu committed Oct 14, 2021
1 parent e1240a9 commit d680ada
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 102 deletions.
12 changes: 10 additions & 2 deletions NUI/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let containers
let display = false
let isLoading = false
let showMiddleMenu = false
let inventoryMaxWeight = 0
let contextElement = document.getElementById('context-menu')
let infoMenu = document.getElementById('info-menu')

Expand Down Expand Up @@ -38,7 +39,7 @@ window.addEventListener('message', (event) => {
if (eventData.action === 'addItem') {
setLoading(0, false)

setWeight(eventData.type, eventData.weights.weight, eventData.weights.maxWeight)
inventoryMaxWeight = eventData.weights.maxWeight

eventData.data.forEach(item => {
addTo(data, item)
Expand Down Expand Up @@ -123,9 +124,12 @@ function setupContainers(type, count) {
}

function useItem(id) {
if (getFrom(data, null, id).usable) {
let value = getFrom(data, null, id)

if (value.usable) {
closeNUI()
$.post(`https://${GetParentResourceName()}/useItem`, JSON.stringify({
'name': value.name,
'id': id
}))
data = removeFrom(data, id)
Expand Down Expand Up @@ -211,8 +215,11 @@ function reloadData() {
container.innerHTML = ''
})

let weight = 0
data.forEach(obj => {
let container = document.getElementById(obj.slot)
weight += obj.weight

if (container.innerHTML === '') {
createItem(obj, container)
} else {
Expand All @@ -223,6 +230,7 @@ function reloadData() {
}
})

setWeight(0, weight, inventoryMaxWeight)
contextElement.classList.remove('active')
}

Expand Down
26 changes: 24 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RegisterNetEvent('esx:playerLoaded', function(playerData)
TriggerServerEvent('eInventoryLite:LoadPlayerData')
end)

RegisterKeyMapping("openInventory", "Open Inventory", "keyboard", "F2")
RegisterCommand('openInventory', function()
RegisterKeyMapping("-openInventory", "Open Inventory", "keyboard", "F2")
RegisterCommand('-openInventory', function()
TriggerServerEvent('eInventoryLite:getInventory')
TriggerEvent('eInventory:openInventory') -- For Add-On

Expand Down Expand Up @@ -37,6 +37,28 @@ RegisterCommand('closeInventory', function()
closeNUI()
end, false)

RegisterNetEvent('esx:addInventoryItem', function(item, count, showNotification)
if tostring(count) ~= 'false' then
TriggerServerEvent('eInventoryLite:addData', item, 'item_standard', count)
end
end)

RegisterNetEvent('esx:removeInventoryItem', function(item, count, showNotification)
if tostring(count) ~= 'false' then
TriggerServerEvent('eInventoryLite:deleteData', item, 'item_standard', count)
end
end)

if configs.includeWeapons then
RegisterNetEvent('esx:addWeapon', function(weapon)
TriggerServerEvent('eInventoryLite:addData', weapon, 'item_weapon', 1)
end)

RegisterNetEvent('esx:removeWeapon', function(weapon)
TriggerServerEvent('eInventoryLite:deleteData', weapon, 'item_weapon', 0)
end)
end

RegisterNUICallback('getConfig', function(data, cb)
cb(configs)
end)
Expand Down
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ configs = {

-- Player
playerInventorySlot = 50, -- Multiply by 5 for best UI experience
includeWeapons = true,

-- Server
-- useMySql = true -- if useMySql disabled using esx_datastore instead (Enable For Performance and efficiency)
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fx_version 'cerulean'

author 'Elclark'
version '1.2.0'
version '1.2.1'
description 'Elclark Inventory Lite. Is an simple ESX Inventory with drag and drop and splittable items to organize your items and weapons'

game 'gta5'
Expand Down
Loading

0 comments on commit d680ada

Please sign in to comment.