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
Doing nothing on an IF & Resetting level on death?
Nye Offline
Senior Member

Posts: 250
Threads: 8
Joined: Jan 2011
Reputation: 2
#2
RE: Doing nothing on an IF & Resetting level on death?

(02-10-2011, 11:43 PM)junkfood2121 Wrote: Well, I got two questions.

First one, if you got a script with an IF statement such as:
if(GetSwingDoorLocked("mansion_5") == true) SetMessage("Level_01", "GruntChaseLockedDoor", 0);
    else

If you don't want anything to happen on the ELSE, how do you stop the script?
I've heard that you can use a BREAK in some languages but I'm not too sure here.

And for my second question, as my friends die on my customs, (lol Big Grin) and like, a door is closed and locked, or a monster spawns and they have to redo from start, all things and events are already done. How do you make it so that they will become back to normal if you die? (If you have a checkpoint at one place, I don't want the events before that to get resetted)

Thanks in advance Smile

FIRST QUESTION:
----------------------

Just use empty curly brackets. Like this:

if(GetSwingDoorLocked("mansion_5") == true)
   {
SetMessage("Level_01", "GruntChaseLockedDoor", 0);
   }
else
   {
INSERT STUFF HERE
   }


If you want to leave the ELSE blank, you DON'T even need to include the ELSE. I know where you are coming from, having programmed in other languages. The language used for scripting here does not require you to use an ELSE, even if its blank Smile

The below code 'SHOULD' work fine:

if(GetSwingDoorLocked("mansion_5") == true)
   {
SetMessage("Level_01", "GruntChaseLockedDoor", 0);
   }

SECOND QUESTION:
-------------------------

If you are concerned about scripted events being undone, you will need to use local variables. (Local, meaning they are specific to just the current map and not the entire custom story, which are global variables).

When you trigger a scripted event, be sure to include the following line:

SetLocalVarInt(string& asName, int alVal);

For example, assume I lock a door named "door1" behind the player. I will use this code:

void OnStart()
{
   AddEntityCollideCallback("Player", "TRIGGERNAME", "DOOREVENT", false, 1); //<---SET TO FALSE, SO THE PROCEDURE CAN REPEAT!
   SetLocalVarInt("EVENTDONE", 0);
}

void DOOREVENT(string &in asParent , string &in asChild , int alState)
{  
   if(GetLocalVarInt("EVENTDONE") == 0)
    {
        SetLocalVarInt("EVENTDONE", 1);
        *blah blah, locking door etc.*
     }
}

Then, just add a point, eg. when the player spawns, where you set the "EVENTDONE" variable back to 0 again.

Hope this helped! Big Grin

(This post was last modified: 02-11-2011, 12:21 AM by Nye.)
02-11-2011, 12:12 AM
Find


Messages In This Thread
RE: Doing nothing on an IF & Resetting level on death? - by Nye - 02-11-2011, 12:12 AM



Users browsing this thread: 1 Guest(s)