05-06-2013, 05:13 PM
All right, I've been searching around for a code to unlock a door after a certain amount of time, but not really found what I was looking for.
Any ideas?
Any ideas?
void AddTimer(string& asName, float afTime, string& asFunction);
Creates a timer which calls a function when it expires.
Callback syntax: void MyFunc(string &in asTimer)
asName - the name of the timer
afTime - time in seconds
asFunction - the function to call
void Function()//Parameters would go here, depending on what called this function
{
//This function starts the timer
AddTimer("ExampleTimer",1.5f,"TimerCall");
//Name of timer, the time, and the callback
}
void TimerCall(string &in asTimer) //This function is called when the timer expires
{
//Do things here
}
In OnStart()
{
AddEntityCollideCallback("Player", "timer_area", "OpenDoor", true, -1);
}
void OpenDoor()
{
AddTimer("ExampleTimer",42f,"TimerCall");
}
void TimerCall(string &in asTimer)
{
SetSwingDoorClosed("hall_door", false, true);
}
void Function(string &in asParent, string &in asChild, int alState)
In OnStart()
{
AddEntityCollideCallback("Player", "timer_area", "OpenDoor", true, -1);
}
void OpenDoor(string &in asParent, string &in asChild, int alState)
{
AddTimer("ExampleTimer", 42.0f, "TimerCall");
}
void TimerCall(string &in asTimer)
{
SetSwingDoorClosed("hall_door", false, true);
}