How to get variable, from another function?

Hey There , I’m trying to make new functions which will execute based on the other one,

I want to replace the tester, number Variable.

I would like to know how can i get, the return data “Success” from the QueryInventory function.

void UInventoryComponent_C::QueryInventory(TSubclassOf< class ACrafting_System > Item_Cata, int Qunantity, UInventoryComponent_C* Test, bool& Success, int& OutPut_Qunantity)
{
	for (auto& Elem : Test->YourMap)  //Here we iterate through the map, and find the Item/Key we are looking for, Check if the item exits, if it does then we increment the value of it
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Test"));
		if (Elem.Key == ■■■■■■■■■■■■■■■■ you
		{
			if (Qunantity>=Elem.Value && Item_Cata)
			{
				OutPut_Qunantity = Elem.Value;
				Success = true;
			}
		}

		else
		{
			OutPut_Qunantity = Elem.Value;
			Success = false;
		}
	}
	OutPut_Qunantity = 2;
	Success = true;
}

void UInventoryComponent_C::RemoveFromInventory(TSubclassOf<class ACrafting_System> Items_To_Be_Removed, int Qunantity, UInventoryComponent_C*Test, bool& Success)
{
	bool tester = true;
	int number = 1;
	QueryInventory(Items_To_Be_Removed, Qunantity, Test, tester, number);
}

Why don’t you make QueryInventory return boolean and just use it to whatever you like.

Because i need both an int and boolean output for that function, I only asked for the boolean bc i assumed if i can get help for that one, i can easily do the other one :slight_smile:

Then make a Struct containing int and bool, and function can return struct.

You can make bool and int params as out parameter. in header; you can declare function like this:

void MyFunc(int& MyIntParam, bool& bMyBoolParam);
(You have to validae this two input in this function.)

Whenver invoke this function:

int IntParam; bool bBoolParam;
MyClass->MyFunc(IntParam, bBoolParam).

There, you have two return values even the function have no return value.