Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 15 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
Author Topic: coded keypad door
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Jan. 11, 2009 06:46 pm
Hmm, weird - seems the bbcode parser is doing some weird things and sticking a modsonline prefix to it.

try this one

http://www.codbrothers.co.uk/misc/mp_keypad.zip
Share |
NotDeadYet
General Member
Since: Jan 5, 2009
Posts: 52
Last: Jul 28, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Jan. 11, 2009 07:22 pm
omg omg omg omg omg! IT WORKS!!! thanks pedro your script is the winner. thanks everyone else on the way to.. this helped a lot. i think i want 2 key coded doors now! sweet. thanks again.. [thumbs_up][tongue][wave][wink][thumbs_up][tongue][wave][wink]

now to get my elevator working [banghead]
Share |
_INSANE_
General Member
Since: Nov 7, 2008
Posts: 352
Last: Jul 10, 2011
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Jan. 11, 2009 07:25 pm
Yeah. I figured there was something wrong.. i needed to edit it... but oh well

Glad you got it working[thumbs_up]

edited on Jan. 11, 2009 02:26 pm by INSANE{H|S}

edited on Jan. 11, 2009 02:28 pm by INSANE{H|S}
Share |
coywhite
General Member
Since: Jul 27, 2008
Posts: 24
Last: Mar 11, 2010
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, Jan. 11, 2009 11:24 pm
cool [drink]




edited on Jan. 11, 2009 06:28 pm by coywhite
Share |
NotDeadYet
General Member
Since: Jan 5, 2009
Posts: 52
Last: Jul 28, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Jan. 12, 2009 01:13 am
NOOOOOOOOOOOOOOOOOOOOOOOOO
[cry][cry][cry][cry][cry][cry]

i tried making 2 different keypadded doors cause the first one was soo cool, now nothing works....[cry] heres what i have
Code:
init()
{ 

   /* Max number can be 25 (set in the for loop below)
      make sure that all sequential triggers are included 
      
      key: targetname
      value: b# 

      
      where # is the number of that button. Can use trigger uses or trigger damage (you shoot the buttons instead)
      
   */
      
   // List the code here - supports any length of code - always start at zero and increase by 1 each time
   // CODE IS 5349
   
   level.doorCode[0] = 5; 
   level.doorCode[1] = 3;
   level.doorCode[2] = 4;
   level.doorCode[3] = 9;
   
   thread keypad(); 
}

keypad()
{
   nextButton = level.doorCode[0];
   
   entryPosition = 0;
   
   level.lastButton = level.doorCode[(level.doorCode.size - 1)];
     
   for(i=1; i <= 9; i++)
   {
      button = getent(("b" + i), "targetname"); // get sequential buttons
      
      if(!isdefined(button)) break; // no more triggers - exit setup
      
      button thread watchTrigger(i);
   }
   
   level.buttonPressed = undefined;
   
   while(1)
   {
      if(isDefined(level.buttonPressed))
      {
         if(level.buttonPressed == nextButton)
         {
            entryPosition++;
            if(entryPosition >= level.doorCode.size) // Code finished so when it matches reset the code and open the door
            {  
               // Do your door stuff here - not threaded so can wait there for door to close again              
               door_open(); 
               nextButton = level.doorCode[0];
               entryPosition = 0;
            }
            else
            {
               nextButton = level.doorCode[entryPosition];
            }
            level.buttonPressed = undefined;
         }
         else
         {
            nextButton = level.doorCode[0]; // button selected did not match nextButton - reset code
            level.buttonPressed = undefined;
            entryPosition = 0;
            continue;
         }     
      }     
      wait 0.05;   
   }   
}

watchTrigger(number)
{
   while(1)
   {
      self waittill("trigger");
      level.buttonPressed = number;
      wait 0.05;
   }
}

door_open()
{
// the rest....
 iprintln("open the door");
 
 door = getent("sliding_door","targetname");
 door2= getent("sliding_door2","targetname");
 
 if(isdefined(door))
 {
   door movey(50,2,0.5,0.25);
   door waittill("movedone");
   
   wait 0.05;
   
   door movey(-50,2,0.5,0.25);
   door waittill("movedone"); 

   door2 movey(50,2,0.5,0.25);
   door2 waittill("movedone");

   wait 0.05;

   door2 movey(-50,2,0.5,0.25);
   door2 waittill("movedone");
 
 }
 
}


this is the first one, which worked till i tried to add the second one... in this one ^^^^ i had triggers 1-9 and a sliding_door, sliding_door2...

Code:
init()
{ 

   /* Max number can be 25 (set in the for loop below)
      make sure that all sequential triggers are included 
      
      key: targetname
      value: b# 

      
      where # is the number of that button. Can use trigger uses or trigger damage (you shoot the buttons instead)
      
   */
      
   // List the code here - supports any length of code - always start at zero and increase by 1 each time
   // CODE IS 1267
   
   level.doorCode[0] = 10; 
   level.doorCode[1] = 11;
   level.doorCode[2] = 12;
   level.doorCode[3] = 13;
   
   thread keypad(); 
}

keypad()
{
   nextButton = level.doorCode[0];
   
   entryPosition = 0;
   
   level.lastButton = level.doorCode[(level.doorCode.size - 1)];
     
   for(i=10; i <= 20; i++)
   {
      button = getent(("b" + i), "targetname"); // get sequential buttons
      
      if(!isdefined(button)) break; // no more triggers - exit setup
      
      button thread watchTrigger(i);
   }
   
   level.buttonPressed = undefined;
   
   while(1)
   {
      if(isDefined(level.buttonPressed))
      {
         if(level.buttonPressed == nextButton)
         {
            entryPosition++;
            if(entryPosition >= level.doorCode.size) // Code finished so when it matches reset the code and open the door
            {  
               // Do your door stuff here - not threaded so can wait there for door to close again              
               door_open(); 
               nextButton = level.doorCode[0];
               entryPosition = 0;
            }
            else
            {
               nextButton = level.doorCode[entryPosition];
            }
            level.buttonPressed = undefined;
         }
         else
         {
            nextButton = level.doorCode[0]; // button selected did not match nextButton - reset code
            level.buttonPressed = undefined;
            entryPosition = 0;
            continue;
         }     
      }     
      wait 0.05;   
   }   
}

watchTrigger(number)
{
   while(1)
   {
      self waittill("trigger");
      level.buttonPressed = number;
      wait 0.05;
   }
}

door_open()
{
// the rest....
 iprintln("open the door");
 
 door = getent("sliding_door3","targetname");
 
 if(isdefined(door))
 {
   door movez(70,3,0.5,0.25);
   door waittill("movedone");

   wait 0;
   
   door movez(-70,2,0.5,0.25);
   door waittill("movedone"); 

 }
 
}


this is the second code for a second set of triggers. for this one i have triggers 10-13 and a sliding_door3

[cry][cry][cry][cry][cry][cry]

help plz

edited on Jan. 11, 2009 08:14 pm by NotDeadYet

of course in the mp_treehouse3.gsc i called up both scripts
mp\maps\mp_treehouse_keypad::init();
mp\maps\mp_treehouse_keypad2::init();

edited on Jan. 11, 2009 08:16 pm by NotDeadYet
Share |
NotDeadYet
General Member
Since: Jan 5, 2009
Posts: 52
Last: Jul 28, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Thursday, Jan. 15, 2009 03:29 pm
sry to double post but anyone??? plz.
Share |
_INSANE_
General Member
Since: Nov 7, 2008
Posts: 352
Last: Jul 10, 2011
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Jan. 15, 2009 03:55 pm
Not sure whether this will work.. but try this for your second door

Code:
init()
{ 

   /* Max number can be 25 (set in the for loop below)
      make sure that all sequential triggers are included 
      
      key: targetname
      value: b# 

      
      where # is the number of that button. Can use trigger uses or trigger damage (you shoot the buttons instead)
      
   */
      
   // List the code here - supports any length of code - always start at zero and increase by 1 each time
   // CODE IS 1267
   
   level.doorCode2[0] = 10; 
   level.doorCode2[1] = 11;
   level.doorCode2[2] = 12;
   level.doorCode2[3] = 13;
   
   thread keypad(); 
}

