Frictional Games Forum (read-only)

Full Version: Timers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Frictional!


I am trying to zoom in the FOV of player for 4 seconds, then back out after 4 seconds.
This is literally my first go at timers, hopefully I was somewhere close, please correct me if you can!

My script:


oid OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);

void FadePlayerFOVMulTo(string &in timer_name)
{
if (timer_name == "FOV")
{
FadePlayerFOVMulTo(0.5, 2);
SetPlayerActive(false);
AddTimer("Normal1", 4, "FadePlayerFOVMulTo");
}
else if (timer_name == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}

Bold is what I'm talking about
void OnPickup()
string &in asTimer
Ah, sorry, I do have a V in void. But,
SetEntityCallbackFunc("key_study_1", "OnPickup");


Is my script in the OnStart. I picking up a key, then ZOOM in for 4 seconds, then back out.

So I think the
void OnPickup(string &in asEntity, string &in type) still works.


Do I need to AddTimer in the OnStart?

Oh I see what you meant.

I tried that, no luck, I still get a "unexpected end of file". And the area where it says its wrong is lines 2 and 79, and thats the very start and end of the hps.

It must be something else..

(08-10-2012, 06:53 PM)TheIcyPickle Wrote: [ -> ]Ah, sorry, I do have a V in void. But,
SetEntityCallbackFunc("key_study_1", "OnPickup");


Is my script in the OnStart. I picking up a key, then ZOOM in for 4 seconds, then back out.

So I think the
void OnPickup(string &in asEntity, string &in type) still works.


Do I need to AddTimer in the OnStart?

Oh I see what you meant.

I tried that, no luck, I still get a "unexpected end of file". And the area where it says its wrong is lines 2 and 79, and thats the very start and end of the hps.

It must be something else..
Here is my script once more

void OnStart()
{
SetEntityCallbackFunc("key_study_1", "OnPickup");

}



void OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);

void FadePlayerFOVMulTo(string &in asTimer)
{
if (timer_name == "FOV")
{
FadePlayerFOVMulTo(0.5, 2);
SetPlayerActive(false);
AddTimer("Normal1", 4, "FadePlayerFOVMulTo");
}
else if (timer_name == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}
}
you forgot the } from:
void OnPickup(string &in asEntity, string &in type)
so make it:

void OnPickup(string &in asEntity, string &in type)
{
SetMessage("Messages", "noise", 4.0);
AddTimer("FOV", 0, "FadePlayerFOVMulTo");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25, false);
}
Thank you steve, I have done that, and now, I get errors which are more understandable.
Which is a good thing Smile

It seems to not like where I say

if timer_name == ("x")


It says that the name is not set and it must be of "boolean type"
Quick question:

Judging by the sound effects you're using and the FOV change, are you trying to simulate the sanity damage effect used in game?

Anyways, this script should give you no errors at all:


void OnStart()
{
SetEntityPlayerInteractCallback("key_study_1", "OnPickup", true);
}

void OnPickup(string &in asEntity)
{
SetMessage("Messages", "noise", 4.0f);
AddTimer("FOV", 0, "ChangeFOV");
AddTimer("Normal1", 4, "ChangeFOV");
PlaySoundAtEntity("", "enemy_hallucination_disappear.snt", "Player", 0, false);
GiveSanityDamage(25.0f, false);
}

void ChangeFOV(string &in asTimer)
{
if(asTimer == "FOV")
{
FadePlayerFOVMulTo(0.5f, 2);
SetPlayerActive(false);
}
if(asTimer == "Normal1")
{
FadePlayerFOVMulTo(1, 2);
SetPlayerActive(true);
}
}
Andy, what would I do without you?
lol

Thanks for all the help guys, I think I did ok at my first go at timers. hehe