Creating a Password Script

Tutorials for Call of Duty mapping

Moderator: Core Staff

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

Creating a Password Script

Post by Nightmare » April 22nd, 2009, 2:00 am

Warning, the code below is for advanced coders only, feel free to ask questions anyway.

Constantly checking password script: checks each time a trigger is triggered.

Code: Select all

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

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

	for(i=1;i<n;i++) //Change n to however many triggers you have
	{
		trig = getent("trigName"+i,"targetname"); //Replace trigName with the targetname in your map
		trig thread checkTrig(i);
	}
}

checkTrig(i)
{
	while(1)
	{
		self waittill("trigger",user);
		if(level.codeCount<3) //Change 3 with however long your code is.
		{
			level.code=level.code+""+i;
			level.codeCount++;
		}
		if(level.codeCount==3) //Change 3 with however long your code is
		{
			if(level.code==123) //Change 123 to whatever code you want
			{
				//Do Stuff Here if Correct
			}
			else
			{
				//Do Stuff Here if Incorrect
			}
			level.codeCount=0;
			level.code="";
		}
	}
}
Enter only password script: checks only when the "enter" trigger is triggered.

Code: Select all

main()
{
	level.code="";
   
	for(i=1;i<7;i++)
	{
		trig = getent("trigName"+i,"targetname");  //Replace trigName with the targetname in your map
		trig thread checkTrig(i);
	}
	getent("trigEnter","targetname") thread checkEnter(); //Replace trigEnter with the targetname in your map
}

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

checkEnter()
{
	self waittill("trigger",user);
	if(level.code==123)  //Change 123 to whatever code you want
	{
		//Do Stuff Here if Correct
	}
	else
	{
		//Do Stuff Here if Incorrect
	}
	level.code="";
	self thread checkEnter();
}
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
helium
CJ Spammer!
CJ Spammer!
Posts: 718
Joined: December 31st, 2007, 9:04 am
Location: Sweden

Re: Creating a Password Script

Post by helium » April 22nd, 2009, 3:15 am

i cba to look through the code (sry) but i'd like to know what exactly this code does? i remember i made a code in another game where u could type something in ur console to open a door, is this something similar?
Image

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Re: Creating a Password Script

Post by JDogg » April 22nd, 2009, 9:32 am

helium wrote:i cba to look through the code (sry) but i'd like to know what exactly this code does? i remember i made a code in another game where u could type something in ur console to open a door, is this something similar?
I'm assuming it's a keypad for a door.
Image
Image

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Creating a Password Script

Post by waywaaaard » April 22nd, 2009, 3:14 pm

you need eg. 10 triggers with the number 0-9 now you got the code 1470 and the script checks if somebody triggered the triggers in the right combination
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

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

Re: Creating a Password Script

Post by Nightmare » April 23rd, 2009, 1:52 am

Lev!athan wrote:you need eg. 10 triggers with the number 0-9 now you got the code 1470 and the script checks if somebody triggered the triggers in the right combination
I made my script as flexible as possible, therefore you can have as many keys as you want.
Be it 1 to 9 buttons, or even with a little tweaking, it can be brought to much larger numbers.
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]

soyeurrr
CJ Wannabe
CJ Wannabe
Posts: 3
Joined: April 27th, 2009, 12:36 am

Re: Creating a Password Script

Post by soyeurrr » April 27th, 2009, 12:40 am

hi nightmare do you play yet? and on what server? when did you begin cod1?

BatterY
CJ Worshipper
CJ Worshipper
Posts: 238
Joined: January 29th, 2010, 10:27 pm

Re: Creating a Password Script

Post by BatterY » April 13th, 2010, 6:25 pm

Dun know where this is supposed to go, but i have number triggers 1-4 and an enter trigger (all are trigger_uses)
How i make it so you press 1 2 3 4 and enter that it accepts it as code?

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

Re: Creating a Password Script

Post by Drofder2004 » April 13th, 2010, 6:41 pm

You need to give the triggers targetname values
trigName1, trigName2, etc

You also need ot change the IF statements from 3 to the length of your password.

Finally change 123 to your password.
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
JuMPZoR
CJ Newbie
CJ Newbie
Posts: 88
Joined: May 16th, 2010, 7:23 pm

Re: Creating a Password Script

Post by JuMPZoR » May 16th, 2010, 9:47 pm

What do I put in the map to press the buttons? Trigger_multiple?
Image

Image

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

Re: Creating a Password Script

Post by Drofder2004 » May 17th, 2010, 12:14 am

JuMPZoR wrote:What do I put in the map to press the buttons? Trigger_multiple?
trigger_use.
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
Perplex
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: March 5th, 2010, 12:02 pm
Location: Germany

Re: Creating a Password Script

Post by Perplex » January 12th, 2011, 11:37 pm

Sry guys that iam reopening this Thread, but i have a problem with my script.

I have make a Keypad in my Map like this

X X X

X X X

X X X

X XXXX

than i have creat a trigger_use for all 10 numbers and the enter button. Now i have called the triggers trigName1,trigName2,trigName3 etc etc and trigEnter. Now when iam stand on my keypad and press F(use) it will not work :(

here is my script

Code: Select all

main()
{
   level.code="5";
   
   for(i=0;i<10;i++)
   {
      trig = getent("trigName"+i,"targetname");  
      trig thread checkTrig(i);
   }
   getent("trigEnter","targetname") thread checkEnter(); 
}

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

checkEnter()
{
   self waittill("trigger",user);
   if(level.code==12345)  
   {
      self iPrintLn("^5*^2Password Correct^5*");
   }
   else
   {
	self iPrintLn("^5*^1Password Denied^5*");
   }
   level.code="5";
   self thread checkEnter();
}
i hope anyone can help me :(

thx

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Creating a Password Script

Post by megazor » January 13th, 2011, 5:46 am

that was an odd script. i have fixed it:

Code: Select all

main()
{
   	level.code = "";
   
   	for (i = 0; i < 10; i++)
     		getent("trigName"+i, "targetname") thread checkTrig(i);
   	getent("trigEnter","targetname") thread checkEnter();
}

checkTrig(i)
{
   	self waittill("trigger", user);
	level.code += i;
   	user iPrintLn(i);	//this prints only one digit; do 'user iPrintLn(level.code)' to show the whole code
   	self thread checkTrig(i);
}

checkEnter()
{
   	self waittill("trigger", user);
   	if (level.code == 12345) 
      		self iPrintLn("^5*^2Password is Correct^5*");
   	else
   		self iPrintLn("^5*^1Password is Wrong^5*");
  	level.code = "";
   	self thread checkEnter();
}

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Creating a Password Script

Post by megazor » January 13th, 2011, 5:48 am

shit, forget the code i posted, here is the correct one:

Code: Select all

main()
{
   	level.code = "";
   
   	for (i = 0; i < 10; i++)
     		getent("trigName"+i, "targetname") thread checkTrig(i);
   	getent("trigEnter","targetname") thread checkEnter();
}

checkTrig(i)
{
   	self waittill("trigger", user);
	level.code += i;
   	user iPrintLn(i);	//this prints only one digit; do 'user iPrintLn(level.code)' to show the whole code
   	self thread checkTrig(i);
}

checkEnter()
{
   	self waittill("trigger", user);
   	if (level.code == 12345) 
      		user iPrintLn("^5*^2Password is Correct^5*");
   	else
   		user iPrintLn("^5*^1Password is Wrong^5*");
  	level.code = "";
   	self thread checkEnter();
}

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests