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
Global Var Problem
TheGilgameshZocker Offline
Junior Member

Posts: 13
Threads: 11
Joined: Mar 2012
Reputation: 0
#1
Global Var Problem

Hi guys! I've got a problem with global vars. I have a map where you have to activate a lever, then the global var ("VarEle") should switch to 1 (activate an elevator). The script of the map (where the lever is):


void OnEnter()
{
SetEntityConnectionStateChangeCallback("lever1", "func_piston");
}


void func_piston(string &in asEntity, int alState)
{
if (alState == 1)
{
AddGlobalVarInt("VarEle", 1);
SetMoveObjectStateExt("Entity_Piston", 0.6, 0.6, 8, 0, false);
PlaySoundAtEntity("", "move_gate.snt", "Entity_Piston", 0, false);
return;
}
}

So, the var should effect an elevator to switch the map (fade out and change map). The script of the other map (where the elevator is):

void OnEnter()

{
CreateParticleSystemAtEntity("FountainPourBlood", "ps_childsnake_blood_stream.ps", "ScriptArea_1", true);
CreateParticleSystemAtEntity("FountainPourBlood", "ps_childsnake_blood_stream.ps", "ScriptArea_2", true);
PlayMusic("02_amb_safe.ogg", true, 5.0f, 0.7f, 10, true);
if (GetGlobalVarInt("VarEle")== 1)
{
SetEntityConnectionStateChangeCallback("elevator_lever_2", "activate_attic");
}
}

void activate_attic(string &in asEntity, int alState)
{
if (alState == 1)
{
FadeOut(3);
ChangeMap("attic.map", "PlayerStartArea_1", "", "");
}
}

void OnLeave()
{
StopMusic(0,0);
}

The main problem is that if I pull the lever down, nothing happens. Please correct me, if you know a way to solve this problem Wink
07-05-2012, 05:36 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#2
RE: Global Var Problem

what is the return; for? I don't see any need of it.
So, you mean by nothing happens, even no sound plays?
Edit: I think you should go for this:
Use SetGlobalVarInt instead of AddGlobalVarInt.
Also, Set the variable to 0 in OnStart() at the first map first.

Think, before you speak Google, before you post
(This post was last modified: 07-05-2012, 06:30 PM by Cruzore.)
07-05-2012, 06:25 PM
Find




Users browsing this thread: 2 Guest(s)