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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Global Variables
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: Help with Global Variables

You don't need a global.hps for global map variables to work. The issue here is that the code logic is wrong. This is the kind of scenario where OnEnter() comes in to play. You appear to have the same func_on function in both maps when it isn't required in any. The goal you're showing me is simple: you want a certain door to be unlocked when the user interacts with a valve in another map.

You've done right by trying to set a global map variable within the connection state chage callback, but that is pretty much all that was needed for the connection state change callback. Therefore the valve_func1 function should look something like this:
PHP Code: (Select All)
void valve_func1(string &in asEntityint alState)
{
    
// You may want to consider alState somewhere in here
    
AddLocalVarInt("Var1"1); // not sure what this is for, but i'll leave it
    // We SET a global map variable here, because ADDing to the variable may cause problems
    
SetGlobalVarInt("Globalvar1"1);
    
// You may want to consider naming your global variables to something more practical


Next you're going to want to remove the func01 function from your scripts, as they are not needed. In your OnEnter function you'll be checking if the global map variable has been set, and if it is set, unlock the door. Therefore make sure your OnEnter function looks something like this:
PHP Code: (Select All)
void OnEnter()
{
    
// You may want to consider naming your global variables to something more practical
    
if(GetGlobalVarInt("Globalvar1") == 1)
    {
        
SetSwingDoorLocked("elevator_door_1"falsefalse);
    }


Since you didn't clearly specify which map contains the elevator door, i'm going to leave you to put this for the map that contains the elevator door.

One final thing i need to mention: All map variables by default equate to 0, at least the ones that deal with numbers (strings would be an empty string). Therefore there is no need to set a global or local map variable to 0 in OnStart (or anywhere else), that is, unless they are not currently at 0 and you want to reset the value.

Tutorials: From Noob to Pro
(This post was last modified: 12-01-2011, 11:58 PM by Your Computer.)
12-01-2011, 11:56 PM
Website Find


Messages In This Thread
Help with Global Variables - by flamez3 - 12-01-2011, 08:36 AM
RE: Help with Global Variables - by Obliviator27 - 12-01-2011, 09:05 AM
RE: Help with Global Variables - by flamez3 - 12-01-2011, 09:13 AM
RE: Help with Global Variables - by Obliviator27 - 12-01-2011, 09:16 AM
RE: Help with Global Variables - by Your Computer - 12-01-2011, 11:56 PM



Users browsing this thread: 1 Guest(s)