Okay let's make an example.
First of all we will make a local variable called "EX".
The variable's default value, that is set by us at first will be 0, and then, after the player enters an area called "AREA", the function "FUNC" will be called, and the variable will be changed to any other value.
void OnEnter()
{
SetLocalVarInt("EX", 0); // 0 is the value we're giving to the var at first.
AddEntityCollideCallback("Player", "AREA", "FUNC", true, 1); //The area
}
Now we want to change the value of the variable if something happens, and then check it's value to do other things, example:
void FUNC(
string &in asEntity, int alState)
{
AddLocalVarInt("EX", 1); //Adding '1' to the variable's value.
}
Now we want to check the variable's value, and do something if it equals 1, else we'll do something else.
void AnyOtherFunctionYouHave()
{
if(GetLocalVarInt("EX") == 1) {
GiveSanityDamage(1.0f, true);
}
else
{
GiveSanityDamage(1.5f, true);
}
}
Okay, so what we did is, we've set an area in which the player will enter to, will set the variables "EX" value to '1' and then we checked in AnyOtherFunctionYouHave the variable's value, if it equals 1, the player will get 1 damage of sanity, else he will get 1.5 damage of sanity.