void OnStart()
{
for(int i = 1; i <= 3; i++) //this will loop the following line 3 times.
AddEntityCollideCallback("Book_"+i, "Area_"+i, "PullBook", false, 1);
//Adds callbacks for Book_1 and Area_1, and for 2 and 3.
}
void PullBook(string &in asParent, string &in asChild, int alState)
{
AddTimer("expire", 20.0f, "TimerExpired"); //Change time to how long it should last
//Add a PlaySoundAtEntity here
AddLocalVarInt("Books", 1); //This adds +1 to this variable for every book that collides with the area.
//Add something to make asParent not movable so that they dont cheat by
//using the same book several times to enter the area, like SetPropStaticPhysics
//or something better. Alternatively you can disable the area and reset it later.
if(GetLocalVarInt("Books") == 3) {
//This will complete the event, put your code here
RemoveTimer("expire");
//Run StopSound
}
}
void TimerExpired(string &in asTimer)
{
//This will reset the event because you ran out of time.
for(int i = 1; i <= 3; i++) ResetProp("Book_"+i);
SetLocalVarInt("Books", 0);//Resets the counter
//Run StopSound here.
//Run any additional resets here as well if you have any.
}