Try using the function,
So, you would put
if(HasItem("lantern") == true
{
STUFF
}
if(HasItem("lantern") == false (or put != true)
{
STUFF
}
I have never done the above code, but it should work!
Second, you don't need to put anything inside the OnLeave() and OnEnter().
Although, inside the OnLeave(), I put sounds (eg. creepy whispers) and also specify the loading screen and text I want the player to load.
Here is an example from one of my scripts:
void OnEnter()
{
}
void OnLeave()
{
PlaySoundAtEntity("", "insanity_whisper.snt", "Player", 0.0f, true);
SetupLoadScreen("LoadingText", "catacombs", 0, "");
StopMusic(3.0f, 10);
}
Also, it's up to you what you do with the lantern check. Maybe it would be cooler if you entered the area, created a 'Block Box' entity and created a trigger in the darkness, just before the block box. Then, when the player collides with the trigger, if he has the lantern, the callback removes the block box ((SetEntityActive, "BlockBox", false)
. Else, it triggers a message telling the player that they should go back to get a lantern.
Finally, with regards to your sound question. ONLY use the level editor for repeated sounds (eg. waterfall streams, water drips, machine humming).
Every other sound, you should create triggers and use the PlaySoundAtEntity function to call. (Create a script area for the entity and place it where you want the sound source to be). Otherwise, the game will just play every single sound and it gets really buggy