Frictional Games Forum (read-only)

Full Version: Timer troubles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When you make a function inside of a function with a timer, I don't know how to write that correctly, please tell me how to fix?

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare_1", true, 1);
}
void Scare_1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "general_chain_rattle_single.snt", 0, false);
GiveSanityDamage(5.0f, true);
AddTimer("Timer_1", 4.0f, "looking");

void looking(string &in asTimer)
{
SetEntityActive("human_skull_1", true);
StartPlayerLookAt("human_skull_1", 6.0f, 7.0f, "");
GiveSanityDamage(5.0f, true);
}
Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "ScriptArea_1", "Scare_1", true, 1);
}

void Scare_1(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("", "general_chain_rattle_single.snt", 0, false);
    GiveSanityDamage(5.0f, true);
    AddTimer("Timer_1", 4.0f, "looking");
}

void looking(string &in asTimer)
{
    SetEntityActive("human_skull_1", true);
    StartPlayerLookAt("human_skull_1", 6.0f, 7.0f, "");
    GiveSanityDamage(5.0f, true);
}

You forgot a '}' after adding timer.
Ohh, I didn't think you needed a } after it, since more or less it is ONE function, (or one and a half).
(04-15-2011, 03:05 AM)evertuy Wrote: [ -> ]Ohh, I didn't think you needed a } after it, since more or less it is ONE function, (or one and a half).
No, it is 2 functions actually.. The timer calls a whole new function after x amount of seconds, it doesn't pause the script or something.