Sign in to follow this  
Zakrepe

Please help me

Recommended Posts

Help me i get this error: attempt to perform arithmetic on a boolean value

addEventHandler("onClientGUIClick", inv.button[4], function()
    local value = ((getElementCurrentSlots(localPlayer)+getItemSlots(itemName)) - getElementMaxSlots(localPlayer))
	local value = tonumber( value )
	if value and value > 1 then
	local itemName = guiGridListGetItemText(inv.grid[1], guiGridListGetSelectedItem(inv.grid[1]), 1);
	if isPlayerInLoot() then
		if getElementData(isPlayerInLoot(), itemName) and getElementData(isPlayerInLoot(), itemName) >= value then
			if not isToolbeltItem(itemName) then
				if (getElementCurrentSlots(localPlayer)+getItemSlots(itemName) <= getElementMaxSlots(localPlayer)) then
					if not playerMovedInInventory then
						triggerEvent("onPlayerMoveItemInInventoryFast", localPlayer, itemName, isPlayerInLoot(),value);
						playerMovedInInventory = true;
						setTimer(function() playerMovedInInventory = false; end, 700, 1);
					else
						startRollMessage("You can't pick up items that fast!", 255, 22, 0);
						return;
					end 
				else
					triggerEvent("gs_notification_text",getLocalPlayer(),"error","Inventory is full!")
					return;
				end
			else
				playerMovedInInventory = true;
				setTimer(function() playerMovedInInventory = false end, 700, 1);
				triggerEvent("onPlayerMoveItemInInventoryFast", localPlayer, itemName, isPlayerInLoot(),value);
			end
		end
		if isPlayerInLoot() then
			setTimer(refreshInventory, 200, 2);
			setTimer(refreshLoot, 200, 2, getElementData(localPlayer, "currentCol"), guiGetText(inv.label[1]));
		end
	  end
	end
end);

 

Share this post


Link to post

AxDpVwL.png

 

 

I wanted to create a system that after clicking the button, it transfers the maximum amount of object that we can pick up.

Share this post


Link to post

1 of your functions[ getElementCurrentSlots, getItemSlots, getElementMaxSlots ] is returning false so debug them use iprint to check the values they return so you can find the culprit

Share this post


Link to post

I think bug line :     local value = (getElementCurrentSlots(LocalPlayer)+getItemSlots(itemName) - getElementMaxSlots(LocalPlayer))

And code now look that: 

addEventHandler("onClientGUIClick", inv.button[4], function()
    local itemName = guiGridListGetItemText(inv.grid[1], guiGridListGetSelectedItem(inv.grid[1]), 1);
    local value = (getElementCurrentSlots(LocalPlayer)+getItemSlots(itemName) - getElementMaxSlots(LocalPlayer))
    local value = tonumber( value )
    if isPlayerInLoot() then
	if (getElementData(isPlayerInLoot(), itemName) and getElementData(isPlayerInLoot(), itemName) >= value) then
            if not isToolbeltItem(itemName) then
                if (getElementCurrentSlots(localPlayer)+getItemSlots(itemName) <= getElementMaxSlots(localPlayer)) then
                    if not playerMovedInInventory then
                        triggerEvent("onPlayerMoveItemInInventoryFast", getLocalPlayer(), itemName, isPlayerInLoot(),value);
                        playerMovedInInventory = true;
                        setTimer(function() playerMovedInInventory = false; end, 700, 1);
                    else
                        startRollMessage("You can't pick up items that fast!", 255, 22, 0);
                        return;
                    end 
                else
                    triggerEvent("gs_notification_text",getLocalPlayer(),"error","Inventory is full!")
                    return;
                end
            else
                playerMovedInInventory = true;
                setTimer(function() playerMovedInInventory = false end, 700, 1);
                triggerEvent("onPlayerMoveItemInInventoryFast", getLocalPlayer(), itemName, isPlayerInLoot(),value);
            end
        end
        if isPlayerInLoot() then
            setTimer(refreshInventory, 200, 2);
            setTimer(refreshLoot, 200, 2, getElementData(localPlayer, "currentCol"), guiGetText(inv.label[1]));
        end
    end
end);

 

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.