Ill explain so you understand what is happening in this script rather than just giving a bunch of code.
So lets start a new script. Create a new .gsc and lets just call it 'door.gsc'. As with any script we need to start it like so:
As you can see the function we are calling is 'door', so we now need to tell the script what 'door' is. To do this we first need to
grab hold of your door and its trigger. The door should be a script_brushmodel
and the trigger a trigger_use
door = getent ("door", "targetname");
trig = getent ("doortrigger", "targetname");
As you can see the script is now looking for a script_brushmodel with a targetname of 'door' and a trigger with a targetname of 'doortrigger'. When it finds them we need to tell it what to do with them.
So we want to wait for the door to get triggered. If you remember the trigger is now indentified as 'trig'
so we use:
trig waittill ("trigger");
So somebody has come along a trigggered the trigger, but what happens now? ... Ok being a door we need it to open. So we want it to rotate on the 'Y' axis 90 degrees.
door rotateyaw (-90,1.5);
So you can see that the door will now open 90 degrees in 1.5 seconds. Either of these can be modified to suit your need. Everything is looking good except no sound will play yet so that is what we need to look at next. We want to play a sound you will need to specify in your .csv (which i wont explain at the moment).
The sound specified is ironically called 'open' as you can see in the code. Now it's a good idea to leave the door open for a while before it closes to allow the player to get through. So lets use:
Or in other words, 'wait 3 second before you close again'. Lets assume we waited 3 seconds and now we want to close the door back up. Lets play the 'close door sound' (again specified in your .csv as 'close') and rotate the door back 90 degrees.
door rotateyaw (90,2.25);
Lets do a quick check. We got the targetnames, we then waited for the door to be triggered. We opened the door and played the sound. We waited for the player to get through. We closed the door and played the 'close' sound. Only one thing left and that to tell the script that we are all done.
door waittill ("rotatedone");
Hope this helps.