Key input?

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

Moderator: Core Staff

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Key input?

Post by Pedsdude » February 18th, 2006, 1:15 am

Is it possible to press keys in a certain order to say open a door? For example, would it be possible to create a script so that if you press "a, b, c, d" a door opens?

It's a long-shot, but I hope someone knows how to do it...
Image
Image

User avatar
hambones
CJ Worshipper
CJ Worshipper
Posts: 312
Joined: December 19th, 2005, 10:58 pm
Location: ^^^ boom... HEADSHOT?

Post by hambones » February 18th, 2006, 1:29 am

Image


"It's so funny of how I think my life is supposed to be devoid of any sort of heartache or drama or anguish or pain. It's sad but I think that I make a value of my days by the times I wake up and feel somewhat normal, but what I really need to do is get out of this fucking house and get laid."

JammY
CJ Newbie
CJ Newbie
Posts: 77
Joined: October 25th, 2005, 1:42 pm
Location: Hertfordshire. UK

Post by JammY » February 18th, 2006, 1:35 am

spose you could do a thing like marshalls house of pain door at the start but have 5 or so scripts for each door?
Add me on XFIRE : asross

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

Post by Drofder2004 » February 18th, 2006, 2:01 am

You can only detect input for 3 keys.

UseButtonPressed();
MeleeButtonPressed();
AttackButtonPressed();

you can use these together for eaxmple..

if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
Open door.

Basically the script says...
if the user is touching the trigger and they press their use button and their melee button, then the door will open.

Very complicated but it works ;)

(Do not listen to hambones, never go to modsonline, that way I have no use here :P)
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

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 18th, 2006, 2:33 am

Ah k, will try it out after I have created all of my hurt triggers.
Drofder2004 wrote:(Do not listen to hambones, never go to modsonline, that way I have no use here :P)
I knew there wasn't a chance in hell of me finding it on modsonline ;) Do you just know all of this information or do you search for it? lol
Image
Image

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

[

Post by Pedsdude » February 18th, 2006, 5:01 pm

Code: Select all

main()
{
thread secretdoor();
}

secretdoor()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");
while(1)
   {
   trigger waittill ("trigger");
   if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
      {
      secretdoor moveZ (112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait(2);
      secretdoor moveZ (-112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait 0.5;
      }
   else
      {
      wait 0.5;
      }
   }
}
Above is the code I used, below is the error I got.

Image
Image
Image

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

Post by Drofder2004 » February 18th, 2006, 8:03 pm

Ok, you cannot just put that code anywhere :P It needs adapted.

First off, what sort of trigger is it? [Multiple/Hurt/Use]

Also you have not said what "self" is. Self does not directly relate to a player, it can be a trigger if you wanted it to ;)

This may or may not work (I am unsure what the error means)

Code: Select all

main()
{
thread secretdoor();
}

secretdoor()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");
while(1)
   {
   trigger waittill ("trigger",player);
   if(player isTouching(trigger) && player useButtonPressed() && player meleeButtonPressed())
      {
      secretdoor moveZ (112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait(2);
      secretdoor moveZ (-112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait 0.5;
      }
   else
      {
      wait 0.5;
      }
   }
} 
The thing with the code is, I do not think it will work with 2 people both trying to use the trigger, as the trigger is waiting for 1 person to trigger it and only that 1 person can also open the door.

This is a second idea for it.

Code: Select all

main()
{
thread secretdoor();
}

secretdoor()
{
players = getEntArray("player", "classname");
for(i=0; i<players.size; i++)
   players[i] thread door_think();
}

door_think()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");

while(1)
   {
   trigger waittill ("trigger",self);
   if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
      {
      secretdoor moveZ (112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait(2);
      secretdoor moveZ (-112,1,0.5,0.5);
      secretdoor waittill ("movedone");
      wait 0.5;
      }
   else
      {
      wait 0.5;
      }
   }
} 
Again, this is all semi off the top of my head, so it may not work. Trial and error ;)
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

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 18th, 2006, 10:30 pm

The trigger is a use (I guessed that use would be the one to use). I'll try both ideas and will get back to you ;)
Image
Image

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 18th, 2006, 11:17 pm

The first code worked fine, although it seemed to interfere with the save mod. When I try and load a position it causes the game to stop with a script runtime error:

Image
Image
Image

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

Post by Drofder2004 » February 19th, 2006, 3:22 am

I recommend whatever your trying to do, use switchs or triggers as what your currently trying to achieve is very complex for a single map ;)
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

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 19th, 2006, 4:28 pm

lol :)

Is there actually any way I can avoid it interfering with the save mod or is that unavoidable?
Image
Image

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

Post by Luke » February 19th, 2006, 5:00 pm

Pedsdude wrote:The first code worked fine, although it seemed to interfere with the save mod. When I try and load a position it causes the game to stop with a script runtime error:

Image
Its probably because you had it on developer mode - speaking from experience :P

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 19th, 2006, 6:03 pm

It's funny how the most complicated scripting bits are actually secret bits that only I plan to use :P lmao
Image
Image

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

Post by Drofder2004 » February 19th, 2006, 9:09 pm

Pedsdude wrote:It's funny how the most complicated scripting bits are actually secret bits that only I plan to use :P lmao
Give me 3 minutes on your new map and I will have found your secrets ;)
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

Pedsdude
Site Admin
Site Admin
Posts: 15914
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » February 19th, 2006, 11:41 pm

Give it your best shot :P
Image
Image

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Semrush [Bot] and 2 guests