Modme Forums

Checking if a trigger has been used, Scripting.

Game Modding | Call of Duty: Black Ops 3 | Scripting


369:

Hello,

So i don't quite understand how if statements can be used, if i got it correctly a if statement always needs to recall a variable, which is made out of a true or false statement.
Then my qeustion is, how do you define the true or false if that makes any sense. For example, i want the if statement to check if a trigger has been used, and then run the code.

I'm a total scrub in scripting, any help is greatly appreciated!


function darkmodetorch()
{
    monkeyt1 = GetEnt("monkey1", "targetname");
    monkeyt1 SetHintString("Find Flashlight First");
    monkeyt1 SetCursorHint("HINT_NOICON");
   
    level waittill("power_on");

    while(1)
    {
        monkeyt1 SetHintString("Extra Spooky");
        monkeyt1 SetCursorHint("HINT_NOICON");
        monkeyt1 waittill("trigger", player);

        level util::set_lighting_state(3);
        wait 0.05;

        monkeyt1 SetHintString("");
        monkeyt1 SetCursorHint("HINT_NOICON");


        if level.monkeyt2 ("trigger", player);  [This code is what i want the if statement to check.]
        {
            monkeyt1 SetHintString("Extra Spooky");
            monkeyt1 SetCursorHint("HINT_NOICON");
        }
        else level.monkeyt2 ("trigger", player); [Same with this one, i guess?]
        {

            monkeyt1 SetHintString("Extra Spooky");
            monkeyt1 SetCursorHint("HINT_NOICON");
        }

    }
}


Spiki:

monkeyt1 waittill("trigger", player);


369:

monkeyt1 waittill("trigger", player);

Doesn't a waittill stop the rest of the code from running? Will give it a try in a few.
For some clarification, i got 2 lightswitches, i want one to say that its off when the other is turned on and vice versa.


Spiki:

Doesn't a waittill stop the rest of the code from running? Will give it a try in a few.
For some clarification, i got 2 lightswitches, i want one to say that its off when the other is turned on and vice versa.

It does stop the code but you cant check for trigger another way, atleast on a noob level

This should do it. Never tested.
function lightswitches()
{
monkeyt1 = GetEnt("monkey1", "targetname");
monkeyt2 = GetEnt("monkey2", "targetname");


monkeyt1 SetHintString("Find Flashlight First");
monkeyt1 SetCursorHint("HINT_NOICON");
monkeyt2 SetHintString("Find Flashlight First");
monkeyt2 SetCursorHint("HINT_NOICON");

level waittill("power_on");

monkeyt1 thread setup_lightswitch(monkeyt2);
monkeyt2 thread setup_lightswitch(monkeyt1);


}


function setup_lightswitch(other_switch) //self = switch trigger
{
if(!isdefined(self))
    IPrintLnBold("Oopsie: Switch doesn't exist");

while(1)
    {
    self waittill("trigger", player);
    self SetHintString("Switch on");
    other_switch SetHintString("Switch off");
    }

}


369:

This should do it. Never tested.


Thank you alot , it works great. But i have to switch through 3 lightstates, so i don't think i could implement that in that code. I'll just keep it simple. I will use this code in a simple elevator though, last time i tried i couldn't get it to work vice versa so major thanks man!


Spiki:

Thank you alot , it works great. But i have to switch through 3 lightstates, so i don't think i could implement that in that code. I'll just keep it simple. I will use this code in a simple elevator though, last time i tried i couldn't get it to work vice versa so major thanks man!

like so
function setup_lightswitch(other_switch) //self = switch trigger
{
if(!isdefined(self))
    IPrintLnBold("Oopsie: Switch doesn't exist");

while(1)
    {
    self waittill("trigger", player);
    self SetHintString("Switch on");
    other_switch SetHintString("Switch off");

    if(self == GetEnt("monkey1", "targetname"))
        level SetLightingState(1);
    else
        level SetLightingState(2);
       
    }

}


369:

like so
if(self == GetEnt("monkey1", "targetname"))
        level SetLightingState(1);
    else
        level SetLightingState(2);
     
    }

}

Thank you SOO much man. This just doubled my possibilities haha. I've made the code but i keep getting a syntax error now. I have no clue why, also not sure if it will work in the first place since i done a couple things like threading function within functions? I suck at explaining.


369:

function setup_lightswitch(other_switch) //self = switch trigger
{
if(!isdefined(self))
    IPrintLnBold("Oopsie: Switch doesn't exist");

while(1)
    {

    monkeyt1 SetHintString("Spooky Mode");
    monkeyt2 SetHintString("");

    monkeyt1 waittill("trigger", player);

    level util::set_lighting_state(2);

    monkeyt1 SetHintString("Aziz, Light!")
    monkeyt2 SetHintString("Extra Spooky Mode");  <--- This line is the 194th

    self waittill("trigger", player);

    self thread setup_lightswitch3();

    monkeyt1 thread setup_lightswitch3();

    self waittill("trigger", player);

    if(self == GetEnt("monkey", "targetname"))
    level util::set_lighting_state(1);
    }

}


^1    monkeyt2 SetHintString
^1-------------------------^
^1ERR(0) scripts/zm/zm_boyafa.gsc (194,26) in "setup_lightswitch()" : syntax error, unexpected TOKEN_IDENTIFIER, expecting TOKEN_LEFT_PAREN :     monkeyt2 SetHintString 


369:

Full code : https://pastebin.com/QQ9VFHQB

Fixed it: https://pastebin.com/bCb1tej0