void OnStart()
{
for(int i=1;i<=4;i++) AddUseItemCallback("Chem"+i, "GetAcidComplete", "UsedChemsOnPot", true, 0);
SetLocalVarInt("Var1", 0);
}
void UsedChemsOnPot(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("16_lever_stuck", 0.3f);
PlaySoundAtEntity("", "impact_metal_chain_med", "Player", 0.0f, false);
if("asParent" == "Chem1" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
}
else if("asParent" == "Chem2" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
}
else if("asParent" == "Chem3" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
}
else if("asParent" == "Chem4" && GetLocalVarInt("Var1") == 1)
{
AddLocalVarInt("Var1", 1);
}
if(GetLocalVarInt("Var1") == 4)
{
PlayMusic("26_event_agrippa_head.ogg", false, 0.7, 0.1, 10, false);
}
}
Several problems here
Firstly, the 'for' loop at the beginning of your script needs to be part of a function (it can't be loose in the script), for example OnStart like in my edited code above.
In the for loop, you start int i at 0, but you are running the loop whilst it is less than or equal to (<=) 4, which means it will run 5 times, so I changed it to 1 since you want to add the 1 to the names of the items. Also, in the last section of the for loop conditions you only had (i+), it needs to be (i++) which means (i + 1) in order to properly iterate.
I've added the SetLocalVarInt to OnStart, and changed all of the SetLocalVarInt's from within the if statements in 'UsedChemsOnPot', changed to AddLocalVarInt. The difference is that SetLocal...etc is telling the game "put the value of this variable to the number I specify", so it was constantly setting the value to 1, rather than
adding 1 to the value as I think you wanted to. AddLocalVarInt is telling the game "add the number I specify to this variable", so it starts at 0 then adds 1 each time a chemical is used, eventually ending at 4 which is enough for the final if statement to run.
In the future, this kind of thread should be created in the 'Development Support' sub-forum
Hope that works, let me know if your still getting problems with it.
EDIT: You changed it while I was writing
So, additionally, you need to not have "" around the conditions for the 'for' loop (conditions is the part in brackets)
You were also using too many braces '{}', you need to keep track of where the opening { and closing } are, so you don't include too many