Door script

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

Moderator: Core Staff

Post Reply
xxG
CJ Wannabe
CJ Wannabe
Posts: 2
Joined: January 27th, 2013, 10:39 am

Door script

Post by xxG » January 30th, 2013, 3:53 pm

Please help me with the script

Code: Select all

main()
{
 doortriggers = getentarray( "doortrig", "targetname" );
 for(i=0;i<doortriggers.size;i++)
 doortriggers[i] thread door_think();
}
 
door_think()
{
 self.doormoving = false;
 self.doorclosed = true;
 self.doormodel = getent(self.target, "targetname");
 
 while (1)
 {
 self waittill("trigger");
 if(!self.doormoving)
 self thread door_move();
 }
}
 
door_move()
{
 self.doormoving = true;
 if(self.doorclosed)
 {
 self.doormodel rotateyaw(-90,1,0.5,0.5);
 self.doormodel waittill("rotatedone");
 self.doorclosed = false;
 }
 else
 {
 self.doormodel rotateyaw(90,1,0.5,0.5);
 self.doormodel waittill("rotatedone");
 self.doorclosed = true;
 }
 self.doormoving = false;
}
I want to trigger the use of the door was opened and waited for 5 seconds then closes.
Last edited by Anonymous on January 30th, 2013, 3:56 pm, edited 1 time in total.
Reason: Added "cod" tag to the code for colour :)

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

Re: Door script

Post by Drofder2004 » January 30th, 2013, 9:21 pm

The script you are using is a door toggle.

Code: Select all

main()
{
   doortriggers = getentarray( "doortrig", "targetname" );
   for(i=0;i<doortriggers.size;i++)
      doortriggers[i] thread door_think();
}
 
door_think()
{
   self.doormodel = getent(self.target, "targetname");
 
   while (1)
   {
      self waittill("trigger");
      self door_move(); /* Removing 'thread' will pause the script until door is closed */
   }
}
 
door_move()
{
   /* Open Door */
   self.doormodel rotateyaw(-90,1,0.5,0.5);
   self.doormodel waittill("rotatedone");
 
   wait 5; /* 5 Second Wait */
 
   /* Door Close */
   self.doormodel rotateyaw(90,1,0.5,0.5);
   self.doormodel waittill("rotatedone");
}
Just in case you have no idea what the script does and requires. You must create a trigger with key/value of "targetname/doortrig", then create a door (script_brushmodel) and finally connect the two (click trigger, then click door, press 'W').
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

xxG
CJ Wannabe
CJ Wannabe
Posts: 2
Joined: January 27th, 2013, 10:39 am

Re: Door script

Post by xxG » January 31st, 2013, 6:37 pm

Thanks it works

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests