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
if statement isn't working
Spazatron Offline
Junior Member

Posts: 33
Threads: 17
Joined: Oct 2012
Reputation: 2
#1
if statement isn't working

I have a note that when you finish reading, teleports you to a new map. This is a map that the player will have already been in before, therefore I need to tell the script that the player is revisiting the map for the second time, and to execute a certain script, otherwise it'd just execute the script from when they were in the map before. So, I have this code when the player reads the note:
void NoteRead(string &in asEntity, string &in asType)
{
    AddGlobalVarInt("SwitchBack", 1);
}
Then on the map that they're teleported to:
void OnStart()
{
    if(GetGlobalVarInt("SwitchBack") == 1)
    {
         [script for second visit]
    }    
    else
    {
         [script for first visit]
    }
}
But when the map is loaded and the player teleports, neither of the codes are executed.
10-05-2014, 06:18 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#2
RE: if statement isn't working

Try using
SetGlobalVarInt("SwitchBack", 1);
instead.

EDIT:

NVM, you need to put the if statement in the OnEnter() Function instead, OnStart is only used the first time the level is started.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
(This post was last modified: 10-05-2014, 06:25 PM by Wapez.)
10-05-2014, 06:24 PM
Find
Spazatron Offline
Junior Member

Posts: 33
Threads: 17
Joined: Oct 2012
Reputation: 2
#3
RE: if statement isn't working

(10-05-2014, 06:24 PM)Wapez Wrote: Try using
SetGlobalVarInt("SwitchBack", 1);
instead.

EDIT:

NVM, you need to put the if statement in the OnEnter() Function instead, OnStart is only used the first time the level is started.

Thanks a lot Smile
10-05-2014, 07:18 PM
Find




Users browsing this thread: 1 Guest(s)