Frictional Games Forum (read-only)

Full Version: if statement isn't working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
Code:
void NoteRead(string &in asEntity, string &in asType)
{
    AddGlobalVarInt("SwitchBack", 1);
}
Then on the map that they're teleported to:
Code:
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.
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.
(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