Frictional Games Forum (read-only)

Full Version: Error in Script file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, i am very new to scripting and when i try to open my level i get this error:

FATAL ERROR:could not load script file (points to my script)

main (16,8) : ERR : Expected ´(´


Can someone explain what is wrong?

Code:
void OnStart()
{
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");
        SetPlayerLampOil(100.0f);
        
        for(int i = 0;i < 10;i++)
        {
            GiveItemFromFile("tinderbox", "tinderbox.ent");
        }
            {    
                AddUseItemCallback("", "key_tower_1", "mansion_1", "KeyOnDoor", true);
            }

        void KeyOnDoor(string &in asItem, string &in asEntity)
        {
        SetSwingDoorLocked("mansion_1", false, true);
        PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
        }
    }
}
You do not put methods (void bla bla) into other methods.
Read this: http://hpl2.frictionalgames.com/tutorial...t_beginner

Code:
void OnStart()
{
    if(ScriptDebugOn())
    {
        GiveItemFromFile("lantern", "lantern.ent");
        SetPlayerLampOil(100.0f);
        
        for(int i = 0;i < 10;i++)
        {
            GiveItemFromFile("tinderbox", "tinderbox.ent");
        }
    }

    AddUseItemCallback("", "key_tower_1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
        SetSwingDoorLocked("mansion_1", false, true);
        PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}
Thank you Pandemoneus, that was an easy fix Smile