How to open the door for free with 3 buttons?

broken avatar :(
Created 1020 days ago
by Conbini2017
0 Members and 1 Guest are viewing this topic.
4,096 views
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 6 days ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
Please tell me the script to open the door for free with 3 buttons. :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 December 2013
Last active: 939 days ago
Posts
6
Respect
Forum Rank
Legless Crawler
Primary Group
Member
Signature
Jack of All Trades: Master of None
×
Chilltacular's Groups
Chilltacular's Contact & Social Links
function openDoor()
{
     level.door = GetEnt("door", "targetname");
     level.trig1 = GetEnt("trigger1", "targetname");
     level.trig2 = GetEnt("trigger2", "targetname");
     level.trig3 = GetEnt("trigger3", "targetname");
     level.doorClip = GetEnt("door_clip", "targetname");
     level.buttonsNeeded = 3;
     level.buttonsPressed = 0;
     thread Trig1();
     thread Trig2();
     thread Trig3();
}

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

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()
{
     if(level.buttonsPressed == level.buttonsNeeded)
     {
     level.door Delete();
     level.doorClip Delete();
     }
}


You would have to make sure that the door is either a script model or a script brushmodel and is named "door" for its target name and each of the triggers are named "trigger1", "trigger2", and "trigger3" in the targetname. If you want you could change the names but they have to correspond in radiant and the script. I included a clip in there in case you use a model for the door instead of a brushmodel as models are non collidable and can be walked through without a clip. Make sure the clip covers the entire door so players can't walk through it.

If you choose to you can rotate the door instead of deleting it by using RotateYaw([angle], [time for rotation]) instead of Delete(), but I won't get into that you can just look it up. JBird has some tutorials on doors and rotations on youtube.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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

You would have to make sure that the door is either a script model or a script brushmodel and is named "door" for its target name and each of the triggers are named "trigger1", "trigger2", and "trigger3" in the targetname.

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:

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)

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();
     }
}

Last Edit: February 24, 2017, 03:14:56 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 6 days ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
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:

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)

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();
     }
}


thank you!!!! :D

In radiant it is use_trigger?
Last Edit: February 26, 2017, 03:40:58 pm by Conbini2017
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
What am i doing wrong all my trigger are set and linked to the door but still say not available  :-[
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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
×
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
What am i doing wrong all my trigger are set and linked to the door but still say not available  :-[

Anytime that happens, the script is not running, or the kvps are wrong, or get ent is being used when you have multiple of a kvp.
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Anytime that happens, the script is not running, or the kvps are wrong, or get ent is being used when you have multiple of a kvp.
Right so ive used your cleaned up version and put scriptparsetree,scripts/zm/Trigger_door.gsc in my zone folder and  your script in scripts/zm/Trigger_door.gsc. is that right? Then my triggers targetname's as trigger and target as door.
target name of the script brush model as door. Something is wrong but i can't figure out what sorry im new ish to modding
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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
×
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
Right so ive used your cleaned up version and put scriptparsetree,scripts/zm/Trigger_door.gsc in my zone folder and  your script in scripts/zm/Trigger_door.gsc. is that right? Then my triggers targetname's as trigger and target as door.
target name of the script brush model as door. Something is wrong but i can't figure out what sorry im new ish to modding

Did you call or thread the function openDoor anywhere? Those were just two functions. They won't run by themselves, unless an auto exec was added to the script. Easiest to call or from main and add a using fit that script.
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Did you call or thread the function openDoor anywhere? Those were just two functions. They won't run by themselves, unless an auto exec was added to the script. Easiest to call or from main and add a using fit that script.

how and where would i add that sorry. Thanks for your help guess we all have to learn somewhere
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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
×
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
how and where would i add that sorry. Thanks for your help guess we all have to learn somewhere

usings are used when you want to call a function in another script. They go at the top of a script that you want to call the function from. See this for more info.
[You are not allowed to view external links. Register or Login to see them]

your using would look like this:
#using scripts\zm\Trigger_door;

You can add this to your mapname.gsc and then in the main function add:
    thread Trigger_door::openDoor();
Last Edit: May 29, 2017, 04:36:39 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Just getting an error after that

UNRECOVERABLE ERROR:
  ^1SCRIPT ERROR: No generated data for 'scripts/zm/zm_five.gsc'



Linker will now terminate.
********************************************************************************

==================================================
Linker summary:

There were no errors or warnings.

==================================================

^1#using scripts
^1-------------^
^1ERR(0) scripts/zm/zm_five.gsc (58,14)  : syntax error, unexpected TOKEN_IDENTIFIER, expecting TOKEN_FILENAME : #using scripts
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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
×
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
Oh, my bad, was on phone, just copied your text. I think your issue is the usings slash has to be like this:
#using scripts\zm\Trigger_door;

fixed in op. The way I had it was just for zone files.
Last Edit: May 29, 2017, 04:39:31 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Oh, my bad, was on phone, just copied your text. I think your issue is the usings slash has to be like this:
#using scripts\zm\Trigger_door;

fixed in op. The way I had it was just for zone files.

Hahaha looking at the code now it's stands out so much as being wrong but it's still saying no available. So must be the kvp's is there any particular trigger type I need to use or kvp's for them or the script model. Don't know how I'm finding it so hard when I've followed everything lol
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 259 days 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
×
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
Hahaha looking at the code now it's stands out so much as being wrong but it's still saying no available. So must be the kvp's is there any particular trigger type I need to use or kvp's for them or the script model. Don't know how I'm finding it so hard when I've followed everything lol

Its tough to help on this post like this. Might be better if you make your own with examples and pictures of what you have done so far.

But as far as kvps, they simply must match what is in script. So for this line:
trigs = GetEntArray("triggers","targetname");

the kvp for the tirggers would be targetname>triggers

I have a scripting tut series if that would be any help. It goes over kvps and things like this.
Last Edit: May 29, 2017, 09:41:46 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 800 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Sorry last one I've got it working but opens after one of the triggers is pressed when theirs 4 to press  :'(

 

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 Twitch
Loading ...