Page 1 of 2

two scripts needed

Posted: November 18th, 2006, 3:17 am
by Nightmare
ok I need two scripts for my upcoming map.

1. So I make a keypad with numbers. I would like it so you have to press the right buttons in the right order to open a door.

2. Kinda like that script in nm_rain, but I need it so when two people are standing in two different triggers that it activates something.
so like even if someone stands on the spot, they need to wait for a second player to come and stand on the spot.

Thanks alot :D

Posted: November 18th, 2006, 3:44 am
by Drofder2004
Ok, I need sleep so i'm only going to give you an idea of how each is done...

1)
Create the keypad, run 1 thread per button.
Use a level variable (level.code) to gather input...

example..
trigger1 waittill ("trigger");
level.variable = level.variable + "1"; //etc

Then create a enter button that checks the variable...
triggerEnter waittill("trigger");
if(level.code == "<code number here>")
//do something
else
level.code = ""; //Reset code.

2)
Again, use a level vairable to monitor the threads (a thread per trigger + 1 thread)

thread a...
{
level.triggerA = false;
while(1)
{
triggerA waittill("trigger", player);

level.triggerA = true;
while(player isTouching(triggerA))
{
wait 0.1;
}
level.triggerA = false;
}

(Same for trigger 2)

Then run a seperate thread to compare the variables...

{
while(1)
{
if((level.triggerA == true) && (level.triggerB == true))
// Do something

wait 0.1;
}
}


More info some other time (if you still need it).

Posted: November 22nd, 2006, 11:44 pm
by Nightmare
could you give me some more info on the first script, I think I understand the second one.

Posted: November 23rd, 2006, 12:57 am
by Drofder2004
Ok, so you run 11 threads for the buttons...


button0 = getent("button0","targetname");
button1 = getent("button1","targetname");
button2 = getent("button2","targetname");
... ... ...
button9 = getent("button9","targetname");
buttonEnter = getent("buttonEnter","targetname");

You then run them all into their threads...

button0 thread checkButton("0");
button1 thread checkButton("1");
button2 thread checkButton("2");
... .. ...
button9 thread checkButton("9");
buttonEnter thread checkButton("enter");

Now, you need to create the thread, checkbutton().

Code: Select all

checkButton(button)
{
while(1)
{
   self waittill("trigger");
   
   if(button == "enter")
   {
      if(level.code == level.answer)
         //Open door
      else
         level.code = "";
   }
   else
      level.code += button;
}
}
Very untested, off the top of my head, should work, if it doesn't try for yourself (a couple of things to remember, you will need to define level.code [level.code = "";] before this you run the checkButton threads, and also you will need to define level.answer to be the code [level.answer = "1234";])

Posted: November 23rd, 2006, 4:46 am
by Nightmare
I still don't get a lick of this, sorry.
Could you make a gsc file and send it over email? That would help me out alot :)

Posted: November 23rd, 2006, 8:54 pm
by Luke
Theres a keypad lock in the map rnr_warehouse, which you have to shoot the numbers to enter the code. The script is over 1000 lines though :o

Posted: November 24th, 2006, 2:13 am
by Drofder2004
Luke wrote:The script is over 1000 lines though :o
What just for the keypad?

Shooting is a better option I must admit, sometimes pushing triggers that are close together get bad responses...

I will knock up a keypad door now.

Posted: November 24th, 2006, 2:25 am
by Nightmare
thank you drof, I <3 you :D

Posted: November 24th, 2006, 2:43 am
by Luke
Drofder2004 wrote:
Luke wrote:The script is over 1000 lines though :o
What just for the keypad?

Shooting is a better option I must admit, sometimes pushing triggers that are close together get bad responses...

I will knock up a keypad door now.
yep, they created a gsc just for that. I had a quick look at it, and could not find the actual code lol :P
And yeah, to create it with use triggers would be damn near impossible to operate if u wanted to make a realistic looking one anyway, as the triggers would be too small and close to each other.

Posted: November 24th, 2006, 3:00 am
by Nightmare
yeah, I am fine with shooting

Posted: November 24th, 2006, 4:45 am
by Drofder2004
Sorry, got put on hold til 2moro ;)

Posted: November 24th, 2006, 4:53 am
by Nightmare
nooooooooooooooo, drof, you make me sad :(

Posted: November 24th, 2006, 5:56 am
by Drofder2004
Nightmare wrote:nooooooooooooooo, drof, you make me sad :(
Its now 5am, if I had more time I would, but what would you prefer, pavlov or script... infact dont answer that, it my choice... pavlov first :P

Posted: November 24th, 2006, 4:21 pm
by Nightmare
Ok well hurry up. :x

Posted: November 24th, 2006, 9:13 pm
by Drofder2004
Nightmare wrote:Ok well hurry up. :x
lol, for that you have to wait until 2moro :P
(well, real reason is I have had 4 hours sleep and I am not in a great mood :P)

For now, check out the map luke said (rnr) and check their coding :)