Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMeepso authored Sep 21, 2024
2 parents f51b093 + 96ec7df commit d5badef
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 25 deletions.
37 changes: 18 additions & 19 deletions client/drops.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local holdingDrop = false
holdingDrop = false
local bagObject = nil
local heldDrop = nil
CurrentDrop = nil
Expand All @@ -7,24 +7,23 @@ CurrentDrop = nil

function GetDrops()
QBCore.Functions.TriggerCallback('qb-inventory:server:GetCurrentDrops', function(drops)
if drops then
for k, v in pairs(drops) do
local bag = NetworkGetEntityFromNetworkId(v.entityId)
if DoesEntityExist(bag) then
exports['qb-target']:AddTargetEntity(bag, {
options = {
{
icon = 'fas fa-backpack',
label = Lang:t('menu.o_bag'),
action = function()
TriggerServerEvent('qb-inventory:server:openDrop', k)
CurrentDrop = dropId
end,
},
if not drops then return end
for k, v in pairs(drops) do
local bag = NetworkGetEntityFromNetworkId(v.entityId)
if DoesEntityExist(bag) then
exports['qb-target']:AddTargetEntity(bag, {
options = {
{
icon = 'fas fa-backpack',
label = Lang:t('menu.o_bag'),
action = function()
TriggerServerEvent('qb-inventory:server:openDrop', k)
CurrentDrop = k
end,
},
distance = 2.5,
})
end
},
distance = 2.5,
})
end
end
end)
Expand Down Expand Up @@ -59,7 +58,7 @@ RegisterNetEvent('qb-inventory:client:setupDropTarget', function(dropId)
label = 'Pick up bag',
action = function()
if IsPedArmed(PlayerPedId(), 4) then
return QBCore.Functions.Notify("You can not be holding a Gun and a Bag!", "error", 5500)
return QBCore.Functions.Notify("You can not be holding a Gun and a Bag!", "error", 5500)
end
if holdingDrop then
return QBCore.Functions.Notify("Your already holding a bag, Go Drop it!", "error", 5500)
Expand Down
1 change: 1 addition & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
QBCore = exports['qb-core']:GetCoreObject()
PlayerData = nil
local hotbarShown = false

-- Handlers
Expand Down
7 changes: 5 additions & 2 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ const InventoryContainer = Vue.createApp({
targetInventory[targetSlotNumber] = sourceItem;
sourceInventory[this.currentlyDraggingSlot].slot = this.currentlyDraggingSlot;
targetInventory[targetSlotNumber].slot = targetSlotNumber;
this.postInventoryData(this.dragStartInventoryType, targetInventoryType, this.currentlyDraggingSlot, targetSlotNumber, amountToTransfer, targetItem.amount);
this.postInventoryData(this.dragStartInventoryType, targetInventoryType, this.currentlyDraggingSlot, targetSlotNumber, sourceItem.amount, targetItem.amount);
}
} else {
sourceItem.amount -= amountToTransfer;
Expand Down Expand Up @@ -589,6 +589,7 @@ const InventoryContainer = Vue.createApp({
});

if (response.data) {
delete this.playerInventory[playerItemKey];
this.otherInventory[1] = newItem;
this.otherInventoryName = response.data;
this.otherInventoryLabel = response.data;
Expand Down Expand Up @@ -698,12 +699,14 @@ const InventoryContainer = Vue.createApp({
}

try {
await axios.post("https://qb-inventory/GiveItem", {
const response = await axios.post("https://qb-inventory/GiveItem", {
item: selectedItem,
amount: amountToGive,
slot: selectedItem.slot,
info: selectedItem.info,
});
if (!response.data) return;

this.playerInventory[selectedItem.slot].amount -= amountToGive;
if (this.playerInventory[selectedItem.slot].amount === 0) {
delete this.playerInventory[selectedItem.slot];
Expand Down
57 changes: 57 additions & 0 deletions locales/de.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local Translations = {
progress = {
['snowballs'] = 'Schneebälle sammeln..',
},
notify = {
['failed'] = 'Fehlgeschlagen',
['canceled'] = 'Abgebrochen',
['vlocked'] = 'Fahrzeug verriegelt',
['notowned'] = 'Du besitzt diesen Gegenstand nicht!',
['missitem'] = 'Du hast diesen Gegenstand nicht!',
['nonb'] = 'Niemand in der Nähe!',
['noaccess'] = 'Nicht zugänglich',
['nosell'] = 'Du kannst diesen Gegenstand nicht verkaufen..',
['itemexist'] = 'Der Gegenstand existiert nicht',
['notencash'] = 'Du hast nicht genug Bargeld..',
['noitem'] = 'Du hast nicht die richtigen Gegenstände..',
['gsitem'] = 'Du kannst dir keinen Gegenstand geben?',
['tftgitem'] = 'Du bist zu weit weg, um Gegenstände zu geben!',
['infound'] = 'Der Gegenstand, den du geben wolltest, wurde nicht gefunden!',
['iifound'] = 'Falscher Gegenstand gefunden, versuche es erneut!',
['gitemrec'] = 'Du hast erhalten ',
['gitemfrom'] = ' Von ',
['gitemyg'] = 'Du hast gegeben ',
['gitinvfull'] = 'Das Inventar des anderen Spielers ist voll!',
['giymif'] = 'Dein Inventar ist voll!',
['gitydhei'] = 'Du hast nicht genug von dem Gegenstand',
['gitydhitt'] = 'Du hast nicht genug Gegenstände zum Übertragen',
['navt'] = 'Ungültiger Typ..',
['anfoc'] = 'Argumente nicht korrekt ausgefüllt..',
['yhg'] = 'Du hast gegeben ',
['cgitem'] = 'Kann den Gegenstand nicht geben!',
['idne'] = 'Gegenstand existiert nicht',
['pdne'] = 'Spieler ist nicht online',
},
inf_mapping = {
['opn_inv'] = 'Inventar öffnen',
['tog_slots'] = 'Schaltet die belegten Slots um',
['use_item'] = 'Verwendet den Gegenstand im Slot ',
},
menu = {
['vending'] = 'Verkaufsautomat',
['bin'] = 'Müllcontainer öffnen',
['craft'] = 'Herstellen',
['o_bag'] = 'Tasche öffnen',
},
interaction = {
['craft'] = '~g~E~w~ - Herstellen',
},
}

if GetConvar('qb_locale', 'en') == 'de' then
Lang = Locale:new({
phrases = Translations,
warnOnMissing = true,
fallbackLang = Lang,
})
end
18 changes: 14 additions & 4 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,18 @@ QBCore.Functions.CreateCallback('qb-inventory:server:createDrop', function(sourc
local bag = CreateObjectNoOffset(Config.ItemDropObject, playerCoords.x + 0.5, playerCoords.y + 0.5, playerCoords.z, true, true, false)
local dropId = NetworkGetNetworkIdFromEntity(bag)
local newDropId = 'drop-' .. dropId
local itemsTable = setmetatable({ item }, {
__len = function(t)
local length = 0
for _ in pairs(t) do length += 1 end
return length
end
})
if not Drops[newDropId] then
Drops[newDropId] = {
name = newDropId,
label = 'Drop',
items = { item },
items = itemsTable,
entityId = dropId,
createdTime = os.time(),
coords = playerCoords,
Expand Down Expand Up @@ -488,9 +495,12 @@ RegisterNetEvent('qb-inventory:server:SetInventoryData', function(fromInventory,
end
else
if toItem then
if RemoveItem(fromId, fromItem.name, fromAmount, fromSlot, 'swapped item') and RemoveItem(toId, toItem.name, toAmount, toSlot, 'swapped item') then
AddItem(toId, fromItem.name, fromAmount, toSlot, fromItem.info, 'swapped item')
AddItem(fromId, toItem.name, toAmount, fromSlot, toItem.info, 'swapped item')
local fromItemAmount = fromItem.amount
local toItemAmount = toItem.amount

if RemoveItem(fromId, fromItem.name, fromItemAmount, fromSlot, 'swapped item') and RemoveItem(toId, toItem.name, toItemAmount, toSlot, 'swapped item') then
AddItem(toId, fromItem.name, fromItemAmount, toSlot, fromItem.info, 'swapped item')
AddItem(fromId, toItem.name, toItemAmount, fromSlot, toItem.info, 'swapped item')
end
else
if RemoveItem(fromId, fromItem.name, toAmount, fromSlot, 'moved item') then
Expand Down

0 comments on commit d5badef

Please sign in to comment.