So, what am i doin wrong here.
The visual thing is worked out.
But what am i doin wrong here.
I've got this in the .js script:
I am using the new qbcore with oxmysql
The visual thing is worked out.
But what am i doin wrong here.
I've got this in the .js script:
This in the qb-inventory -> server -> main.lua$("#item-use").droppable({
hoverClass: "button-hover",
drop: function(event, ui) {
setTimeout(function() {
IsDragging = false;
}, 300);
fromData = ui.draggable.data("item");
fromInventory = ui.draggable.parent().attr("data-inventory");
if (fromData.useable) {
if (fromData.shouldClose) {
Inventory.Close();
}
$.post(
"Hidden link for visitors, to see Log in or register now.",
JSON.stringify({
inventory: fromInventory,
item: fromData,
})
);
}
},
});
and this in the qb-inventory -> client -> main.luaRegisterServerEvent("inventory:server:GiveItem")
AddEventHandler('inventory:server:GiveItem', function(target, inventory, item, amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(target))
local dist = #(GetEntityCoords(GetPlayerPed(src))-GetEntityCoords(GetPlayerPed(target)))
if dist < 3 then
if amount <= item.amount then
if amount == 0 then
amount = item.amount -- If 0 gives all of an item the player has
end
if OtherPlayer.Functions.AddItem(item.name, amount, false, item.info) then
TriggerClientEvent('inventory:client:ItemBox',target, QBCore.Shared.Items[item.name], "add", amount)
TriggerClientEvent('QBCore:Notify', target, "You Received " .. amount .. ' ' .. item.label .. "!")
TriggerClientEvent("inventory:client:UpdatePlayerInventory", target, true)
Player.Functions.RemoveItem(item.name, amount, item.slot)
TriggerClientEvent('inventory:client:ItemBox',src, QBCore.Shared.Items[item.name], "remove", amount)
TriggerClientEvent('QBCore:Notify', src, "You gave " .. OtherPlayer.PlayerData.charinfo.firstname.." "..OtherPlayer.PlayerData.charinfo.lastname.. " " .. amount .. " " .. item.label .."!")
TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, true)
else
TriggerClientEvent('QBCore:Notify', src, "The other players inventory is full!", "error")
TriggerClientEvent('QBCore:Notify', target, "Your inventory is full!", "error")
TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, false)
TriggerClientEvent("inventory:client:UpdatePlayerInventory", target, false)
end
else
TriggerClientEvent('QBCore:Notify', src, "You do not have enough items to transfer")
end
else
TriggerClientEvent('QBCore:Notify', src, "You are too far away to give items!")
end
end)
RegisterNUICallback("GiveItem", function(data, cb)
local player, distance = QBCore.Functions.GetClosestPlayer(GetEntityCoords(PlayerPedId()))
if player ~= -1 and distance < 3 then
if (data.inventory == 'player') then
local playerId = GetPlayerServerId(player)
SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true)
TriggerServerEvent("inventory:server:GiveItem", playerId, data.inventory, data.item, data.amount)
else
QBCore.Functions.Notify("You do not own this item!", "error")
end
else
QBCore.Functions.Notify("No one nearby!", "error")
end
end)
I am using the new qbcore with oxmysql