Frictional Games Forum (read-only)
Variable help needed PLEASE :'( - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Variable help needed PLEASE :'( (/thread-8171.html)



Variable help needed PLEASE :'( - X4anco - 05-21-2011

Hello ,

I need help with a script -to do with variables, Ive never used them
before- and when the player interacts with a lever nothing happens when I want a message when door = 0 but nothing happens, I hope you can help Big Grin
Code:
//VARAIBLES
    AddLocalVarInt("door1", 0);
    //FUNCTIONS
    SetEntityPlayerInteractCallback("lever1", "used1", false);
Code:
void used1(string &in asParent, string &in asChild, int alState)
{
     if(GetGlobalVarInt("door1")==1)
    {
    SetSwingDoorLocked("metal_1", false, true);
    PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
    }
    else
    {
     PlayGuiSound("21/21_lever_fail.ogg", 1);
     SetMessage("Message", "mem8", 3);
     }
}



RE: Variable help needed PLEASE :'( - nemesis567 - 05-21-2011

You know that you don't need to declare the variables?

AddLocalVarInt("door1", 0); // This will add 0 to the door1 variable, which means that it will do nothing.


RE: Variable help needed PLEASE :'( - X4anco - 05-21-2011

(05-21-2011, 09:58 PM)nemesis567 Wrote: You know that you don't need to declare the variables?

AddLocalVarInt("door1", 0); // This will add 0 to the door1 variable, which means that it will do nothing.

What do you mean?


RE: Variable help needed PLEASE :'( - Kyle - 05-21-2011

Do you really need a global variable in this case?

In your "void OnStart()", you could add this: SetLocalVarInt("door1", 0);

Then the place where you set it to 1, put this: SetLocalVarInt("door1", 1); or AddLocalVarInt("door1", 1);

This is what the used1 function should look like.

Code:
void used1(string &in asParent, string &in asChild, int alState)
{
     if (GetLocalVarInt("door1") == 1)
     {
          SetSwingDoorLocked("metal_1", false, true);
          PlaySoundAtEntity("", "unlcok_door", "metal_1", 0, false);
          return;
     }
     else
     {
          PlayGuiSound("21/21_lever_fail.ogg", 1);
          SetMessage("Message", "mem8", 3);
          return;
     }
}
}


RE: Variable help needed PLEASE :'( - X4anco - 05-21-2011

(05-21-2011, 10:07 PM)Kyle Wrote: Do you really need a global variable in this case?

In your "void OnStart()", you could add this: SetLocalVarInt("door1", 0);

Then the place where you set it to 1, put this: SetLocalVarInt("door1", 1); or AddLocalVarInt("door1", 1);

This is what the used1 function should look like.

Code:
void used1(string &in asParent, string &in asChild, int alState)
{
     if (GetLocalVarInt("door1") == 1)
     {
          SetSwingDoorLocked("metal_1", false, true);
          PlaySoundAtEntity("", "unlcok_door", "metal_1", 0, false);
          return;
     }
     else
     {
          PlayGuiSound("21/21_lever_fail.ogg", 1);
          SetMessage("Message", "mem8", 3);
          return;
     }
}
}


Still nothing happens SD@Angry:R{AP!!!!!!
*feels like screaming!


RE: Variable help needed PLEASE :'( - Kyle - 05-22-2011

It should work. Maybe if you shown a little more of your script I can be able to fix it all. :/