UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

How to open the door for free with 3 buttons?

HOT
broken avatar :(
Created 7 years ago
by Conbini2017
0 Members and 1 Guest are viewing this topic.
9,948 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Sorry last one I've got it working but opens after one of the triggers is pressed when theirs 4 to press  :'(

It's tough to say. I'd add some prints to see what is happening. A print before it checks the level.buttonsPressed, a print before it level.buttonsPressed--.
Code Snippet
Plaintext
iprintlnbold("total:";
iprintlnbold(level.buttonsPressed);


Something like that to try and troubleshoot your issue.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 4 years ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
Some people get offended by this, but please know I mean no offense:

Here are some tips to clean up your code, make it more readable, and dynamic:

Code Snippet
Plaintext
function openDoor()
{
     level.door = GetEnt("door", "targetname");//I personally would pass the door, and not use a level var

     // level.trig1 = GetEnt("trigger1", "targetname");
     // level.trig2 = GetEnt("trigger2", "targetname");
     // level.trig3 = GetEnt("trigger3", "targetname");

     //instead of three level trigs above give them all the same targetname and do this
     trigs = GetEntArray("triggers","targetname");


     level.doorClip = GetEnt("door_clip", "targetname");//I personally would set the clip as the doors target and not use level var
     //need to disconnect paths on the door so zombies don't try to go through
     level.doorClip DisconnectPaths();//may not see this issue if no other way in that area

     level.buttonsNeeded = trigs.size;//set this to the number of trigs by using array size
     // level.buttonsPressed = 0;//we can comment this out and just use buttons needed and subtract

     // thread Trig1();
     // thread Trig2();
     // thread Trig3();

     //instead of threading the same function with a different name on each different trigger
     //you can thread on the array, or iterate the array and thread on each trigger

     //iterate method:
     foreach(trig in trigs)
     {
          trig thread Trig1();//I personally would pass the door, and not use a level var
     }

     //thread_all method:
     // array::thread_all(trigs, &Trig1);//this method requires adding #using scripts\shared\array_shared; to top

}

function Trig1()//I personally would pass the door, and not use a level var
{
     //you should set the hint here
     self SetCursorHint("HINT_NOICON");
     self SetHintString("Press [{+activate}] to...");

     // while(1)//no need for a while loop when you are breaking unconditionally
     // {
     self waittill("trigger", player);//self is the trigger, and player isn't used, so not really needed
     level.buttonsPressed--;//subtract so we can check < 0 later
     self Delete();//self delete
     CheckDoor();
     // break;
     // }
}
//no need for multiple functions that do the same function
// function Trig2()
// {
//      while(1)
//      {
//      level.trig2 waittill("trigger", player);
//      level.buttonsPressed++;
//      level.trig2 Delete();
//      CheckDoor();
//      break;
//      }
// }

// function Trig3()
// {
//      while(1)
//      {
//      level.trig3 waittill("trigger", player);
//      level.buttonsPressed++;
//      level.trig3 Delete();
//      CheckDoor();
//      break;
//      }
// }

function CheckDoor()//I personally would pass the door, and not use a level var
{
     // if(level.buttonsPressed >= level.buttonsNeeded)//check if >= instead of == just incase something bugs
     if(level.buttonsNeeded<=0)//changed this to check for less than 0 since now we will subtract
     {
          level.doorClip ConnectPaths();
          level.door Delete();
          level.doorClip Delete();
     //when you open a door, you'll need to connect the paths, which means you should disconnect the paths first
     }
}


Here is the code cleaned up. I would also set the doors as the target of the triggers and make some more tweaks, but this is cleaner and you can add as many triggers as you want this way: (sorry for any typos or errors, didn't test)
Code Snippet
Plaintext

function openDoor()
{
     trigs = GetEntArray("triggers","targetname");
     level.buttonsNeeded = trigs.size;

     door = GetEnt("door", "targetname");
     
     doorClip = GetEnt("door_clip", "targetname");//I personally would set the clip as the doors target and not use level var
     doorClip DisconnectPaths();

     foreach(trig in trigs)
     {
          trig thread Trig1(door, doorClip);
     }
}

function Trig1(door, doorClip)
{
     self SetCursorHint("HINT_NOICON");
     self SetHintString("Press [{+activate}] to...");

     self waittill("trigger", player);
     level.buttonsPressed--;
     self Delete();
     CheckDoor(door, doorClip);
}

function CheckDoor(door, doorClip)
{
     if(level.buttonsNeeded<=0)
     {
          doorClip ConnectPaths();
          door Delete();
          doorClip Delete();
     }
}


Could the problem be that you are setting buttonsNeeded to trigs.size, but later in the code you are subtracting buttonsPressed and not buttonsNeeded?

 
Loading ...