Frictional Games Forum (read-only)
[SCRIPT] "if" script doesn't work - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] "if" script doesn't work (/thread-17811.html)



"if" script doesn't work - ooadrianoo - 08-16-2012

This is my first "if" script and I don't know why it doesn't work.
Code:
void monsterbreakdoor(string &in asTimer)
{
if (GetSwingDoorClosed("cellar_wood01_5") == true)
{
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "ScriptArea_53", false);
SetEntityActive("servant_grunt_3", true);
SetEntityActive("cellar_wood01_broken_2", true);
SetEntityActive("cellar_wood01_5", false);
PlaySoundAtEntity("", "break_wood.snt.snt", "ScriptArea_53", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_impact.ps", "ScriptArea_53", false);
ShowEnemyPlayerPosition("servant_grunt_3");
}

else
{ if(GetSwingDoorClosed("cellar_wood01_5") == false)
{
SetEntityActive("ScriptArea_54", true);
}
}
}

If the door will be open, there shouldn't be door breaking effects and an area should be true. On the other side the door should be breaking.
But both is happening. Why?


RE: "if" script doesn't work - Adny - 08-16-2012

void monsterbreakdoor(string &in asTimer)
{
if(GetSwingDoorClosed("cellar_wood01_5") == true)
{
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "ScriptArea_53", false);
SetEntityActive("servant_grunt_3", true);
SetEntityActive("cellar_wood01_broken_2", true);
SetEntityActive("cellar_wood01_5", false);
PlaySoundAtEntity("", "break_wood.snt.snt", "ScriptArea_53", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_impact.ps", "ScriptArea_53", false);
ShowEnemyPlayerPosition("servant_grunt_3");
}

if(GetSwingDoorClosed("cellar_wood01_5") == false)
{
SetEntityActive("ScriptArea_54", true);
}
}

This should work; you had a few extra brackets and the organization was a bit off. If this doesn't solve your problem, please post the full hps file.


RE: "if" script doesn't work - GoranGaming - 08-16-2012

Or:

void monsterbreakdoor(string &in asTimer)
{
if(GetSwingDoorClosed("cellar_wood01_5") == true){

CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "ScriptArea_53", false);
SetEntityActive("servant_grunt_3", true);
SetEntityActive("cellar_wood01_broken_2", true);
SetEntityActive("cellar_wood01_5", false);
PlaySoundAtEntity("", "break_wood.snt.snt", "ScriptArea_53", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_impact.ps", "ScriptArea_53", false);
ShowEnemyPlayerPosition("servant_grunt_3");
}else if(GetSwingDoorClosed("cellar_wood01_5") == false){

SetEntityActive("ScriptArea_54", true);
}
}