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


Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable help needed PLEASE :'(
X4anco Offline
Member

Posts: 157
Threads: 66
Joined: Apr 2011
Reputation: 0
#1
Bug  Variable help needed PLEASE :'(

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
//VARAIBLES
    AddLocalVarInt("door1", 0);
    //FUNCTIONS
    SetEntityPlayerInteractCallback("lever1", "used1", false);
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);
     }
}

...
(This post was last modified: 05-21-2011, 09:39 PM by X4anco.)
05-21-2011, 08:58 PM
Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#2
RE: Variable help needed PLEASE :'(

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.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
05-21-2011, 09:58 PM
Find
X4anco Offline
Member

Posts: 157
Threads: 66
Joined: Apr 2011
Reputation: 0
#3
RE: Variable help needed PLEASE :'(

(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?

...
05-21-2011, 10:03 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: Variable help needed PLEASE :'(

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.

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;
     }
}
}

(This post was last modified: 05-21-2011, 10:07 PM by Kyle.)
05-21-2011, 10:07 PM
Find
X4anco Offline
Member

Posts: 157
Threads: 66
Joined: Apr 2011
Reputation: 0
#5
RE: Variable help needed PLEASE :'(

(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.

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!

...
05-21-2011, 10:19 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: Variable help needed PLEASE :'(

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

05-22-2011, 12:31 AM
Find




Users browsing this thread: 1 Guest(s)