Frictional Games Forum (read-only)
[Solved]Help i don't know how to use Timers - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: [Solved]Help i don't know how to use Timers (/thread-6920.html)



[Solved]Help i don't know how to use Timers - Danny Boy - 03-16-2011

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


RE: Help i don't know how to use Timers - Viperdream - 03-16-2011

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/tutorials/script/entihscript_beginner


RE: Help i don't know how to use Timers - Danny Boy - 03-17-2011

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();
}

}


RE: Help i don't know how to use Timers - Viperdream - 03-17-2011

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.


RE: Help i don't know how to use Timers - Danny Boy - 03-18-2011

Hey its works now thank you very much! Big Grin