Results 1 to 3 of 3

Thread: About doors :)

  1. #1
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts

    About doors :)

    How can I do so many doors without using a function for each one?

    I mean, I dont want to do this:

    PHP Code:
    main()
    {
    thread door1();
    thread door2();
    thread door3();
    }

    door1()
    {
    ... 
    I want to make like a script which allows you to open every door, instead of using a new function for each one. I know this because I've seen in jm_cruise map. I also know that I must use arrays, but it's a bit hard for me

    Can you help me? Any help will be appreciated <3

  2. #2
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Code:
    // create a prefab (new map)
    // model your door -> script_model or script-brushmodel
    // select your trigger first then your door hit W (arrow from trig to door appears)
    // save it and paste this prefab as many times as you like in your map
    
    init()
    {
    	doorTrigs = getEntArray( "targetname" , "trigger_door" ); // maybe switch params
    
    	for( i = 0 ; i < doorTrigs.size ; i++ )
    	{
    		if( !isDefined( doorTrigs[i].target ) )
    			continue;
    
    		door = getEnt( doorTrigs[i].target , "targetname" ); // maybe switch params
    
    		if( !isDefined( door ) )
    			continue;
    
    		doorTrigs[i] thread doorThink( door );
    	}
    }
    
    doorThink( door )
    {
    	while( isDefined( self ) )
    	{
    		self waittill( "trigger" , player );
    
    		door rotateYaw( 90 , 1.0 );
    
    		door waittill( "rotatedone" );
    
    		self waittill( "trigger" , player );
    
    		door rotateYaw( -90 , 1.0 );
    
    		door waittill( "rotatedone" );
    	}
    }

  3. The Following 3 Users Say Thank You to serthy For This Useful Post:

    kung foo man (1st February 2014),pollo (2nd February 2014),smect@ (2nd February 2014)

  4. #3
    Private pollo's Avatar
    Join Date
    Jul 2012
    Location
    Spain
    Posts
    116
    Thanks
    93
    Thanked 69 Times in 35 Posts
    Thank you mate

    I was thinking about making doors (not prefabs) and linking the trigger to them, but it linked all of the doors. Ty very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •