Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with Timers
ADrySoldier Offline
Junior Member

Posts: 1
Threads: 1
Joined: Oct 2014
Reputation: 0
#1
Trouble with Timers

So I have recently started to make a Custom Story, and everything was going great until I got to this one part in my .lang file. Here it is:

void OnStart()
{
}
AddEntityCollideCallback("Player", "ScriptArea_1", "BoardDoor", true, 1);
// Set Player to Sleeping Position
SetPlayerActive(false);
FadeOut(0.0f);
SetPlayerCrouching(true);
MovePlayerHeadPos(0, -0.75f, 0, 10, 0);
FadePlayerRollTo(37.75f, 10, 10);
// Ready Timer for Wake
AddTimer("Time1", 2.5f, "Wake");
}
}

void OnEnter()
{
PlayMusic("", true, 0.9, 1.0, 1, true);
}

void OnLeave()
{
StopMusic(1 , 1);
}

void Wake(string &in asTimer)
{
// string &in asTimer is always used when setting up a Timer Callback
// Set Player to a awoken position
FadeIn(0.7f);
FadePlayerRollTo(0.0f, 6.5, 7);
// Ready Timer for EventDoor
AddTimer("Time2", 5.0f, "EventDoor");
}

void EventDoor(string &in asTimer)
{
// Player looks at door, says Robbers! and gets up
StartPlayerLookAt("metal_1", 4.5f, 5, "");
SetMessage("Messages", "robbers", 3);
MovePlayerHeadPos(0, 0, 0, 4.5f, 3);
// Ready timer for Move
AddTimer("Move", 2.0f, "Move");
}

void Move(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
}

void BoardDoor(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
FadeOut(0.5f);
AddTimer("PlaySound", 1.5f, "PlaySound");
}

void PlaySound(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_2");
PlayGuiSound("15_hammer.snt", 100);
AddTimer("PlaySound2", 0.8f, "PlaySound2");
}

void PlaySound2(string &in asTimer)
{
PlayGuiSound("15_hammer.snt", 100);
AddTimer("PlaySound3", 0.8f, "PlaySound3");
}

void PlaySound3(string &in asTimer)
{
PlayGuiSound("15_hammer.snt", 100);
AddTimer("PlaySound4", 0.8f, "PlaySound4");
}

void PlayGuiSound4(string &in asTimer)
{
PlayGuiSound("15_hammer.snt", 100);
AddTimer("FadeIn", 0.5f, "FadeIn");
}

void FadeIn(string &in asTimer)
{
FadeIn(0.5f);
AddTimer("blockcade", 0.0f, "blockcade");
}

void blockcade(string &in asTimer)
{
SetEntityActive("cabinet_nice_2", true);
SetEntityActive("chair_wood02_2", true);
SetEntityActive("chair_wood02_3", true);
SetEntityActive("chair_wood02_1", true);
SetEntityActive("cabinet_nice_1", false);
SetEntityActive("shirt_hanging_white_1", true);
SetEntityActive("shirt_hanging_white_2", true);
AddTimer("Finish", 0.0f, "Finish");
}

void Finish(string &in asTimer)
{
SetMessage("Messages", "doneboards", 3);
AddTimer("LookUp", 2.0f, "LookUp");
}

void LookUp(string &in asTimer)
{
SetEntityActive("fallingrock", true);
AddEntityCollideCallback("fallingrock", "ScriptArea_2", "Faint", true, 1);
StartPlayerLookAt("fallingrock", 4.5f, 5, "");
}

void Faint(string &in asParent, string &in asChild, int alState)
{
FadeOut(0.3f);
StopPlayerLookAt();
}

After PlayGuiSound4 that the player is stuck there because of SetPlayerActive. It's supposed to show a barricade at the door at via the SetEntities but nothing happens and I am tearing my hair out looking it up online and seeing long since dead threads. I don't know what the problem is, and if it's even the timer. Please help.

Here's a picture of the CS I am working on:


.jpg   Concussion.jpg (Size: 47.5 KB / Downloads: 228)

I made a demo on ModDB but that was when I was first trying so it sucks majorly. This is a reboot that is a completely new idea with the same name. Thanks for looking.
(This post was last modified: 10-25-2014, 10:08 PM by ADrySoldier.)
10-25-2014, 08:13 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Trouble with Timers

Can I first say that I am surprised your code actually works:

PHP Code: (Select All)
void OnStart()
{
}
AddEntityCollideCallback("Player""ScriptArea_1""BoardDoor"true1);
// Set Player to Sleeping Position
SetPlayerActive(false);
FadeOut(0.0f);
SetPlayerCrouching(true);
MovePlayerHeadPos(0, -0.75f0100);
FadePlayerRollTo(37.75f1010);
// Ready Timer for Wake
AddTimer("Time1"2.5f"Wake");
}


On the third line, you have a closing brace which would close the OnStart(), and generate errors for the rest of that set of code there.

Edit: If you remove that closing brace, remove another at the bottom of the OnStart() area as well. If you do not fully understand, this is what your code should look like:

Spoiler below!
PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea_1""BoardDoor"true1);
// Set Player to Sleeping Position
SetPlayerActive(false);
FadeOut(0.0f);
SetPlayerCrouching(true);
MovePlayerHeadPos(0, -0.75f0100);
FadePlayerRollTo(37.75f1010);
// Ready Timer for Wake
AddTimer("Time1"2.5f"Wake");





Now, I do not think you can call timers at 0.0f. You CAN however change the two which happen instantly by changing 0.0f to 0.001f, which is practically instantaneous. Give that an attempt, otherwise I do not know exactly what is wrong. Perhaps I misread some syntax, but the game would return an error in that case.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 10-26-2014, 12:21 AM by Romulator.)
10-26-2014, 12:19 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Trouble with Timers

I do know you can call a timer with 0.0f as the time, however instead of doing
PHP Code: (Select All)
AddTimer("timer"0.0f"TimerFunc"); 
You might as well just do
PHP Code: (Select All)
TimerFunc("timer"); 
to call the timer function instantly.

10-26-2014, 01:51 AM
Find




Users browsing this thread: 1 Guest(s)