Frictional Games Forum (read-only)

Full Version: Unnexpected end of file error CONTINUES!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I made a post last time annnddd... The solution didn't work, now I got an error but at the very end of .hps file WICH IS NOT WRONG!
Code:
(59, 2) : ERR : Unexpected end of file
Code:
//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()
{

} <-(59, 2)
Help? Huh
try this:


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()
{

}
ShowPlayerCrosshairIcons(false);
(03-01-2014, 09:01 PM)davide32 Wrote: [ -> ]try this:


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()
{

}
I still get the error! HELP!?HuhSadAngry

(03-01-2014, 09:12 PM)Amn Wrote: [ -> ]ShowPlayerCrosshairIcons(false);
Nope still get it it says line (58, 2) unexpected end of file! HELP?! Angry
but some errors can stay in another line in hps file for example if the error is in 200 line and there're 10 script it can report the error on line 195 or in another line. It oroblably report the error in the same line where is the err.
Usually unexpected end of file, missing things, and extra things are SUPER hard to deal with because the error doesn't tell you where it's at. Instead it just shows you the lines OF THE ENTIRE SCRIPT.

Annoying.
Okay, on further analysis, on two occasions we have this:
PHP Code:
PlayMusic(inrto_cabin.oggfalse012false); 

NOT SURE if inrto_cabin.ogg is spelt incorrectly (for now I'll assume it is okay), but the problem is that it is a string value, so it must be enclosed in two quotation marks (").

Replace the two (one in OnStart and the other a few lines up from void UseKeyOnDoor) with these respectively:
PHP Code:
PlayMusic("inrto_cabin.ogg"false111false); 
PHP Code:
PlayMusic("inrto_cabin.ogg"false012false); 

You could also...
Spoiler below!

Just for the sake of coding, although that having the volume at 0 to make the music mute is okay, can also use this instead of the second PlayMusic:
PHP Code:
void StopMusic(float afFadeTimeint alPrio); 
Stops music.

afFadeTime - time in seconds until music stops
alPrio - the priority of the music that should stop


Edit: Oh and as Amn pointed out; in your OnStart(), you have forgotten the semi-colon at the end of this: ShowPlayerCrosshairIcons(false)
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:

Code:
//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()
{

}