FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
[SOLVED]Lever if-statements nearly working...
Yea so i have 4 levers (2 of them is combined in 1 script) So it is 3 scripts we are talking about.
Spoiler below!
void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_simple01_1", "PipeStart1_1");
SetEntityConnectionStateChangeCallback("lever_simple01_2", "PipeStart1_2");
SetEntityConnectionStateChangeCallback("lever_simple01_3", "PipeStart2_1");
SetEntityConnectionStateChangeCallback("lever_simple01_4", "PipeStart3_1");
}
///TIMERS
void MachineSoundTimer(string &in asTimer)
{
PlaySoundAtEntity("","13_machine_run.snt", "ScriptArea_2", 0, false);
}
///LEVERS
void PipeStart3_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_4", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_8", 0, false);
CreateParticleSystemAtEntity("Steam_5", "ps_steam.ps", "ScriptArea_7", true);
CreateParticleSystemAtEntity("Steam_6", "ps_steam.ps", "ScriptArea_8", true);
SetEntityActive("StickyArea_1", true);
}
else
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
void PipeStart2_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_3", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_6", 0, false);
CreateParticleSystemAtEntity("Steam_3", "ps_steam.ps", "ScriptArea_5", true);
CreateParticleSystemAtEntity("Steam_4", "ps_steam.ps", "ScriptArea_6", true);
SetEntityActive("StickyArea_2", true);
}
else
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true); PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
void PipeStart1_1(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("PipeStart1", 1);
SetLeverStuckState("lever_simple01_1", 1, true);
PlaySoundAtEntity("","13_press_done.snt", "pipes_thin_bend_short_9", 0, false);
CreateParticleSystemAtEntity("Steam_1", "ps_steam.ps", "ScriptArea_3", true);
if(GetLocalVarInt("PipeStart1") == 2)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_2", 0, false);
PlaySoundAtEntity("","13_machine_fail.snt", "ScriptArea_2", 0, false);
SetEntityActive("StickyArea_3", true);
}
else
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddDebugMessage("StartMachineSound", false);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}
void PipeStart1_2(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("PipeStart1", 1);
SetLeverStuckState("lever_simple01_2", 1, true);
PlaySoundAtEntity("","13_press_done.snt", "pipes_thin_bend_short_10", 0, false);
CreateParticleSystemAtEntity("Steam_2", "ps_steam.ps", "ScriptArea_4", true);
if(GetLocalVarInt("PipeStart1") == 2)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
PlaySoundAtEntity("","13_press_done.snt", "Player", 0, false);
PlaySoundAtEntity("","13_machine_fail.snt", "ScriptArea_2", 0, false);
SetEntityActive("StickyArea_3", true);
}
else
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddDebugMessage("StartMachineSound", false);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}
Everything works, except the
if(GetLocalVarInt("MachineStart") == 3) and beneath that.
The debug messages show that the LocalVarInt is at 3, (They say +1, 3 times), but no sound or particlesystems are getting active..
It used to work, but now it doesn't. There are no errors or anything.. Just nothing
Trying is the first step to success.