two scripts needed

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » November 25th, 2006, 12:12 am

I got it to work but I didn't use an array, which i think you need to do for the way drofder arranged it. But it does work, heres the gsc i put together

Code: Select all

Main()
{
maps\mp\_load::main();
thread checkButton0();
thread checkButton1();
thread checkButton2();
thread checkButton3();
thread checkButton4();
thread checkButton5();
thread checkButton6();
thread checkButton7();
thread checkButton8();
thread checkButton9();
thread checkButtonenter();
level.code = "";
}

checkButton0()
{
button0 = getent("button0","targetname");
while(1)
{
button0 waittill ("trigger");
level.code = level.code + "0";
iprintlnbold(level.code);
wait .5;
}
}

checkButton1()
{
button1 = getent("button1","targetname");
while(1)
{
button1 waittill ("trigger");
level.code = level.code + "1"; 
iprintlnbold(level.code);
wait .5;
}
} 

checkButton2()
{
button2 = getent("button2","targetname");
while(1)
{
button2 waittill ("trigger");
level.code = level.code + "2"; 
iprintlnbold(level.code);
wait .5;
}
}

checkButton3()
{
button3 = getent("button3","targetname");
while(1)
{
button3 waittill ("trigger");
level.code = level.code + "3"; 
iprintlnbold(level.code);
wait .5;
}
}

checkButton4()
{
button4 = getent("button4","targetname");
while(1)
{
button4 waittill ("trigger");
level.code = level.code + "4"; 
iprintlnbold(level.code);
wait .5;
}
} 

checkButton5()
{
button5 = getent("button5","targetname");
while(1)
{
button5 waittill ("trigger");
level.code = level.code + "5"; 
iprintlnbold(level.code);
wait .5;
}
} 

checkButton6()
{
button6 = getent("button6","targetname");
while(1)
{
button6 waittill ("trigger");
level.code = level.code + "6"; 
iprintlnbold(level.code);
wait .5;
}
}    

checkButton7()
{
button7 = getent("button7","targetname");
while(1)
{
button7 waittill ("trigger");
level.code = level.code + "7"; 
iprintlnbold(level.code);
wait .5;
}
} 

checkButton8()
{
button8 = getent("button8","targetname");
while(1)
{
button8 waittill ("trigger");
level.code = level.code + "8"; 
iprintlnbold(level.code);
wait .5;
}
}  

checkButton9()
{
button9 = getent("button9","targetname");
while(1)
{
button9 waittill ("trigger");
level.code = level.code + "9"; 
iprintlnbold(level.code);
wait .5;
}
}  

checkButtonenter()
{
enter = getent("buttonenter","targetname");
while(1)
{
level.answer = "1234";
enter waittill ("trigger");
if(level.code == level.answer)
iprintlnbold(level.code);
else
level.code = ""; //Reset code
}
} 
this works for just the 1 keypad, but i'm sure drofder will provide a more efficient code for you.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 25th, 2006, 10:51 pm

No array is needed, just a looped script ;)

Code: Select all

Main()
{
maps\mp\_load::main();
thread checkButton(0);
thread checkButton(1);
thread checkButton(2);
thread checkButton(3);
thread checkButton(4);
thread checkButton(5);
thread checkButton(6);
thread checkButton(7);
thread checkButton(8);
thread checkButton(9);
thread checkButtonenter();

level.code = "";
}

checkButton(i)
{
temp = "button_" + i;
button = getent(temp,"targtname");

while(1)
{
button waittill ("trigger");
level.code = level.code + "" + i;
iprintlnbold(level.code); // debug
wait .5;
}
}

