Page 1 of 2

Enter The Pin Code To Open The Door

Posted: October 26th, 2008, 2:43 pm
by Scorpion
Hello

On the Map Nm_Dual About 1/2 The Way Through The Map , You Get To The Bit Where You Have To Enter The Pin Code Something Like 663777 .

Could You Tell Me How To Do This Please?

Thankyou :twisted:

Re: Enter The Pin Code To Open The Door

Posted: October 26th, 2008, 3:43 pm
by Drofder2004
Point and click (either Use or shoot), cant remember.

Re: Enter The Pin Code To Open The Door

Posted: October 26th, 2008, 4:41 pm
by Scorpion
I Know That

I Meant To Say How Do You Make it

Re: Enter The Pin Code To Open The Door

Posted: October 26th, 2008, 6:11 pm
by Nightmare
Here is the code. I must warn you, you must have a good understanding of coding to understand this.
If you can, come back to it later once you understand scripting in CoD a bit better (or study some C++ or Java).

viewtopic.php?p=83118#p83118

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 1:00 am
by Drofder2004
I do have a code lying around I was going to release to someone during the whole "puzzle" phase, which was a random passcode puzzle generator, but since my format lost it. It shouldn't be too hard to replicate using the code NM posted. Any one for a task? :P

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 1:28 am
by Nightmare
I could give it a go, honestly, that is really easy.
In fact, I did the exact same thing in nm_repeat.

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 3:19 am
by Drofder2004
Yeh, I was trying to do something very complex, and settled for the simpler version.

---

Here's a small task that I just attempted and I know is possibly (and possibly easy) but I am failing to wrap my head around it properly.

Basically I want to create a random, unique number generator, but without causing the game lag.

The first way I tried, the obvious "if number is not unique, randomise again".
That works fine, but if the game does not hit the final random number possible, then the game tells the script to abandon, being potentially infinite.

The second way I was looking to do it was an array.

array[0] = 0
array[1] = 1
array[2] = 2
array[3] = 3
etc

and when the randomiser hits a number, it is removed from the list and the list is recalculated, for example, random number equals "2". "2" is removed and becomes...

array[0] = 0
array[1] = 1
array[2] = 3
array[3] = 4
etc

This is the same way Call of Duty deals with player disconnects, but I unable to get it to work :S

Wanna have a go at that? :)

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 3:36 am
by Nightmare
I remember making something of that sort (pushing and popping) in c++. I'd have to see if I still have the file anywhere.

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 5:26 pm
by Scorpion
Iv Created The Pin Code And It Moves The Door . Its All Working Good But I want to add A Enter Button Just Like On Nm_Dual

Here Is My Script

main()
{

level.codeCount=0;
level.code="";

for(i=1;i<7;i++) //Change 4 to however many triggers you have
{
trig = getent("jm_lockover_no"+i,"targetname");
trig thread checkTrig(i);
}
}

checkTrig(i)
{
while(1)
{
self waittill("trigger",user);
if(level.codeCount<6) //Change 3 with however long your code is.
{
level.code=level.code+""+i;
level.codeCount++;
}
if(level.codeCount==6) //Change 3 with however long your code is
{
if(level.code==536236) //Change 123 to whatever code you want
{
user iprintln ("Password Correct");
platform = getent ("jm_lockover_no_door","targetname");
wait(2);
platform moveX (64,2,0.5,0.5);
platform waittill ("movedone");
wait(5);
platform moveX (-64,2,0.5,0.5);
platform waittill ("movedone");
}
else
{
iprintln("Password Denied");
}
level.codeCount=0;
level.code="";
}
}
}


Iv Created A Enter Button And A Enter Trigger

What Other Information Would I Add Into The Script?

ThankYou

Re: Enter The Pin Code To Open The Door

Posted: October 27th, 2008, 11:14 pm
by zipperdude
This is what mine looks like:

Code: Select all

