The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lever-Pulling Combination Help
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#1
Lever-Pulling Combination Help

I have been working on a script for a while and for some reason, it doesn't work the way I want it to work. The player is supposed to pull down 5 levers in a certain order and there are 2 combinations that they can use.

These are the levers: 1 2 3 4 5
Combinations: 4 5 2 1 3
5 1 3 2 4

I don't want the combinations to combine in a way. So this is my somewhat advanced script that should have taken care of it, but doesn't work, yet still can run:

void OnStart()
{
    SetLocalVarInt("Lever", 1);
    SetEntityConnectionStateChangeCallback("lever_simple01_22", "L1");
    SetEntityConnectionStateChangeCallback("lever_simple01_23", "L2");
    SetEntityConnectionStateChangeCallback("lever_simple01_24", "L3");
    SetEntityConnectionStateChangeCallback("lever_simple01_25", "L4");
    SetEntityConnectionStateChangeCallback("lever_simple01_26", "L5");
    Check();
}
void Check()
{
    if (GetLocalVarInt("Lever") == 6)
    {
        GiveSanityBoost();
        int x = RandInt(1, 2);
        if (x == 1)
        {
            SetSwingDoorLocked("castle_1", false, true);
            SetSwingDoorClosed("castle_1", false, true);
            return;
        }
        else if (x == 2)
        {
            SetSwingDoorLocked("castle_2", false, true);
            SetSwingDoorClosed("castle_2", false, true);
            return;
        }
    }
}
void L5(string &in asEntity, int alState)
{
    if (alState == 1)
    {
        if (GetLocalVarInt("Lever") == 4)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_26", true);
            return;
        }
        else if (GetLocalVarInt("Lever") == 3)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_26", true);
            return;
        }
        else if ((GetLocalVarInt("Lever") != 3) || (GetLocalVarInt("Lever") != 4))
        {
            SetLocalVarInt("Lever", 1);
            for (int i = 22; i <= 26 && i >= 22; i++)
            {
                SetEntityInteractionDisabled("lever_simple01_"+i, false);
            }
            return;
        }
    }
}
void L4(string &in asEntity, int alState)
{
    if (alState == 1)
    {
        if (GetLocalVarInt("Lever") == 1)
        {
            AddLocalVarInt("lever", 1);
            SetEntityInteractionDisabled("lever_simple_25", true);
            return;
        }
        else if (GetLocalVarInt("Lever") == 2)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_25", true);
            return;
        }
        else if ((GetLocalVarInt("Lever") != 1) || (GetLocalVarInt("Lever") != 2))
        {
            SetLocalVarInt("Lever", 1);
            for (int i = 22; i <= 26 && i >= 22; i++)
            {
                SetEntityInteractionDisabled("lever_simple01_"+i, false);
            }
            return;
        }
    }
}
void L3(string &in asEntity, int alState)
{
    if (alState == 1)
    {
        if (GetLocalVarInt("Lever") == 3)
        {
            AddLocalVarInt("lever", 1);
            SetEntityInteractionDisabled("lever_simple_24", true);
            return;
        }
        else if (GetLocalVarInt("Lever") == 2)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_24", true);
            return;
        }
        else if ((GetLocalVarInt("Lever") != 3) || (GetLocalVarInt("Lever") != 2))
        {
            SetLocalVarInt("Lever", 1);
            for (int i = 22; i <= 26 && i >= 22; i++)
            {
                SetEntityInteractionDisabled("lever_simple01_"+i, false);
            }
            return;
        }
    }
}
void L2(string &in asEntity, int alState)
{
    if (alState == 1)
    {
        if (GetLocalVarInt("Lever") == 1)
        {
            AddLocalVarInt("lever", 1);
            SetEntityInteractionDisabled("lever_simple_23", true);
            return;
        }
        else if (GetLocalVarInt("Lever") == 5)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_23", true);
            return;
        }
        else if ((GetLocalVarInt("Lever") != 1) || (GetLocalVarInt("Lever") != 5))
        {
            SetLocalVarInt("Lever", 1);
            for (int i = 22; i <= 26 && i >= 22; i++)
            {
                SetEntityInteractionDisabled("lever_simple01_"+i, false);
            }
            return;
        }
    }
}
void L1(string &in asEntity, int alState)
{
    if (alState == 1)
    {
        if (GetLocalVarInt("Lever") == 5)
        {
            AddLocalVarInt("lever", 1);
            SetEntityInteractionDisabled("lever_simple_22", true);
            return;
        }
        else if (GetLocalVarInt("Lever") == 4)
        {
            AddLocalVarInt("Lever", 1);
            SetEntityInteractionDisabled("lever_simple_22", true);
            return;
        }
        else if ((GetLocalVarInt("Lever") != 5) || (GetLocalVarInt("Lever") != 4))
        {
            SetLocalVarInt("Lever", 1);
            for (int i = 22; i <= 26 && i >= 22; i++)
            {
                SetEntityInteractionDisabled("lever_simple01_"+i, false);
            }
            return;
        }
    }
}

(This post was last modified: 05-01-2011, 11:34 PM by Kyle.)
05-01-2011, 11:32 PM
Find


Messages In This Thread
Lever-Pulling Combination Help - by Kyle - 05-01-2011, 11:32 PM
RE: Lever-Pulling Combination Help - by Kyle - 05-01-2011, 11:53 PM
RE: Lever-Pulling Combination Help - by Kyle - 05-02-2011, 12:13 AM



Users browsing this thread: 1 Guest(s)