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
Script Help Unnexpected end of file error CONTINUES!
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#8
RE: Unnexpected end of file error CONTINUES!

Unexpected end of file happens when you have syntax error in your code. Basically, you opened something up (parentheses, for example) and didn't close it. Please observe the following basic rule:

typing a ( { " ' requires a corresponding ' " } ) to close it.
examples:
  • function( ... )
  • if { ... }
  • "..."
  • '...'

Everything that I can see at first glance:

line 8: ShowPlayerCrosshairIcons(false);
line 10: AddTimer("fadein", 3, "TimerInroOutro");
line 12: PlayMusic("inrto_cabin.ogg", false, 1, 1, 1, false);
line 27: AddTimer("fadein", 1, "TimerIntroOutro");
line 38: PlayMusic("inrto_cabin.ogg", false, 0, 1, 2, false);

Please use proper indentation to ensure code clarity. This is what my edited file looks like:

//This is only executed when the map is loaded for the first time. Only happens once. Can be used for adding effects that should not repeat.//
void OnStart()
{  
    AddUseItemCallback("", "key1", "frontdoor", "UseKeyOnDoor", true);
    FadeOut(0);
    SetPlayerActive(false);
    SetSanityDrainDisabled(true);
    ShowPlayerCrosshairIcons(false);

    AddTimer("fadein", 3, "TimerInroOutro");

    PlayMusic("inrto_cabin.ogg", false, 1, 1, 1, false);
}           //Missing brace

void TimerInroOutro(string &in asTimer)
{
    if(GetLocalVarInt("Intro") < 3) {

        if(asTimer == "fadein") {
            TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
            FadeIn(1);
            AddTimer("fadeout", 4, "TimerIntroOutro");
        }

        if(asTimer == "fadeout") {
            FadeOut(1);
            AddTimer("fadein", 1, "TimerIntroOutro");
            AddLocalVarInt(Intro, 1);
        }
        else
        {
            TeleportPlayer("Spawn");
            FadeIn(2);
            SetPlayerActive(true);
            SetSanityDrainDisabled(false);
            ShowPlayerCrosshairIcons(true);

            PlayMusic("inrto_cabin.ogg", false, 0, 1, 2, false);
        }
    }
}       //Missing brace

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("frontdoor", false, true);
    RemoveItem(asItem);
}

//This is executed every time you enter the level. Can be executed several times. Can be used for playing music and adding checks.//
void OnEnter()
{

}

//This is executed every time you leave the level. Can be executed several times. Can be used for stopping music//
void OnLeave()
{

}

(This post was last modified: 03-02-2014, 08:05 PM by Putmalk.)
03-02-2014, 07:59 PM
Find


Messages In This Thread
RE: Unnexpected end of file error CONTINUES! - by Putmalk - 03-02-2014, 07:59 PM



Users browsing this thread: 1 Guest(s)