checkButtonenter()
{
enter = getent("buttonenter","targetname");

while(1)
{
level.answer = "1234";
enter waittill ("trigger");
if(level.code == level.answer)
   iprintlnbold("Password Correct"); // Debug
else
{
   iprintln("Password reset");
   level.code = ""; //Reset code
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » November 25th, 2006, 11:37 pm

So how does it find the ent names? i named the butons button0, button1 ect in a test map, should this script work still?
I tried it but it goes mental with loads of text showing up when i spawn, and it won't load in dev mode, it says undefined is not an object(line 26). the only thing that did work was when i shot the enter button it displayed the reset message. This is in cod 2 btw.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 26th, 2006, 2:47 am

Luke wrote:So how does it find the ent names? i named the butons button0, button1 ect in a test map, should this script work still?
I tried it but it goes mental with loads of text showing up when i spawn, and it won't load in dev mode, it says undefined is not an object(line 26). the only thing that did work was when i shot the enter button it displayed the reset message. This is in cod 2 btw.
temp = "button_" + i;
button = getent(temp,"targtname");

so targetname are button_i where i is a number...
change it to

temp = "button" + i;
button = getent(temp,"targtname");

and all is well ;)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » November 26th, 2006, 4:16 am

Thought that might be it, but i'm getting the same problem though :? pretty sure it's not my triggers coz they worked with the other code.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 26th, 2006, 5:03 am

Luke wrote:Thought that might be it, but i'm getting the same problem though :? pretty sure it's not my triggers coz they worked with the other code.
i'll quickly see if I can get it to work...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 26th, 2006, 5:28 am

Working...

Code: Select all

Main()
{
   maps\mp\_load::main();

   level.code = "";

   for(i=0; i<10; i++)
   {
	j = "" + i;
	button = getent("button_" + j,"targetname");
	button thread checkbutton(j);
   }

   thread checkButtonenter();
}

checkButton(j)
{
   while(1)
   {
      self waittill ("damage");
      level.code = level.code + "" + j;
      iprintlnbold(level.code); // debug
      wait .5;
   }
}

checkButtonenter()
{
   enter = getent("button_enter","targetname");

   while(1)
   {
      level.answer = "1234";
      enter waittill ("damage");
      if(level.code == level.answer)
      {
         iprintlnbold("Password Correct"); // Debug
         level.code = "";
      }
      else
      {
         iprintln("Password reset");
         level.code = ""; //Reset code
      }
   }
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » November 26th, 2006, 1:35 pm

Awesome thanks :) 47 lines pretty much owns 1170 that rnr use lol
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » November 26th, 2006, 8:46 pm

thanks alot drofder :D
now can you explain the second script alittle bit? :)
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 26th, 2006, 10:59 pm

Ok, second script is pretty straight forward.

2 triggers. lets call them trigA and trigB.

3 threads, 2 for monitoring each trigger, and a third for monitoring to see if both triggers are activated...
(By the way, I am going to use a new method for getent and thread)

Code: Select all

main()
{
   level.trigA = false;
   level.trigB = false;
   getent("trigA","targetname") thread trigAmonitor();
   getent("trigB","targetname") thread trigBmonitor();
   thread trigMonitor();
}

trigAmonitor()
{
   while(1)
   {
      self waittill("trigger", other);

      while(other isTouching(self))
      {
         level.trigA = true;
      }
      
      level.trigA = false;
   }
}

trigBmonitor()
{
   while(1)
   {
      self waittill("trigger", other);

      while(other isTouching(self))
      {
         level.trigB = true;
      }
      
      level.trigB = false;
   }
}

trigMonitor()
{
   while(1)
   {
      if(trigA == true && trigB == true)
      {
         //Do stuff here
      }
      wait 0.05;
   }
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » November 28th, 2006, 11:57 pm

hmm, for some reason the action is activated even with no one in either of the triggers :?

Code: Select all

level.nm_dual_trigA = false;
level.nm_dual_trigB = false;
getent("nm_dual_room13_triga","targetname") thread nm_dual_trigAmonitor();
getent("nm_dual_room13_trigb","targetname") thread nm_dual_trigBmonitor();
thread nm_dual_trigMonitor();


nm_dual_trigAmonitor()
{
   while(1)
   {
      self waittill("trigger", other);

      while(other isTouching(self))
      {
         level.nm_dual_trigAtrigA = true;
      }
     
      level.nm_dual_trigAtrigA = false;
   }
}

nm_dual_trigBmonitor()
{
   while(1)
   {
      self waittill("trigger", other);

      while(other isTouching(self))
      {
         level.nm_dual_trigB = true;
      }
     
      level.nm_dual_trigB = false;
   }
}

nm_dual_trigMonitor()
{
front1 = getent("nm_dual_room13_eledoor_front1","targetname");
front2 = getent("nm_dual_room13_eledoor_front2","targetname");
elevator = getent("nm_dual_room13_ele","targetname");
back1 = getent("nm_dual_room13_eledoor_back1","targetname");
back2 = getent("nm_dual_room13_eledoor_back2","targetname");
while(1)
{
if(nm_dual_trigA == true && nm_dual_trigB == true)
{
front1 moveZ (-144,2,0.5,0.5);
front2 moveZ (-144,2,0.5,0.5);
front2 waittill ("movedone");
wait(4);
front1 moveZ (144,2,0.5,0.5);
front2 moveZ (144,2,0.5,0.5);
front2 waittill ("movedone");
wait(1);
front2 moveZ (-304,3,0.5,0.5);
elevator moveZ (-304,3,0.5,0.5);
back2 moveZ (-304,3,0.5,0.5);
elevator waittill ("movedone");
wait(1);
back1 moveZ (-144,2,0.5,0.5);
back2 moveZ (-144,2,0.5,0.5);
back2 waittill ("movedone");
wait(4);
back1 moveZ (144,2,0.5,0.5);
back2 moveZ (144,2,0.5,0.5);
back2 waittill ("movedone");
wait(1);
front2 moveZ (304,1,0.5,0.5);
elevator moveZ (304,1,0.5,0.5);
back2 moveZ (304,1,0.5,0.5);
elevator waittill ("movedone");
}
wait 0.05;
}
}
Btw, I get this error in developer mode

Code: Select all

pair has unmatching types 'undefined' and 'int': (file 'maps\mp\nm_dual.gsc'. line 1367)
if(nm_dual_trigA == true && nm_dual_trigB == true)
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » November 29th, 2006, 12:23 am

Nightmare wrote:hmm, for some reason the action is activated even with no one in either of the triggers :?
Btw, I get this error in developer mode

Code: Select all

pair has unmatching types 'undefined' and 'int': (file 'maps\mp\nm_dual.gsc'. line 1367)
if(nm_dual_trigA == true && nm_dual_trigB == true)
thats because your variables are called "level.nm_dual_trigA" not just "nm_dual_trigA" ;)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » November 29th, 2006, 1:09 am

ah, that explains it. It works now :)
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest