CarnivorousJelly
Posting Freak
Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation:
80
|
RE: So many errors
(02-11-2013, 08:55 PM)Adrianis Wrote: You'll get there, if you take the time to break down the problems and code them bit by bit.
However, since you want to actually re-set the timers if they leave the area (rather than just make them invalid when they expire), we should do things slightly differently.
void OnStart()
{
AddEntityCollideCallback("Player", "Area_VisionTrigger", "Script_VisionTrigger", false, 0);
[b]SetLocalVarInt("HasWindPlayed", 0) // setup for use in Script_VisionTrigger[/b]
}
void Script_VisionTrigger (string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
PlayMusic("vision_music", true, 1, 6, 7, false); // this is to happen every time
[b]if (GetLocalVarInt("HasWindPlayed") == 0) // wind stuff happens first time only
{[/b]
CreateParticleSystemAtEntity("Area_VisionWind", "ps_dust_whirl.ps", "Area_VisionWind", false);
SetLampLit("candlestick_floor_1", false, true);
SetLampLit("candle_floor_small_1", false, true);
PlaySoundAtEntity("blow", "general_wind_whirl", "Player", 0.0f, false);
[b]SetLocalVarInt("HasWindPlayed", 1);
} [/b]
AddTimer("fadescreen", 18.1f, "timer_fade");
AddTimer("visionstarter", 19.2f, "timer_vision_start");
AddTimer("visionender", 203.53f, "timer_vision_end");
SetLocalVarInt("IsPlayerInArea", 1); // where 1 is yes and 0 is no
}
if(alState == -1)
{
StopMusic(3, 7);
[b]RemoveTimer("fadescreen");
RemoveTimer("visionstarter");
RemoveTimer("visionender");[/b]
SetLocalVarInt("IsPlayerInArea", 0); // where 1 is yes and 0 is no
}
}
void Potential_Timer_Function(string &in strTimer)
{
if (GetLocalVarInt("IsPlayerInArea") == 1)
{
// do the stuff
[b]SetEntityActive("Area_VisionTrigger", false); // this will deactivate the trigger area[/b]
}
}
Decided to keep the variables for checking if you are in / out of the area, despite the fact that with the RemoveTimers they are not so important, but a nice extra layer of security never hurt
EDIT: Ninja'd, but still useful i hope
Very useful  If you don't mind, could you explain how this code would be used?
void FadeOut(float afTime);
I have a general grasp on where I should put it in the whole script, but no idea what "float" or "afTime" would actually look like in the script. Unfortunately, staring at 00_rainy_hall.hps didn't help me much other than figuring out how to teleport the player (thankfully, I have the teleport part working).
![[Image: quote_by_rueppells_fox-d9ciupp.png]](http://orig14.deviantart.net/d9d5/f/2015/282/5/9/quote_by_rueppells_fox-d9ciupp.png)
|
|