Hi everyone looking for help with the following command
I'm making a game that one character collects one Item , say a gun and another character collects a item , say a Axe.
This is what i'm trying to do but get a error.
this is the scrip.
function room_RepExec()
{
if (cEGO.InventoryQuantity[iGUN.ID]==1){ && if (cJOE.InventoryQuantity[iAXE.ID]==1){
gPUZ1.Visible = true;
}
else
gPUZ1.Visible = false;
}
}
=======================================
I know you can do this with Objects like
if (ocup.Visible == true && ojug.Visible == true){
is there anyway you can do the same but for character ?.
Thank you and hope someone can help with this.
Stevo2024
You simply have a wrong syntax, you should use the same syntax as you did with your objects example:
if (cEGO.InventoryQuantity[iGUN.ID]==1 && cJOE.InventoryQuantity[iAXE.ID]==1){
On another hand, if you really need two separate "ifs", then you should make a nested structure, without any "&&" in between:
if (cEGO.InventoryQuantity[iGUN.ID]==1){
if (cJOE.InventoryQuantity[iAXE.ID]==1){
// do something here
}
}
Note that a term like oCup.Visible == true is redundant; AGS does not read this like a human would, it simply calculates the result. Therefore, oCup.Visible == true is the exact same as oCup.Visible.
In other words, you can do
gPUZ1.Visible = cEGO.HasInventory(iGUN) && cJOE.HasInventory(iAXE);