India Posted March 6, 2021 Posted March 6, 2021 (edited) 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 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 March 6, 2021 by India
Tekken Posted March 6, 2021 Posted March 6, 2021 itemPlus = itemPlus or 1; Where does the error occurs ?
India Posted March 6, 2021 Author Posted March 6, 2021 (edited) 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 Edited March 6, 2021 by India
India Posted March 6, 2021 Author Posted March 6, 2021 (edited) 2 minutes ago, Tekken said: Well what is the problem explain properly please? attempt to compare number with nil line starts in: if itemPlus > 0 then Edited March 6, 2021 by India
Tekken Posted March 6, 2021 Posted March 6, 2021 Replace itemPlus with (itemPlus or 0) if you want to ALWAYS be at least 1 replace the 0 with 1 That should do it 1
India Posted March 6, 2021 Author Posted March 6, 2021 3 minutes ago, Tekken said: Replace itemPlus with (itemPlus or 0) if you want to ALWAYS be at least 1 replace the 0 with 1 That should do it oh thanks, it works itemPlus = itemPlus or 1;
Tekken Posted March 6, 2021 Posted March 6, 2021 Exactly what I gave you from the beginning ! Glad I could help 1
sacr1ficez Posted March 6, 2021 Posted March 6, 2021 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. 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now