Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If and else, need help!
Alento Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2012
Reputation: 0
#1
If and else, need help!

Hey all!

Look at this code:


void tangenterA(string &in asEntity)
{
PlaySoundAtEntity("", "pianoA.snt", "tangent_a",0, false );
AddLocalVarInt("tangent", 1);
AddTimer("Recheck", 0.1f, "CheckTangent");
}

void tangenterB(string &in asEntity)
{
PlaySoundAtEntity("", "pianoB.snt", "tangent_b",0, false );
SetEntityActive("wrong5", true);
ShowEnemyPlayerPosition("wrong5");
}

void tangenterC(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 1)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck2", 0.1f, "CheckTangent");
}
else if (GetLocalVarInt("tangent") == 0)
{
SetEntityActive("wrong1",true);
ShowEnemyPlayerPosition("wrong1");
SetPropHealth("blowdoor1", 0);
}

PlaySoundAtEntity("", "pianoC.snt", "tangent_c",0, false );

}

void tangenterD(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 2)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck3", 0.1f, "CheckTangent");

}
else if (GetLocalVarInt("tangent") == 0)
{
SetEntityActive("wrong2",true);
ShowEnemyPlayerPosition("wrong2");
SetPropHealth("blowdoor2", 0);

}
PlaySoundAtEntity("", "pianoD.snt", "tangent_d",0, false );
}

void tangenterE(string &in asEntity)
{
PlaySoundAtEntity("", "pianoE.snt", "tangent_e",0, false );
SetEntityActive("wrong3", true);
ShowEnemyPlayerPosition("wrong3");
SetPropHealth("blowdoor3", 0);
}

void tangenterF(string &in asEntity)
{
PlaySoundAtEntity("", "pianoF.snt", "tangent_f",0, false );
SetEntityActive("wrong4", true);
ShowEnemyPlayerPosition("wrong4");
SetPropHealth("musicdoor", 0);
}
You get what I want?
Okey, I've got x numbers of "tones", A,B,C,D,E and F.
What i want, is, when you hit A, you will get one var. and IF you have 1 var, and you hit C, you will get another, if you don't have 1 var when you hit C, monster will spawn, and same for D.

BUT, if you hit A,C and then D. You complete the task, and door will be unlocked.

this is like the doors are like:


void CheckTangent(string &in asTimer)
{
if (GetLocalVarInt("tangent") == 0)
{
SetSwingDoorLocked("DDoor1", true, true);
SetSwingDoorLocked("DDoor2", true, true);
SetSwingDoorLocked("DDoor3", true, true);
}
else if (GetLocalVarInt("Tangent") == 3)
{
SetSwingDoorLocked("DDoor1", false, true);
SetSwingDoorLocked("DDoor2", false, true);
SetSwingDoorLocked("DDoor3", false, true);
GiveSanityBoostSmall();
}
}
If something is blurry or something, let me know, and please help me, my brain is a mess right now....
Thanks! Smile

PS! "tangent" and "tangenter" is like "key" - piano keys in english.

---------Want help with YOUR Custom Story? ---------
http://www.frictionalgames.com/forum/user-19049.html
(This post was last modified: 09-08-2012, 02:30 AM by Alento.)
09-08-2012, 02:25 AM
Find
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#2
RE: If and else, need help!

What is blurry for me, is where the problem lies. Shouldn't it work by your scripting?

All I can recommend is that you change your script to the bold texts I've modified. Post any problems that arise.

void tangenterA(string &in asEntity)
{
if(GetLocalVarInt("tangent") == 0)
{

AddLocalVarInt("tangent", 1);
AddTimer("Recheck", 0.1f, "CheckTangent");
}
else if (GetLocalVarInt("tangent") != 0)
{
SetEntityActive("wrong0", true);
ShowEnemyPlayerPosition("wrong0");
}

PlaySoundAtEntity("", "pianoA.snt", "tangent_a",0, false );
}



void tangenterB(string &in asEntity)

{
PlaySoundAtEntity("", "pianoB.snt", "tangent_b",0, false );
SetEntityActive("wrong5", true);
ShowEnemyPlayerPosition("wrong5");
}



void tangenterC(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 1)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck2", 0.1f, "CheckTangent");
}
else if (GetLocalVarInt("tangent") != 1)
{
SetEntityActive("wrong1",true);
ShowEnemyPlayerPosition("wrong1");
SetPropHealth("blowdoor1", 0);
}
PlaySoundAtEntity("", "pianoC.snt", "tangent_c",0, false );
}



