Now i think i got it.
It seems to work correctly.
Code:
void OnEnter()
{
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);
}
void OnStart()
{
for (int i = 0; i < 10; i++)
{
AddEntityCollideCallback("Player" , "ScriptArea_" + 0 + i , "InArea" , false , 1);
}
for (int i = 11; i < 20; i++)
{
for (int j = 1; j < 5; j++)
AddEntityCollideCallback("Player" , "ScriptArea_" + i + "." + j, "FadeOut1" , false , 1);
}
SetSanityDrainDisabled(true);
AddEntityCollideCallback("Player" , "Music2" , "secondmusic" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_1" , "Slender1" , true , 1);
AddEntityCollideCallback("Player" , "activeslendy_2" , "Slender2" , true , 1);
}
bool IsInArea = false;
bool Slender_1active = false;
bool Slender_2active = false;
string Slender_active = "000000000";
string LastArea = "00";
void secondmusic (string &in asParent, string &in asChild, int alState)
{
StopMusic(0.0f, 1);
PlayMusic("Slender 2.ogg", true, 1.0f, 0.0f, 2, true);
}
void Slender1 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_1", true);
Slender_active = "1" + StringSub(Slender_active, 1, 8);
AddDebugMessage("active", false);
AddDebugMessage(Slender_active, false);
}
void Slender2 (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Slender_2", true);
Slender_active = StringSub(Slender_active, 0, 1) + "1" + StringSub(Slender_active, 2, 7);
AddDebugMessage("active2", false);
AddDebugMessage(Slender_active, false);
}
void InArea(string &in asParent, string &in asChild, int alState)
{
string areanumber1 = StringSub(asChild, 11, 2);
int i;
i = (areanumber1[0] -48) *10 + areanumber1[1] -48;
AddDebugMessage(Slender_active, false);
if (Slender_active[i-1] == 1 + 48)
{
AddDebugMessage("InArea > if statement executing", false);
IsInArea = true;
LastArea = areanumber1;
AddTimer("Dead", 2, "Dead");
}
}
void Dead(string &in asTimer)
{
if(IsInArea == true)
{
FadeOut(0.3);
SetPlayerHealth(0);
}
}
void FadeOut1(string &in asParent, string &in asChild, int alState)
{
IsInArea = false;
string areanumber2 = StringSub(asChild, 11, 2);
int i1, i2;
i2 = (areanumber2[0] - 48) *10 + areanumber2[1] -48;
i1 = (LastArea[0] - 48) *10 + LastArea[1] -48;
AddDebugMessage("i1 =" + i1, false);
AddDebugMessage("i2 =" + i2, false);
if(i1 == i2 - 10)
{
//FadeOut
AddDebugMessage("fade", false);
LastArea = areanumber2;
}
}
I think its done.