main()
{

level.codeCount=0;
level.code="";

for(i=1;i<10;i++) //Change 4 to however many triggers you have
{
trig = getent("math_prob_"+i,"targetname");
trig thread checkTrig(i);
}
}

checkTrig(i)
{
while(1)
{
self waittill("trigger",user);
if(level.codeCount<2) //Change 3 with however long your code is.
{
level.code=level.code+""+i;
level.codeCount++;
}
if(level.codeCount==2) //Change 3 with however long your code is
{
if(level.code==62) //Change 123 to whatever code you want
{
	user iprintln ("Correct Answer");
	mc_door_1 = getent ("mc_door_1","targetname");
	wait(2);
	mc_door_1 rotatepitch ( 90 , 5 );
	mc_door_1 waittill ("movedone");
	wait(5);
	mc_door_1 rotatepitch ( -90 , 5 );
	mc_door_1 waittill ("movedone");
}
else
{
iprintln("Wrong Answer");
}
level.codeCount=0;
level.code="";
}
}
}
But nothing happens when u shoot the buttons :( Ive checked all the targetnames and values and renamed everything but still nothing happens. Its very saddening.

Re: Enter The Pin Code To Open The Door

Posted: October 28th, 2008, 3:26 am
by Nightmare

Code: Select all

main()
{
	level.code="";
	
	for(i=1;i<7;i++)
	{
		trig = getent("jm_lockover_no"+i,"targetname");
		trig thread checkTrig(i);
	}
	getent("jm_lockover_enter","targetname") thread checkEnter();
}

checkTrig(i)
{
	self waittill("trigger",user);
	level.code=level.code+""+i;
	wait 0.05;
	thread checkTrig(i);
}

checkEnter()
{
	self waittill("trigger",user);
	if(level.code==536236)
	{
		user iprintln ("Password Correct");
		platform = getent ("jm_lockover_no_door","targetname");
		wait(2);
		platform moveX (64,2,0.5,0.5);
		platform waittill ("movedone");
		wait(5);
		platform moveX (-64,2,0.5,0.5);
		platform waittill ("movedone");
	}
	else iprintln("Password Denied");
	level.code="";
	self thread checkEnter();
}
What a beauty, I simplified it big time. :D
Have any questions? Just ask!

Re: Enter The Pin Code To Open The Door

Posted: October 28th, 2008, 4:29 am
by zipperdude
Nightmare wrote:

Code: Select all

main()
{
	level.code="";
	
	for(i=1;i<7;i++)
	{
		trig = getent("jm_lockover_no"+i,"targetname");
		trig thread checkTrig(i);
	}
	getent("jm_lockover_enter","targetname") thread checkEnter();
}

checkTrig(i)
{
	self waittill("trigger",user);
	level.code=level.code+""+i;
	wait 0.05;
	thread checkTrig(i);
}

checkEnter()
{
	self waittill("trigger",user);
	if(level.code==536236)
	{
		user iprintln ("Password Correct");
		platform = getent ("jm_lockover_no_door","targetname");
		wait(2);
		platform moveX (64,2,0.5,0.5);
		platform waittill ("movedone");
		wait(5);
		platform moveX (-64,2,0.5,0.5);
		platform waittill ("movedone");
	}
	else iprintln("Password Denied");
	level.code="";
	self thread checkEnter();
}
What a beauty, I simplified it big time. :D
Have any questions? Just ask!

So your gunna help him and not me... :( thnx nm i thaught we were friends. :'(

Re: Enter The Pin Code To Open The Door

Posted: October 28th, 2008, 7:18 am
by JDogg
zipperdude wrote:
Nightmare wrote:

Code: Select all

main()
{
	level.code="";
	
	for(i=1;i<7;i++)
	{
		trig = getent("jm_lockover_no"+i,"targetname");
		trig thread checkTrig(i);
	}
	getent("jm_lockover_enter","targetname") thread checkEnter();
}

checkTrig(i)
{
	self waittill("trigger",user);
	level.code=level.code+""+i;
	wait 0.05;
	thread checkTrig(i);
}

checkEnter()
{
	self waittill("trigger",user);
	if(level.code==536236)
	{
		user iprintln ("Password Correct");
		platform = getent ("jm_lockover_no_door","targetname");
		wait(2);
		platform moveX (64,2,0.5,0.5);
		platform waittill ("movedone");
		wait(5);
		platform moveX (-64,2,0.5,0.5);
		platform waittill ("movedone");
	}
	else iprintln("Password Denied");
	level.code="";
	self thread checkEnter();
}
What a beauty, I simplified it big time. :D
Have any questions? Just ask!

So your gunna help him and not me... :( thnx nm i thaught we were friends. :'(
Well you thought wrong then huh. Only kidding, NM prolly just forgot :shock:.

Re: Enter The Pin Code To Open The Door

Posted: October 28th, 2008, 11:07 pm
by zipperdude
JDogg wrote:
zipperdude wrote:
Nightmare wrote:

Code: Select all

main()
{
	level.code="";
	
	for(i=1;i<7;i++)
	{
		trig = getent("jm_lockover_no"+i,"targetname");
		trig thread checkTrig(i);
	}
	getent("jm_lockover_enter","targetname") thread checkEnter();
}

checkTrig(i)
{
	self waittill("trigger",user);
	level.code=level.code+""+i;
	wait 0.05;
	thread checkTrig(i);
}

checkEnter()
{
	self waittill("trigger",user);
	if(level.code==536236)
	{
		user iprintln ("Password Correct");
		platform = getent ("jm_lockover_no_door","targetname");
		wait(2);
		platform moveX (64,2,0.5,0.5);
		platform waittill ("movedone");
		wait(5);
		platform moveX (-64,2,0.5,0.5);
		platform waittill ("movedone");
	}
	else iprintln("Password Denied");
	level.code="";
	self thread checkEnter();
}
What a beauty, I simplified it big time. :D
Have any questions? Just ask!

So your gunna help him and not me... :( thnx nm i thaught we were friends. :'(
Well you thought wrong then huh. Only kidding, NM prolly just forgot :shock:.
lol

Re: Enter The Pin Code To Open The Door

Posted: October 29th, 2008, 3:50 am
by Nightmare
The best way is to do some error checking with iprintln.
Try this:

Code: Select all

main()
{

	level.codeCount=0;
	level.code="";
	iprintln("I'm starting the loop.");
	for(i=1;i<7;i++) //Change 4 to however many triggers you have
	{
		trig = getent("jm_lockover_no"+i,"targetname");
		if(!isDefined(trig))
		{
			iprintln("^1Sorry, but I can't find trigger "+i+"!");
		}
		else
		{
			trig thread checkTrig(i);
			iprintln("I've gotten trigger "+i+" ready!");
		}
	}
	iprintln("Finished looping, my work here is done!");
}

checkTrig(i)
{
	while(1)
	{
		iprintln("Trigger "+i+" is waiting to be triggered!");
		self waittill("trigger",user);
		iprintln("Trigger "+i+" has been triggered!");
		if(level.codeCount<6) //Change 3 with however long your code is.
		{
			iprintln("The code count is lower than 6, let me add this to the code.");
			level.code=level.code+""+i;
			level.codeCount++;
		}
		if(level.codeCount==6) //Change 3 with however long your code is
		{
			iprintln("The code count equal to 6, lets check if it is right.");
			if(level.code==536236) //Change 123 to whatever code you want
			{
				user iprintln ("Password Correct");
				platform = getent ("jm_lockover_no_door","targetname");
				wait(2);
				platform moveX (64,2,0.5,0.5);
				platform waittill ("movedone");
				wait(5);
				platform moveX (-64,2,0.5,0.5);
				platform waittill ("movedone");
			}
			else
			{
				iprintln("Password Denied");
			}
			level.codeCount=0;
			level.code="";
		}
	}
}