hasankortak
üye
- Katılım
- 23 Tem 2021
- Mesajlar
- 430
- Konu Yazar
- #1
Kod:
Selamlar Herkese, forumda item verme kısmının paylaşılmadığını gördüm.Bende Ufak Tefek Eklemeler yapıp fixlemeye çalıştım.
Kod:
RegisterServerEvent("inventory:server:GiveItem") ----> Server Side
AddEventHandler('inventory:server:GiveItem', function(name, inventory, item, amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(name))
local Target = OtherPlayer.PlayerData.charinfo.firstname..' '..OtherPlayer.PlayerData.charinfo.lastname
local YourName = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
local totalWeight = QBCore.Player.GetTotalWeight(OtherPlayer.PlayerData.items)
local itemInfo = QBCore.Shared.Items[item.name:lower()]
if amount ~= 0 then
if (totalWeight + (itemInfo["weight"] * amount)) <= QBCore.Config.Player.MaxWeight then
if Player.Functions.RemoveItem(item.name, amount, item.slot, item.info) and OtherPlayer.Functions.AddItem(item.name, amount,false, item.info) then
TriggerClientEvent('QBCore:Notify', src, "Şu İtemi Verdin : "..item.label..' Verilen : '..Target)
TriggerClientEvent('inventory:client:ItemBox',src, QBCore.Shared.Items[item.name], "remove", amount)
TriggerClientEvent('QBCore:Notify', name, "Şu İtemi Aldın : "..item.label..' Veren : '..YourName)
TriggerClientEvent('inventory:client:ItemBox',name, QBCore.Shared.Items[item.name], "add", amount)
end
else
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Karşıdaki kişi maksimum kiloda', "error")
TriggerClientEvent('QBCore:Notify', OtherPlayer.PlayerData.source, 'Maksimum ağırlığa ulaştınız item eklenmedi', "error")
end
end
end)
----ESX HALİ SERVER Side----
RegisterServerEvent("inventory:server:GiveItem")
AddEventHandler('inventory:server:GiveItem', function(name, sedat, inventory, item, amount)
local src = source
local Player = ESX.GetPlayerFromId(src)
local OtherPlayer = ESX.GetPlayerFromId(tonumber(name))
local Target = OtherPlayer.get("firstName")..' '..OtherPlayer.get("lastName")
local YourName = Player.get("firstName")..' '..Player.get("lastName")
local totalWeight = ESX.GetTotalWeight(OtherPlayer.inventory)
local itemInfo = ESX.GetItems()[tostring(item.name)]
if amount ~= 0 then
if (totalWeight + (itemInfo["weight"] * amount)) <= ESX.GetConfig().MaxWeight then
if Player.removeInventoryItem(item.name, amount, item.slot, item.info) and OtherPlayer.addInventoryItem(item.name, amount,false, item.info) then
-- TriggerClientEvent('QBCore:Notify', src, "Şu İtemi Verdin : "..item.label..' Verilen : '..Target)
TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'success', text = "Şu İtemi Verdin : "..item.label..' Verilen : '..Target})
TriggerClientEvent("inventory:client:ItemBox",src, ESX.GetItems()[item.name],'remove',amount)
--TriggerClientEvent('QBCore:Notify', name, "Şu İtemi Aldın : "..item.label..' Veren : '..YourName)
TriggerClientEvent('mythic_notify:client:SendAlert', name, { type = 'success', text = "Şu İtemi Aldın : "..item.label..' Veren : '..YourName})
TriggerClientEvent("inventory:client:ItemBox",OtherPlayer.source, ESX.GetItems()[item.name],'add',amount)
end
else
TriggerClientEvent('mythic_notify:client:SendAlert', Player.source, { type = 'error', text = 'Karşıdaki kişi maksimum kiloda'})
TriggerClientEvent('mythic_notify:client:SendAlert', OtherPlayer.source, { type = 'error', text = 'Maksimum ağırlığa ulaştınız item eklenmedi'})
end
end
end)
RegisterNetEvent('inventory:client:lockInventory')
AddEventHandler('inventory:client:lockInventory', function(toggle)
inventorylocked = toggle
end)
---->Torpido Bagaj da item vermeyi kapatmak için<------
OpenTrunk()
inventorylocked = false
elseif CurrentGlovebox ~= nil then
inventorylocked = false
elseif CurrentDrop and CurrentDrop ~= 0 then
inventorylocked = false
else
inventorylocked = true
TriggerServerEvent("inventory:server:OpenInventory")
end
---> Client Side
RegisterNUICallback("GiveItem", function(data, cb)
local player, distance = GetClosestPlayer()
if player ~= -1 and distance < 2.5 then
local playerPed = GetPlayerPed(player)
local playerId = GetPlayerServerId(player)
local plyCoords = GetEntityCoords(playerPed)
local pos = GetEntityCoords(GetPlayerPed(-1))
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, plyCoords.x, plyCoords.y, plyCoords.z, true)
if dist < 2.5 and givelock == true then
SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true)
TriggerServerEvent("inventory:server:GiveItem", playerId, data.inventory, data.item, data.amount)
print(data.amount)
elseif givelock== false then
QBCore.Functions.Notify("İtemi Veremezsin!", "error")
else
QBCore.Functions.Notify("Yakında Kimse Yok!", "error")
end
else
QBCore.Functions.Notify("No one nearby!", "error")
end
end)
----> HTML - Uı kısmına
<div class="inv-option-item" id="item-use"><p>Kullan</p></div>
<div class="inv-option-item" id="item-give"><p>VER</p></div>
-----> JS
$("#item-use").droppable({ ---dan sonra ekleyebilirsiniz
$("#item-give").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");
amount = $("#item-amount").val();
if(fromData.amount > 0) {
$.post("
", JSON.stringify({
inventory: fromInventory,
item: fromData,
amount: parseInt(amount),
}));
Inventory.Close();
}
}
});
Selamlar Herkese, forumda item verme kısmının paylaşılmadığını gördüm.Bende Ufak Tefek Eklemeler yapıp fixlemeye çalıştım.
Kod:
RegisterServerEvent("inventory:server:GiveItem") ----> Server Side
AddEventHandler('inventory:server:GiveItem', function(name, inventory, item, amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(name))
local Target = OtherPlayer.PlayerData.charinfo.firstname..' '..OtherPlayer.PlayerData.charinfo.lastname
local YourName = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
local totalWeight = QBCore.Player.GetTotalWeight(OtherPlayer.PlayerData.items)
local itemInfo = QBCore.Shared.Items[item.name:lower()]
if amount ~= 0 then
if (totalWeight + (itemInfo["weight"] * amount)) <= QBCore.Config.Player.MaxWeight then
if Player.Functions.RemoveItem(item.name, amount, item.slot, item.info) and OtherPlayer.Functions.AddItem(item.name, amount,false, item.info) then
TriggerClientEvent('QBCore:Notify', src, "Şu İtemi Verdin : "..item.label..' Verilen : '..Target)
TriggerClientEvent('inventory:client:ItemBox',src, QBCore.Shared.Items[item.name], "remove", amount)
TriggerClientEvent('QBCore:Notify', name, "Şu İtemi Aldın : "..item.label..' Veren : '..YourName)
TriggerClientEvent('inventory:client:ItemBox',name, QBCore.Shared.Items[item.name], "add", amount)
end
else
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Karşıdaki kişi maksimum kiloda', "error")
TriggerClientEvent('QBCore:Notify', OtherPlayer.PlayerData.source, 'Maksimum ağırlığa ulaştınız item eklenmedi', "error")
end
end
end)
----ESX HALİ SERVER Side----
RegisterServerEvent("inventory:server:GiveItem")
AddEventHandler('inventory:server:GiveItem', function(name, sedat, inventory, item, amount)
local src = source
local Player = ESX.GetPlayerFromId(src)
local OtherPlayer = ESX.GetPlayerFromId(tonumber(name))
local Target = OtherPlayer.get("firstName")..' '..OtherPlayer.get("lastName")
local YourName = Player.get("firstName")..' '..Player.get("lastName")
local totalWeight = ESX.GetTotalWeight(OtherPlayer.inventory)
local itemInfo = ESX.GetItems()[tostring(item.name)]
if amount ~= 0 then
if (totalWeight + (itemInfo["weight"] * amount)) <= ESX.GetConfig().MaxWeight then
if Player.removeInventoryItem(item.name, amount, item.slot, item.info) and OtherPlayer.addInventoryItem(item.name, amount,false, item.info) then
-- TriggerClientEvent('QBCore:Notify', src, "Şu İtemi Verdin : "..item.label..' Verilen : '..Target)
TriggerClientEvent('mythic_notify:client:SendAlert', src, { type = 'success', text = "Şu İtemi Verdin : "..item.label..' Verilen : '..Target})
TriggerClientEvent("inventory:client:ItemBox",src, ESX.GetItems()[item.name],'remove',amount)
--TriggerClientEvent('QBCore:Notify', name, "Şu İtemi Aldın : "..item.label..' Veren : '..YourName)
TriggerClientEvent('mythic_notify:client:SendAlert', name, { type = 'success', text = "Şu İtemi Aldın : "..item.label..' Veren : '..YourName})
TriggerClientEvent("inventory:client:ItemBox",OtherPlayer.source, ESX.GetItems()[item.name],'add',amount)
end
else
TriggerClientEvent('mythic_notify:client:SendAlert', Player.source, { type = 'error', text = 'Karşıdaki kişi maksimum kiloda'})
TriggerClientEvent('mythic_notify:client:SendAlert', OtherPlayer.source, { type = 'error', text = 'Maksimum ağırlığa ulaştınız item eklenmedi'})
end
end
end)
RegisterNetEvent('inventory:client:lockInventory')
AddEventHandler('inventory:client:lockInventory', function(toggle)
inventorylocked = toggle
end)
---->Torpido Bagaj da item vermeyi kapatmak için<------
OpenTrunk()
inventorylocked = false
elseif CurrentGlovebox ~= nil then
inventorylocked = false
elseif CurrentDrop and CurrentDrop ~= 0 then
inventorylocked = false
else
inventorylocked = true
TriggerServerEvent("inventory:server:OpenInventory")
end
---> Client Side
RegisterNUICallback("GiveItem", function(data, cb)
local player, distance = GetClosestPlayer()
if player ~= -1 and distance < 2.5 then
local playerPed = GetPlayerPed(player)
local playerId = GetPlayerServerId(player)
local plyCoords = GetEntityCoords(playerPed)
local pos = GetEntityCoords(GetPlayerPed(-1))
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, plyCoords.x, plyCoords.y, plyCoords.z, true)
if dist < 2.5 and givelock == true then
SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true)
TriggerServerEvent("inventory:server:GiveItem", playerId, data.inventory, data.item, data.amount)
print(data.amount)
elseif givelock== false then
QBCore.Functions.Notify("İtemi Veremezsin!", "error")
else
QBCore.Functions.Notify("Yakında Kimse Yok!", "error")
end
else
QBCore.Functions.Notify("No one nearby!", "error")
end
end)
----> HTML - Uı kısmına
<div class="inv-option-item" id="item-use"><p>Kullan</p></div>
<div class="inv-option-item" id="item-give"><p>VER</p></div>
-----> JS
$("#item-use").droppable({ ---dan sonra ekleyebilirsiniz
$("#item-give").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");
amount = $("#item-amount").val();
if(fromData.amount > 0) {
$.post("
Ziyaretçiler için gizlenmiş link,görmek için
Giriş yap veya üye ol.
inventory: fromInventory,
item: fromData,
amount: parseInt(amount),
}));
Inventory.Close();
}
}
});