Jump to content

new Dx Inventory problems


Recommended Posts

line 30: attemt to index upvalue 'myslots' (a nil value)
line 15: failed to call 'new_inv:showNewInventory' [string"?"]

these are my errors, im trying to merge this dx inventory to my own 

heres the rest of the code, if anyone could help i would be so thankful because im lost

1st error..........

function getMySlots()
getPlayerCurrentSlots()
getPlayerMaxAviableSlots()
end


function refreshNewInventory()
	if not getElementData ( localPlayer, "dayz:new_inv") then return end
	myInventory = exports.dayz:getMyInventory()
	lootInventory = exports.dayz:getLootInventory()
	mySlots = exports.dayz:getMySlots()
	lootSlots = exports.dayz:getLootSlots()
	if myInvOffset+itemQuant > #myInventory then
		if #myInventory > itemQuant then
			myInvOffset = #myInventory-itemQuant
		else
			myInvOffset = 0
		end
	end
	if lootInventory then
		if lootInvOffset+itemQuant > #lootInventory then
			if #lootInventory > itemQuant then
				lootInvOffset = #lootInventory-itemQuant
			else
				lootInvOffset = 0
			end
		end
	end
	local sack = exports.dayz:getPlayerSackName() or "Pocket"
	sackText = sack.." ("..mySlots[1].."/"..mySlots[2]..")"
	lootName = (getElementData(getLocalPlayer(),"lootname") or "Loot").." ("..lootSlots[1].."/"..lootSlots[2]..")"
	selectedFood = nil
	selectedMedicine = nil
	selectedSpec = nil
	selectedItemInMyInventory = nil
	selectedItemInLootInventory = nil
	selectingMainWeapon = false
	refreshFoodBoxes()
	refreshMedicineBoxes()
	refreshToolsBoxes()
	refreshPrimaryWeapons()
	refreshSecondaryWeapons()
	selectedVest = getElementData (localPlayer,"clothBody")
	if selectedVest == 0 then
		selectedVest = false
	end
	selectedHelmet = getElementData (localPlayer,"clothHead")
	if selectedHelmet == 0 then
		selectedHelmet = false
	end
	if sack then
		selectedSack = sack
	else
		selectedSack = nil
	end
end

2nd error.......

function showInventory(key,keyState)
  hideRightClickInventoryMenu()
 -- guiSetVisible(InfoWindow,false)
  local col = getElementData(getLocalPlayer(),"currentCol")
  local gearName = getElementData(getLocalPlayer(),"lootname")
  refreshLoot(col,gearName)
  if getElementData(getLocalPlayer(),"logedin") and keyState == "down" then
	local x, top, bottom = exports.new_inv:getRadioButtonsCoords()
	if getElementData ( localPlayer, "dayz:new_inv") then
		guiRadioButtonSetSelected ( inventoryOnButton, true )
		guiSetVisible(topChangeButtonsParent,not guiGetVisible(topChangeButtonsParent))
		guiSetPosition(topChangeButtonsParent,x,top,false)
		guiSetPosition(bottomChangeButtonsParent,x,bottom,false)
		guiSetVisible(bottomChangeButtonsParent,not guiGetVisible(bottomChangeButtonsParent))
		local show = exports.new_inv:showNewInventory()
		if show then
			onClientOpenInventoryStopMenu ()
		end
		showCursor(show)
		return
	else
		guiRadioButtonSetSelected ( inventoryOffButton, true )
		guiSetVisible(topChangeButtonsParent,false)
	end
	if guiGetVisible(inventoryWindows) then
		guiSetVisible(inventoryWindows,false)
		guiSetVisible(CraftWindow,false)
		showCursor(false)
		guiSetVisible(bottomChangeButtonsParent,false)
	else
		guiSetVisible(inventoryWindows,true)
		showCursor(true)
		guiSetPosition(bottomChangeButtonsParent,0.14*sW+0.72*sW,0.18*sH+0.63*sH-30,false)
		guiSetVisible(bottomChangeButtonsParent,true)
	end
	guiSetVisible(HideGear,false)
	if isPlayerInLoot() then
	  if getElementData(col,"tent") then 
		guiSetVisible(HideGear,true)
		if getElementData(col,"visible") then 
		  guiCheckBoxSetSelected(HideGear,false)
		else
		  guiCheckBoxSetSelected(HideGear,true)
		end
	  end
	end
	refreshInventory()
	--RefreshComboBoxes()
	if guiGetVisible(inventoryWindows)== true then
	  onClientOpenInventoryStopMenu()
	end
  end