keypad()
{
   nextButton = level.doorCode2[0];
   
   entryPosition = 0;
   
   level.lastButton = level.doorCode2[(level.doorCode2.size - 1)];
     
   for(i=10; i <= 20; i++)
   {
      button = getent(("b" + i), "targetname"); // get sequential buttons
      
      if(!isdefined(button)) break; // no more triggers - exit setup
      
      button thread watchTrigger(i);
   }
   
   level.buttonPressed = undefined;
   
   while(1)
   {
      if(isDefined(level.buttonPressed))
      {
         if(level.buttonPressed == nextButton)
         {
            entryPosition++;
            if(entryPosition >= level.doorCode2.size) // Code finished so when it matches reset the code and open the door
            {  
               // Do your door stuff here - not threaded so can wait there for door to close again              
               door_open(); 
               nextButton = level.doorCode2[0];
               entryPosition = 0;
            }
            else
            {
               nextButton = level.doorCode2[entryPosition];
            }
            level.buttonPressed = undefined;
         }
         else
         {
            nextButton = level.doorCode2[0]; // button selected did not match nextButton - reset code
            level.buttonPressed = undefined;
            entryPosition = 0;
            continue;
         }     
      }     
      wait 0.05;   
   }   
}

watchTrigger(number)
{
   while(1)
   {
      self waittill("trigger");
      level.buttonPressed = number;
      wait 0.05;
   }
}

door_open()
{
// the rest....
 iprintln("open the door");
 
 door = getent("sliding_door3","targetname");
 
 if(isdefined(door))
 {
   door movez(70,3,0.5,0.25);
   door waittill("movedone");

   wait 0;
   
   door movez(-70,2,0.5,0.25);
   door waittill("movedone"); 

 }
 
}
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Thursday, Jan. 15, 2009 05:23 pm
Almost there Insane. As each trigger is referenced explicitly you need separate targetnames for each key. It also uses the number in the targetname to get the number of the key it should activate so you need to start at 1 each time in the for loop.

For example in the second keypad rename all the triggers. Instead of
key: targetname
value: b1

change it to
key: targetname
key:c1

and use the same letter for the rest of the keys in that keypad.

Then in the script above change this line (35):
Code:
button = getent(("b" + i), "targetname"); // get sequential buttons


to
Code:
button = getent(("c" + i), "targetname"); // get sequential buttons


As the button pressed variable is also global you will need a new version of this, so do a find-replace and change 'level.buttonPressed' to 'level.buttonPressed2'

Final Script with C# triggers (#=a number)
Code:
init()
{ 

   /* Max number can be 25 (set in the for loop below)
      make sure that all sequential triggers are included 
      
      key: targetname
      value: c# 
      
      where # is the number of that button. Can use trigger uses or trigger damage (you shoot the buttons instead)
      
   */
      
   // List the code here - supports any length of code - always start at zero and increase by 1 each time
   // CODE IS 1267
   
   level.doorCode2[0] = 1; 
   level.doorCode2[1] = 2;
   level.doorCode2[2] = 6;
   level.doorCode2[3] = 7;
   
   thread keypad(); 
}

keypad()
{
   nextButton = level.doorCode2[0];
   
   entryPosition = 0;
        
   for(i=1; i <= 20; i++)
   {
      button = getent(("c" + i), "targetname"); // get sequential buttons
      
      if(!isdefined(button)) break; // no more triggers - exit setup
      
      button thread watchTrigger(i);
   }
   
   level.buttonPressed2 = undefined;
   
   while(1)
   {
      if(isDefined(level.buttonPressed2))
      {
         if(level.buttonPressed2 == nextButton)
         {
            entryPosition++;
            if(entryPosition >= level.doorCode2.size) // Code finished so when it matches reset the code and open the door
            {  
               // Do your door stuff here - not threaded so can wait there for door to close again              
               door_open(); 
               nextButton = level.doorCode2[0];
               entryPosition = 0;
            }
            else
            {
               nextButton = level.doorCode2[entryPosition];
            }
            level.buttonPressed2 = undefined;
         }
         else
         {
            nextButton = level.doorCode2[0]; // button selected did not match nextButton - reset code
            level.buttonPressed2 = undefined;
            entryPosition = 0;
            continue;
         }     
      }     
      wait 0.05;   
   }   
}

