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:
void valve_func1(string &in asEntity, int 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:
void OnEnter()
{
// You may want to consider naming your global variables to something more practical
if(GetGlobalVarInt("Globalvar1") == 1)
{
SetSwingDoorLocked("elevator_door_1", false, false);
}
}
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.