Frictional Games Forum (read-only)

Full Version: [Solved]Help i don't know how to use Timers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Help i don't know how to use Timers!

CreateTimer(std:Confusedtring asName, float afTime, std:Confusedtring asCallback, bool abGlobal); i know this is the code but i simply do not know what:

asName... i have to give a name to the timer? or what this name is for?

asCallback... what is this?

abGlobal... its to put true or false right?

please help
Example:

I want a timer that activates when I enter the map

This is what I do:

Code:
void MonsterSpawnTimer(string &in asTimer)
//No need to put anything between the "()", put stuff between {} to let stuff happen
{
SetEntityActive("bigassmonster", true);
}
And then, because I want it from the start, I do this:
void OnStart()
{
AddTimer("Monster", 10.0f, "MonsterSpawnTimer");  
}
//The "Monster" is just a name, you can name it anything you want
//The "10.0f" means 10seconds. Float stands for float.
//"MonsterSpawnTimer" is the Timer I'm referring to.

If you still don't understand it, check this out:
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
well that does not work =/

i wanted to the player wend enters a area the door closes in a noise and creapy way, so the player looks behind him to see what happned... i wanted a timer to to make him stop looking at the door... and wend i have put the timer he does not look at the door eny more =/ what is the prob?

here is the code if it helps:

void OnStart()
{
AddEntityCollideCallback("Player", "ScaryAreaone", "CollideScaryArea", true, 1);
}
void CollideScaryArea(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("SuperDoor", true, true);
PlaySoundAtEntity("", "break_wood", "SuperDoor",0,false);
PlaySoundAtEntity("", "react_pant", "Player",0,false);
PlayGuiSound("insanity_monster_roar01.ogg", 1.0f);
GiveSanityDamage(25, true);
StartPlayerLookAt("SuperDoor", 7, 6, "");
AddTimer("Peek a Boo", 02.0f, "CollideScaryArea");
{
StopPlayerLookAt();
}

}
Code:
void CollideScaryArea(string &in asParent, string &in asChild, int alState)
{
    SetSwingDoorLocked("SuperDoor", true, true);
    PlaySoundAtEntity("", "break_wood", "SuperDoor",0,false);
    PlaySoundAtEntity("", "react_pant", "Player",0,false);
    PlayGuiSound("insanity_monster_roar01.ogg", 1.0f);
    GiveSanityDamage(25, true);
    StartPlayerLookAt("SuperDoor", 7, 6, "");
        AddTimer("Boo", 0.2f, "PeekaBooTimer"); //This only links to "PeekaBooTimer"
}    
void PeekaBooTimer(string &in asTimer)
//Put the stuff you want done in a seperate place, away from OnStart or any other stuff with void in front of it.
{
StopPlayerLookAt();
}
See what I did there? Don't put the stuff you want to get done in the AddTimer, since that only links to the timer you created.
Hey its works now thank you very much! Big Grin