Frictional Games Forum (read-only)

Full Version: help with script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i tried to script something .. tell me please whats wrong with this script... when i start the map the game crash.
void OnStart()
{
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}
void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}
I don't see any problem. Is there a error message when it crashes?
yes this is what it says [Image: n4ztbhmwqmnd.png]
the error lies somewhere else. Paste the whole script file of the map "map2.hps"
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "hammer", "block", "breakwood", true);
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}

void breakwood (string &in asItem, string &in asEntity)
{
SetEntityActive("block",false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);

void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
SetEntityActive("rain",false);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
You had some misplaced brackets, this should be good:


////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "hammer", "block", "breakwood", true);
AddEntityCollideCallback("Player", "bookarea", "bookscare", true, 1);

}

void breakwood(string &in asItem, string &in asEntity)
{
SetEntityActive("block",false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);
}

void bookscare(string &in asParent, string &in asChild, int alState)
{
AddPropForce("book1", 31, 1, -19.25, "world");
SetEntityActive("light1",true);
SetEntityActive("light2",true);
SetEntityActive("mb_window_1",false);
SetEntityActive("mb_window_noglass_1",true);
SetEntityActive("rain",false);
PlaySoundAtEntity("", "break_glass_large", "mb_window_noglass_1", 0, false);
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
void breakwood (string &in asItem, string &in asEntity)
{
SetEntityActive("block", false);
PlaySoundAtEntity("", "break_wood", "mansion_1", 0, false);
GiveSanityBoost();
RemoveItem(asItem);

void bookscare(string &in asParent, string &in asChild, int alState)
the function "breakwood" has no closing bracket }
thank you , that works now