attempt to perform arithmetic on a nil value
Ehhez a functionhoz:
function getAllItemWeight()
local bagWeight = 0
local keyWeight = 0
local vehWeight = 0
local objectWeight = 0
if isElement(elementSource) then
if getElementType(elementSource) == \"player\" then
if inventoryItems[elementSource][\"bag\"] then
for i = 1, row * column do
if (inventoryItems[elementSource][\"bag\"]) then
bagWeight = bagWeight + (getItemWeight(inventoryItems[elementSource][\"bag\"][\"id\"]) * inventoryItems[elementSource][\"bag\"][\"count\"])
end
end
end
if inventoryItems[elementSource][\"key\"] then
for i = 1, row * column do
if (inventoryItems[elementSource][\"key\"]) then
keyWeight = keyWeight + (getItemWeight(inventoryItems[elementSource][\"key\"][\"id\"]) * inventoryItems[elementSource][\"key\"][\"count\"])
end
end
end
end
if getElementType(elementSource) == \"vehicle\" then
if inventoryItems[elementSource] then
if inventoryItems[elementSource][\"vehicle\"] then
for i = 1, row * column do
if (inventoryItems[elementSource][\"vehicle\"]) then
vehWeight = vehWeight + (getItemWeight(inventoryItems[elementSource][\"vehicle\"][\"id\"]) * inventoryItems[elementSource][\"vehicle\"][\"count\"])
end
end
end
end
end
if getElementType(elementSource) == \"object\" then
if inventoryItems[elementSource][\"object\"] then
for i = 1, row * column do
if (inventoryItems[elementSource][\"object\"]) then
objectWeight = objectWeight + (getItemWeight(inventoryItems[elementSource][\"object\"][\"id\"]) * inventoryItems[elementSource][\"object\"][\"count\"])
end
end
end
end
end
return bagWeight + keyWeight + vehWeight + objectWeight
end