Jump to content

[HELP] Inventory - itemPlus


India

Recommended Posts

Hello, i have inventory system for DayZ Gamemode, if i delete the values there, it gives an error. Cause trying to attract a value that is not. If there is no value, i want it to be "1". so you can take 1 item when the value is empty.

Spoiler

mta-screen-2021-03-06-16-06-47.png

 

function onPlayerMoveItemOutOfInventory ()
	hideRightClickInventoryMenu ()
	if playerMovedInInventory or getNetworkStats().packetlossLastSecond > 10 then return end
	itemPlus = tonumber(guiGetText(editBoxInv))
	if itemPlus > 0 then
		loot = getElementData(localPlayer,"currentCol")
		dropItemName = guiGridListGetItemText ( gridlistItems["inventory"], guiGridListGetSelectedItem ( gridlistItems["inventory"] ), 1 )
		itemName = guiGridListGetItemData(gridlistItems["inventory"], guiGridListGetSelectedItem ( gridlistItems["inventory"] ), 1 )
		if dropItemName == "" then return end
		if getElementData(localPlayer,itemName) and getElementData(localPlayer,itemName) >= 1 then
			if getElementData(localPlayer,itemName) < itemPlus then
				itemPlus = getElementData(localPlayer,itemName)
			end
			if getElementData(localPlayer,itemName) >= itemPlus then
				move,reason = onPlayerDontMoveItemOutOFInventory(itemName,itemPlus)
				if move then
					if loot then
						if isPlayerInLoot() then
							if getLootCurrentSlots(loot) + (getItemSlots(itemName)*itemPlus) <= getLootMaxAviableSlots(isPlayerInLoot()) then
								setElementData(localPlayer,itemName,getElementData(localPlayer,itemName)-itemPlus)
								if not getElementData(loot,itemName) then setElementData(loot,itemName,0) end
								setElementData(loot,itemName,getElementData(loot,itemName)+itemPlus)
								playerMovedInInventory = true
								setTimer(function() playerMovedInInventory = false end,300,1)
								if loot and getElementData(loot,"itemloot") then
									triggerServerEvent("refre:~emLoot",getRootElement(),loot,getElementData(loot,"parent"))
								end
							else
								triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Yeterli alan yok", 255, 0, 0 )
							end
						end
					else
						if getNetworkStats().packetlossLastSecond < 2 then
							setElementData(localPlayer,itemName,getElementData(localPlayer,itemName)-itemPlus)
							triggerServerEvent("playerDropAItem",localPlayer,itemName,itemPlus,dropItemName)
						else
							triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Kötü sunucu bağlantısı", 255, 0, 0 )
						end
						playerMovedInInventory = true
						setTimer(function() playerMovedInInventory = false end,800,1)
					end
					triggerServerEvent("shiftLoot",localPlayer,itemName,itemPlus,loot)
				else
					triggerEvent ("displayClientInfo", localPlayer,"Inventory", reason, 255, 0, 0 )
				end
			else
				triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Çok fazla değer", 255, 0, 0 )
			end
		end
		refreshInventory()
		if isPlayerInLoot() then
			if getElementData(loot,"safe") == 1 and guiGetText(lootSlot) == "Yer:" then
				hideInventoryManual ()
				triggerEvent ("onClientOpenSafe", localPlayer, loot)
				return
			end
			refreshLoot(loot)
		end
	else
		triggerEvent ("displayClientInfo", localPlayer,"Inventory", "Çok küçük değer", 255, 0, 0 )
	end
end
addEventHandler ( "onClientGUIClick", buttonInv, onPlayerMoveItemOutOfInventory, false )

 

Edited by India
Link to comment
34 minutes ago, Tekken said:

Where does the error occurs ?

I have PVP Tents, and it appears as "inf" because the item values are unlimited. when i click item taking value disappears

mta-screen-2021-03-06-20-01-23.png

Edited by India
Link to comment
  • Scripting Moderators
57 minutes ago, India said:

oh thanks, it works


itemPlus = itemPlus or 1;

 

By setting items client-side you are inviting "hackers" to your server. Be aware that someday someone will exploit that you've doing it incorrectly, which will result in player copying items and so on.

  • Thanks 2
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...