- Katılım
- 4 yıl 7 ay 7 gün
- Mesajlar
- 158
Selamlar bende iki tane envanter var şimdi bu envanter es_extendedın kendi weightini kullanmıyor. Ben nasıl es_extendedın ağırlığını eklediğim ikinci envanterin ağırlığına eşitlerim denediğim şeylerden biri
bu kodu eklediğim envanterin weight hesaplamasının sonuna ekliyorum
Kod:
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.weight = weight
Kod:
function loadPlayerInventory()
ESX.TriggerServerCallback("esx_inventoryhud:getPlayerInventory", function(data)
items = {}
fastItems = {}
inventory = data.inventory
accounts = data.accounts
money = data.money
weapons = data.weapons
if Config.IncludeCash and money ~= nil and money > 0 then
for key, value in pairs(accounts) do
moneyData = {
label = _U("cash"),
name = "cash",
type = "item_money",
count = money,
usable = false,
rare = false,
limit = -1,
canRemove = true
}
table.insert(items, moneyData)
end
end
if Config.IncludeAccounts and accounts ~= nil then
for key, value in pairs(accounts) do
if not shouldSkipAccount(accounts[key].name) then
local canDrop = accounts[key].name ~= "bank"
if accounts[key].money > 0 then
accountData = {
label = accounts[key].label,
count = accounts[key].money,
type = "item_account",
name = accounts[key].name,
usable = false,
rare = false,
limit = -1,
canRemove = canDrop
}
table.insert(items, accountData)
end
end
end
end
if inventory ~= nil then
for key, value in pairs(inventory) do
if inventory[key].count <= 0 then
inventory[key] = nil
else
inventory[key].type = "item_standard"
table.insert(items, inventory[key])
--widgetTotal = getInventoryWeight(items)
end
end
end
if Config.IncludeWeapons and weapons ~= nil then
for key, value in pairs(weapons) do
local weaponHash = GetHashKey(weapons[key].name)
local playerPed = PlayerPedId()
if HasPedGotWeapon(playerPed, weaponHash, false) and weapons[key].name ~= "WEAPON_UNARMED" then
local found = false
for slot, weapon in pairs(fastWeapons) do
if weapon == weapons[key].name then
local ammo = GetAmmoInPedWeapon(playerPed, weaponHash)
table.insert(
fastItems,
{
label = weapons[key].label,
count = ammo,
limit = -1,
type = "item_weapon",
name = weapons[key].name,
usable = false,
rare = false,
canRemove = true,
slot = slot
}
)
found = true
break
end
end
if found == false then
local ammo = GetAmmoInPedWeapon(playerPed, weaponHash)
table.insert(
items,
{
label = weapons[key].label,
count = ammo,
limit = -1,
type = "item_weapon",
name = weapons[key].name,
usable = false,
rare = false,
canRemove = true
}
)
end
end
end
end
local arrayWeight = Config.localWeight
local arraySilah = Config.localSilah
local weight = 0
local itemWeight = 0
local silahWeight = 0
local itemsW = 0
if items ~= nil then
for i = 1, #items, 1 do
if items[i] ~= nil then
itemWeight = Config.DefaultWeight
itemWeight = itemWeight / items[1].count * 0.0
if arraySilah[items[i].name] ~= nil then
silahWeight = arraySilah[items[i].name]
weight = weight + silahWeight
end
if arrayWeight[items[i].name] ~= nil then
itemWeight = arrayWeight[items[i].name]
items[i].limit = itemWeight / 1000
end
weight = weight + (itemWeight * (items[i].count or 1))
end
end
end
local arrayWeight = Config.localWeight
local arraySilah = Config.localSilah
local itemWeight = 0
local silahWeight = 0
if fastItems ~= nil then
for i = 1, #fastItems, 1 do
if fastItems[i] ~= nil then
itemWeight = Config.DefaultWeight
itemWeight = itemWeight / items[1].count * 0.0
if arraySilah[fastItems[i].name] ~= nil then
silahWeight = arraySilah[fastItems[i].name]
weight = weight + silahWeight
end
if arrayWeight[fastItems[i].name] ~= nil then
itemWeight = arrayWeight[fastItems[i].name]
fastItems[i].limit = itemWeight / 1000
end
weight = weight + (itemWeight * (fastItems[i].count or 1))
end
end
end
local texts = _U("player_info", GetPlayerName(PlayerId()), (weight / 1000), (Config.Limit / 1000))
if weight > Config.Limit then
exports['mythic_notify']:SendAlert('error', 'Inventário Cheio! Não Consegues Andar')
--[[TriggerEvent("pNotify:SendNotification", {
text = 'Inventário Cheio! Não Consegues Andar',
type = "error",
timeout = 2000,
layout = "centerLeft"
})--]]
--Uncomment this to Use pNotify
setHurt()
texts = _U("player_info_full", GetPlayerName(PlayerId()), (weight / 1000), (Config.Limit / 1000))
elseif weight <= Config.Limit then
setNotHurt()
texts = _U("player_info", GetPlayerName(PlayerId()), (weight / 1000), (Config.Limit / 1000))
end
SendNUIMessage(
{
action = "setItems",
itemList = items,
fastItems = fastItems,
text = texts
})
end, GetPlayerServerId(PlayerId())
)
end
local texts = _U("player_info", GetPlayerName(PlayerId()), (weight / 1000), (Config.Limit / 1000))
bunun altına ama o zaman eklediğim envanterin ağırlığı 0 oluyor.
Son düzenleme: