Frictional Games Forum (read-only)

Full Version: Unexpected end of file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Uggh I knew I shouldn't have made alot of code and test it out later because the game is horrible at telling u where the problem is.

Code:
void OnStart()
{
    GiveItemFromFile("lantern", "lantern.ent");
    SetPlayerLampOil(0.0f);

    SetEntityInteractionDisabled("hatch_ceiling02_1", true);

    AddEntityCollideCallback("Player", "ScriptArea_1", "GustDoor", true, 1);    
    AddEntityCollideCallback("Player", "ScriptArea_2", "ScriptActivate", true, 1);    
    AddEntityCollideCallback("Player", "ScriptArea_3", "Pot", true, 1);    
    AddEntityCollideCallback("Player", "ScriptArea_5", "Ladder", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_8", "FakeScare", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_7", "Enemy1", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_10", "Enemy2", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_11", "Enemy3", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_12", "Enemy4", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_13", "Enemy5", true, 1);    
    
    AddUseItemCallback("Key1Unlock", "key_study_1", "hatch_metal01_1", "ScriptActivate2", true);
    AddUseItemCallback("Key2Unlock"", "key_tomb_rusty_1", "level_dungeon_1", "LeaveLevel", true);


    AddTimer("StartDoorShut", 0.6f, "DoorLock");    
}
void Intro()
{

}

void OnEnter()
{    
    PreloadParticleSystem("ps_dust_push");
}

void OnLeave()
{    

}

void DoorLock(string &in asTimer)
{
    PlaySoundAtEntity("Door", "close_gate.snt", "Player", 0, false);
    AddTimer("TimerGust", 1.3f, "DoorLock2");    
}

void DoorLock2(string &in asTimer)
{
    PlaySoundAtEntity("Door2", "lock_door.snt", "Player", 0, false);
}

//**************************************************************************************
void GustDoor(string &in asParent, string &in asChild, int alState)
{
    StartScreenShake(0.003f,0.25f, 1,1);
    
    PlaySoundAtEntity("gust_door", "general_wind_whirl.snt", "cellar_wood01_1", 1.0 / 3, false);
    
    CreateParticleSystemAtEntity("gust", "ps_dust_push", "GustArea", false);
    
    SetSwingDoorClosed("cellar_wood01_1", true, false);
    
    AddTimer("TimerGust", 0.1f, "Gust");
}

void Gust(string &in asTimer)
{
    PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0, false);
    PlaySoundAtEntity("creaking_door", "joint_door_move_special.snt", "cellar_wood01_1", 1.0 / 1.8f, false);
    
    GiveSanityDamage(5, true);
    
    StopSound("creaking_door", 0.4f);
}
//**************************************************************************************
void ScriptActivate(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("ScriptArea_3", true);
    PlaySoundAtEntity("scare1", "scare_whine_loop3.snt", "Player", 0, false);
    PlaySoundAtEntity("scare2", "scare_ghost.snt", "Player", 0, false);

    StartPlayerLookAt("ScriptArea_6", 6.0f, 8.0f, "");
    SetEntityActive("hanging_prisoner_1", true);
    PlayGuiSound("27_orb_implode.ogg", 1.0f);
    StartScreenShake(0.20f, 2, 0.1f, 1);
    CreateParticleSystemAtEntity("Wind", "ps_guardian_appear_explosion.ps", "ScriptArea_6", false);
    
    FadePlayerRollTo(-90, 30, 35);
    FadeOut(1.8f);
    
    SetLampLit("candlestick01_1", false, false);
    SetLampLit("candlestick_tri_1", false, false);
    
    FadeImageTrailTo(4, 5);
    FadeRadialBlurTo(0.45, 2);                
        
    StopSound("scare_whine_loop3.snt", 2.0f);
    StopSound("scare_ghost.snt", 2.0f);
    
    AddTimer("StopScare", 4.0f, "StopScare");
    AddTimer("FallSound", 0.4f, "FallSound");
    GiveSanityDamage(24, true);
    
    SetPlayerRunSpeedMul(0.0f);
    SetPlayerMoveSpeedMul(0.0f);
    SetPlayerLookSpeedMul(0.03f);
    SetPlayerCrouching(true);
    SetPlayerCrouchDisabled(true);
    SetPlayerJumpDisabled(true);
    SetInventoryDisabled(true);

}

void FallSound(string &in asTimer)
{
    PlayGuiSound("player_bodyfall.snt", 1.0f);
}

void StopScare(string &in asTimer)
{
    FadeIn(2.0f);
    SetEntityActive("hanging_prisoner_1", false);
    AddTimer("GetUp", 1.0f, "GetUp");
    FadeImageTrailTo(0, 1);
    FadeRadialBlurTo(0, 1);
    StopPlayerLookAt();    
}
void GetUp(string &in asTimer)
{
    SetPlayerRunSpeedMul(1.0f);
    SetPlayerMoveSpeedMul(1.0f);
    SetPlayerLookSpeedMul(1.00f);
    SetPlayerCrouchDisabled(false);
    SetPlayerJumpDisabled(false);
    SetInventoryDisabled(false);
    FadePlayerRollTo(0, 25, 30);
}

//**************************************************************************************
void Pot(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("vase_1", true);
    AddTimer("PotScareSound", 1.1f, "ScarePot");
}

void ScarePot(string &in asTimer)
{
    PlaySoundAtEntity("scare3", "react_scare1.ogg", "Player", 0, false);
    GiveSanityDamage(4, true);
}
//**************************************************************************************
void ScriptActivate2(string &in entity, string &in type)
{
    PlaySoundAtEntity("unlocksound", "unlock_door.snt", "Player", 0.0f, false);
    RemoveItem("key_study_1");
    SetMessage("Message", "KeyBroke", 0);
    SetEntityActive("ScriptArea_5", true);
}

void Ladder(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("dooropen", "door_safety_open.snt", "Player", 0, false);

    AddTimer("HatchOpen", 1.2f, "HatchOpen");
    AddTimer("HatchCloseSound", 1.2f, "HatchOpen");
    AddTimer("LadderCreate", 1.5f, "LadderCreate");
}

void HatchOpen(string &in asTimer)
{
    SetSwingDoorLocked("hatch_metal01_1", false, false);
    SetSwingDoorClosed("hatch_metal01_1", false, false);
    AddPropForce("hatch_metal01_1", 0, 0, 90, "World");
    AddPropImpulse("hatch_metal01_1", 0, 0, 90, "World");
}
void HatchCloseSound(string &in asTimer)
{
    PlaySoundAtEntity("doorclose", "door_level_wood_locked.snt", "Player", 0, false);
}

void LadderCreate(string &in asTimer)
{
    SetEntityActive("ladder_grab_1", true);
    SetEntityActive("LadderArea_1", true);
}
//**************************************************************************************
void FakeScare(string &in asParent, string &in asChild, int alState)
{
    AddPropImpulse("cabinet_simple_4", 0, 0, 15, "World");
    PlaySoundAtEntity("FakeCabinetBreak", "27_orb_implode.ogg", "Player", 0, false);
    StartScreenShake(0.45f, 2, 0.1f, 0.3f);
    DestroyParticleSystem("ParticleSystem_1");
}
//********************************************************************************************
void Key2(string &in entity, string &in type)
{
    PlaySoundAtEntity("GruntAlert", "amb_alert.snt", "Player", 0, false);
    SetEntityActive("ScriptArea_7", true);
    AddTimer("LookCloset", 1.0f, "LookCloset");
}

void LookCloset(string &in asTimer)
{
    StartPlayerLookAt("ScriptArea_9", 6.0f, 8.0f, "");
    PlaySoundAtEntity("GruntAlert", "amb_alert.snt", "Player", 0, false);
    AddTimer("ClosetParticle", 0.6f, "ClosetKnockKnock");
    PlayGuiSound("react_scare1.ogg", 1.0f);    
}
void ClosetKnockKnock(string &in asTimer)
{
    StopPlayerLookAt();    
    CreateParticleSystemAtEntity("KnockKnock!!!", "ps_hit_wood.ps", "KnockKnock", false);
}
//**************************************************************************************
void Enemy1(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorLocked("level_dungeon_1", false, true);
    AddPropImpulse("cabinet_simple_4", 0, 15, 0, "World");
    SetEntityActive("servant_grunt_1", true);
    ShowEnemyPlayerPosition("servant_grunt_1");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0.0f, "");    
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0.0f, "");    
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_14", 0.0f, "");    
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 0.0f, "");
    PlayMusic("10_event_coming.ogg", true, 15, 2, 0, true);
    SetEntityActive("ScriptArea_10", true);
    SetEntityActive("ScriptArea_11", true);
    SetEntityActive("ScriptArea_12", true);
    SetEntityActive("ScriptArea_13", true);
}

void Enemy2(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_2", true);
    ShowEnemyPlayerPosition("servant_grunt_2");
}

void Enemy3(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_4", true);
    ShowEnemyPlayerPosition("servant_grunt_4");
}

void Enemy4(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_3", true);
    ShowEnemyPlayerPosition("servant_grunt_3");
}

void Enemy5(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", true);
    ShowEnemyPlayerPosition("servant_brute_1");
}
//**************************************************************************************
void LeaveLevel(string &in entity, string &in type)
{
//    SetSwingDoorLocked("level_dungeon_1", false, true);
    PlaySoundAtEntity("UnlockDoorSound", "unlock_door.snt", "Player", 0, false);
}

I know its all my code and a big load of it, but it complains about the last line. This normally means I'm missing a "" or ; somewhere, but its terrible at telling u where the error is 98% of the time.

The part I was adding in was the
Code:
SetPlayerLampOil(0.0f);
Code:
AddEntityCollideCallback("Player", "ScriptArea_10", "Enemy2", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_11", "Enemy3", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_12", "Enemy4", true, 1);
    AddEntityCollideCallback("Player", "ScriptArea_13", "Enemy5", true, 1);"
at the top. And at the bottom
Code:
void Enemy2(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_2", true);
    ShowEnemyPlayerPosition("servant_grunt_2");
}

void Enemy3(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_4", true);
    ShowEnemyPlayerPosition("servant_grunt_4");
}

void Enemy4(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_3", true);
    ShowEnemyPlayerPosition("servant_grunt_3");
}

void Enemy5(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_brute_1", true);
    ShowEnemyPlayerPosition("servant_brute_1");
}

I tried taking huge chunks of code out temporarily to get a idea where the problem was, but I've remove almost half of it and it still gives me the same error "Unexpected end of the file".

One time it gave me a strange additional error talking about a script function from a different map??
It's alright, I'll find it. You should try to use Notepad++ it makes it a lot easier, but if you're already using it then... Wink

(This may take a few minutes...)

Edit:

(1 minute later...)

Line 20: AddUseItemCallback("Key2Unlock"", "key_tomb_rusty_1", "level_dungeon_1", "LeaveLevel", true);

You added an extra (").

Should be:

AddUseItemCallback("Key2Unlock", "key_tomb_rusty_1", "level_dungeon_1", "LeaveLevel", true);

There would probably be some more errors in there so once you're done fixing that up, tell me what it is if there is one. Tongue
THANK YOU.

Making errors in scripting drives me crazy and you can't find it >.<