watchTrigger(number)
{
   while(1)
   {
      self waittill("trigger");
      level.buttonPressed2 = number;
      wait 0.05;
   }
}

door_open()
{
// the rest....
 iprintln("open the door");
 
 door = getent("sliding_door3","targetname");
 
 if(isdefined(door))
 {
   door movez(70,3,0.5,0.25);
   door waittill("movedone");

   wait 0;
   
   door movez(-70,2,0.5,0.25);
   door waittill("movedone"); 

 }
 
}


I'm assuming here that you have a copy of the keypad with numbers 1-9 and you want to open a separate door and the script above (which I haven't tested) should do this.
Share |
_INSANE_
General Member
Since: Nov 7, 2008
Posts: 352
Last: Jul 10, 2011
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Jan. 15, 2009 05:33 pm
Thanks Pedro, I learned something today[biggrin][wave]

I hope it works for you, Notdeadyet
Share |
NotDeadYet
General Member
Since: Jan 5, 2009
Posts: 52
Last: Jul 28, 2009
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Thursday, Jan. 15, 2009 07:07 pm
script compile error :|
i have triggers c1-c7
and sliding_door3

Code:
init()
{ 

   /* Max number can be 25 (set in the for loop below)
      make sure that all sequential triggers are included 
      
      key: targetname
      value: c# 

      
      where # is the number of that button. Can use trigger uses or trigger damage (you shoot the buttons instead)
      
   */
      
   // List the code here - supports any length of code - always start at zero and increase by 1 each time
   // CODE IS 1267
   
   level.doorCode2[0] = 1; 
   level.doorCode2[1] = 2;
   level.doorCode2[2] = 6;
   level.doorCode2[3] = 7;
   
   thread keypad(); 
}

keypad()
{
   nextButton = level.doorCode2[0];
   
   entryPosition = 0;
        
   for(i=1; i <= 20; i++)
   {
      button = getent(("c" + i), "targetname"); // get sequential buttons
      
      if(!isdefined(button)) break; // no more triggers - exit setup
      
      button thread watchTrigger(i);
   }
   
   level.buttonPressed2 = undefined;
   
   while(1)
   {
      if(isDefined(level.buttonPressed2))
      {
         if(level.buttonPressed2 == nextButton)
         {
            entryPosition++;
            if(entryPosition >= level.doorCode2.size) // Code finished so when it matches reset the code and open 

the door
            {  
               // Do your door stuff here - not threaded so can wait there for door to close again              
               door_open(); 
               nextButton = level.doorCode2[0];
               entryPosition = 0;
            }
            else
            {
               nextButton = level.doorCode2[entryPosition];
            }
            level.buttonPressed2 = undefined;
         }
         else
         {
            nextButton = level.doorCode2[0]; // button selected did not match nextButton - reset code
            level.buttonPressed2 = undefined;
            entryPosition = 0;
            continue;
         }     
      }     
      wait 0.05;   
   }   
}

watchTrigger(number)
{
   while(1)
   {
      self waittill("trigger");
      level.buttonPressed2 = number;
      wait 0.05;
   }
}

door_open()
{
// the rest....
 iprintln("open the door");
 
 door = getent("sliding_door3","targetname");
 
 if(isdefined(door))
 {
   door movez(70,3,0.5,0.25);
   door waittill("movedone");

   wait 0;
   
   door movez(-70,2,0.5,0.25);
   door waittill("movedone"); 

 }
 
}

// I'm assuming here that you have a copy 


edited on Jan. 15, 2009 02:16 pm by NotDeadYet
Share |
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»