end
bindKey("j","down",showInventory)

function showNewInventory()
	if inventoryShowing then
		hideNewInventory()
		return false
	end
	inventoryShowing = true
	showCursor(true)
	selectedItemInMyInventory = nil
	selectedItemInLootInventory = nil
	movingItem = nil
	myScrollHeight = scrollMaxHeight
	lootScrollHeight = scrollMaxHeight
	lastCursorPosition = getCursorPosition()
	refreshNewInventory()
	doubleClickTimer = 0
	addEventHandler ("onClientHUDRender", getRootElement(), drawInventory)
	bindKey ( "mouse_wheel_up", "down", playerScrollInventory, "up" )
	bindKey ( "mouse_wheel_down", "down", playerScrollInventory, "down" )
	bindKey ( "mouse1", "up", resetTotalTempOffset )
	bindKey ( "mouse1", "down", itemSelectedInInventory )
	checkMiddleDrawing()
	return true
end

 

Edited by greentumbleweed
Link to comment
6 hours ago, greentumbleweed said:

this gave me the exact same error exports.new_inv: works fine in other gm somewhere there is a string not being found and im not very good with exporting functions and strings tbh

Maybe you didn't export the function in new_inv in meta.xml

Link to comment
2 minutes ago, LyricalMM said:

Code? Maybe you didn't put the params corectly idk

 

<export function="setMiddleVisible" type="client" />
	<export function="getRadioButtonsCoords" type="client" />
	<export function="showNewInventory" type="client" />
	<export function="hideNewInventory" type="client" />
	<export function="refreshNewInventory" type="client" />

 

Link to comment
6 minutes ago, greentumbleweed said:

 


<export function="setMiddleVisible" type="client" />
	<export function="getRadioButtonsCoords" type="client" />
	<export function="showNewInventory" type="client" />
	<export function="hideNewInventory" type="client" />
	<export function="refreshNewInventory" type="client" />

 

well your script is serverside?

Link to comment
18 minutes ago, LyricalMM said:

the last tought i have is that is something wrong in your showNewInventory function

well that function is fine it would have to be my showInventory function but idk ive been trying this for a week now and i cant get it to work correctly :/

do you have any idea about the first* error?

On 07/10/2018 at 10:25, greentumbleweed said:

line 30: attemt to index upvalue 'myslots' (a nil value)


 
function getMySlots()
getPlayerCurrentSlots()
getPlayerMaxAviableSlots()
end


function refreshNewInventory()
	if not getElementData ( localPlayer, "dayz:new_inv") then return end
	myInventory = exports.dayz:getMyInventory()
	lootInventory = exports.dayz:getLootInventory()
	mySlots = exports.dayz:getMySlots()
	lootSlots = exports.dayz:getLootSlots()
	if myInvOffset+itemQuant > #myInventory then
		if #myInventory > itemQuant then
			myInvOffset = #myInventory-itemQuant
		else
			myInvOffset = 0
		end
	end
	if lootInventory then
		if lootInvOffset+itemQuant > #lootInventory then
			if #lootInventory > itemQuant then
				lootInvOffset = #lootInventory-itemQuant
			else
				lootInvOffset = 0
			end
		end
	end
	local sack = exports.dayz:getPlayerSackName() or "Pocket"
	sackText = sack.." ("..mySlots[1].."/"..mySlots[2]..")"
	lootName = (getElementData(getLocalPlayer(),"lootname") or "Loot").." ("..lootSlots[1].."/"..lootSlots[2]..")"
	selectedFood = nil
	selectedMedicine = nil
	selectedSpec = nil
	selectedItemInMyInventory = nil
	selectedItemInLootInventory = nil
	selectingMainWeapon = false
	refreshFoodBoxes()
	refreshMedicineBoxes()
	refreshToolsBoxes()
	refreshPrimaryWeapons()
	refreshSecondaryWeapons()
	selectedVest = getElementData (localPlayer,"clothBody")
	if selectedVest == 0 then
		selectedVest = false
	end
	selectedHelmet = getElementData (localPlayer,"clothHead")
	if selectedHelmet == 0 then
		selectedHelmet = false
	end
	if sack then
		selectedSack = sack
	else
		selectedSack = nil
	end
end

 

Edited by greentumbleweed
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...