void tangenterD(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 2)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck3", 0.1f, "CheckTangent");
}
//could be changed to just a simple "else", since either you hit it on '2' or you don't.
else if (GetLocalVarInt("tangent") != 2)
{
SetEntityActive("wrong2",true);
ShowEnemyPlayerPosition("wrong2");
SetPropHealth("blowdoor2", 0);
}
PlaySoundAtEntity("", "pianoD.snt", "tangent_d",0, false );
}

void tangenterE(string &in asEntity)
{
PlaySoundAtEntity("", "pianoE.snt", "tangent_e",0, false );
SetEntityActive("wrong3", true);
ShowEnemyPlayerPosition("wrong3");
SetPropHealth("blowdoor3", 0);
}

void tangenterF(string &in asEntity)
{
PlaySoundAtEntity("", "pianoF.snt", "tangent_f",0, false );
SetEntityActive("wrong4", true);
ShowEnemyPlayerPosition("wrong4");
SetPropHealth("musicdoor", 0);
}

And btw, I didn't double check all the possible minor issues that might crash stuff, if that's your current problem.

As mentioned in a comment, you can also change the "else if (GetLocalVarInt("tangent") != 2)" (and all the other ones) to just "else".

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
(This post was last modified: 09-08-2012, 08:45 AM by Theforgot3n1.)
09-08-2012, 08:38 AM
Website Find
Alento Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2012
Reputation: 0
#3
RE: If and else, need help!

(09-08-2012, 08:38 AM)Theforgot3n1 Wrote: What is blurry for me, is where the problem lies. Shouldn't it work by your scripting?

All I can recommend is that you change your script to the bold texts I've modified. Post any problems that arise.

void tangenterA(string &in asEntity)
{
if(GetLocalVarInt("tangent") == 0)
{

AddLocalVarInt("tangent", 1);
AddTimer("Recheck", 0.1f, "CheckTangent");
}
else if (GetLocalVarInt("tangent") != 0)
{
SetEntityActive("wrong0", true);
ShowEnemyPlayerPosition("wrong0");
}

PlaySoundAtEntity("", "pianoA.snt", "tangent_a",0, false );
}



void tangenterB(string &in asEntity)

{
PlaySoundAtEntity("", "pianoB.snt", "tangent_b",0, false );
SetEntityActive("wrong5", true);
ShowEnemyPlayerPosition("wrong5");
}



void tangenterC(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 1)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck2", 0.1f, "CheckTangent");
}
else if (GetLocalVarInt("tangent") != 1)
{
SetEntityActive("wrong1",true);
ShowEnemyPlayerPosition("wrong1");
SetPropHealth("blowdoor1", 0);
}
PlaySoundAtEntity("", "pianoC.snt", "tangent_c",0, false );
}



void tangenterD(string &in asEntity)
{
if (GetLocalVarInt("tangent") == 2)
{
AddLocalVarInt("tangent", 1);
AddTimer("Recheck3", 0.1f, "CheckTangent");
}
//could be changed to just a simple "else", since either you hit it on '2' or you don't.
else if (GetLocalVarInt("tangent") != 2)
{
SetEntityActive("wrong2",true);
ShowEnemyPlayerPosition("wrong2");
SetPropHealth("blowdoor2", 0);
}
PlaySoundAtEntity("", "pianoD.snt", "tangent_d",0, false );
}

void tangenterE(string &in asEntity)
{
PlaySoundAtEntity("", "pianoE.snt", "tangent_e",0, false );
SetEntityActive("wrong3", true);
ShowEnemyPlayerPosition("wrong3");
SetPropHealth("blowdoor3", 0);
}

void tangenterF(string &in asEntity)
{
PlaySoundAtEntity("", "pianoF.snt", "tangent_f",0, false );
SetEntityActive("wrong4", true);
ShowEnemyPlayerPosition("wrong4");
SetPropHealth("musicdoor", 0);
}

And btw, I didn't double check all the possible minor issues that might crash stuff, if that's your current problem.

As mentioned in a comment, you can also change the "else if (GetLocalVarInt("tangent") != 2)" (and all the other ones) to just "else".
Oh, so you mean that my scripting is right?
Well I'm glad to hear that Big Grin but the doors won't open.. :/

*EDIT* I've got it now! Smile it works! Smile thanks for the help Smile

---------Want help with YOUR Custom Story? ---------
http://www.frictionalgames.com/forum/user-19049.html
(This post was last modified: 09-09-2012, 12:53 AM by Alento.)
09-08-2012, 11:38 PM
Find




Users browsing this thread: 1 Guest(s)