Frictional Games Forum (read-only)

Full Version: Automatic open door script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I make a script, when door must open automaticly. It din't work. Working only sound.
.hps file:
void OnStart()
{
AddEntityCollideCallback("Player", "quest1", "Memento1", true, 1);
AddEntityCollideCallback("Player", "DoorScriptArea1", "EventDoor", true, 1);
}

void Memento1(string &in asParent, string &in asChild, int alState)
{
AddQuest("area", "quest1");
}

void EventDoor(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DoorScripted1", false, false);
SetSwingDoorDisableAutoClose("DoorScripted1", true);

PlaySoundAtEntity("creak", "joint_door_move_special.snt", "DoorScripted1", 1, false);

AddTimer("", 2, "TimerStopSound");
AddTimer("DoorScripted1", 0, "TimerMoveDoor");
}

void TimerMoveDoor(string &in asTimer)
{
if(GetLocalVarInt("VarDoor") == 10) return;
AddLocalVarInt("VarDoor", 1);

AddTimer(asTimer, 0.03, "TimerMoveDoor");

AddPropForce(asTimer, -70, 0, 0, "world");
}

void TimerStopSound(string &in asTimer)
{
StopSound("creak", 0.4);
}
its possible that you didn't match the names of something. did you match up "DoorScripted1" with whats in you hpl?
Change this
PHP Code:
AddTimer("DoorScripted1"0"TimerMoveDoor"); 
to this
PHP Code:
AddTimer("DoorScripted1"0.05"TimerMoveDoor"); 

This line here:
PHP Code:
AddPropForce(asTimer, -7000"world"); 
This is correct, but make sure of a few things:

1. asTimer here would mean that your door would be named TimerMoveDoor in the Level Editor. If not, then make sure it is! Tongue
2. The numbers may need to be tweaked, depending on which way your door faces. Try these alterations as well:
PHP Code:
AddPropForce(asTimer7000"world");
AddPropForce(asTimer00, -70"world");
AddPropForce(asTimer0070"world"); 
(01-03-2015, 01:54 PM)Romulator Wrote: [ -> ]Change this
PHP Code:
AddTimer("DoorScripted1"0"TimerMoveDoor"); 
to this
PHP Code:
AddTimer("DoorScripted1"0.05"TimerMoveDoor"); 

This line here:
PHP Code:
AddPropForce(asTimer, -7000"world"); 
This is correct, but make sure of a few things:

1. asTimer here would mean that your door would be named TimerMoveDoor in the Level Editor. If not, then make sure it is! Tongue
2. The numbers may need to be tweaked, depending on which way your door faces. Try these alterations as well:
PHP Code:
AddPropForce(asTimer7000"world");
AddPropForce(asTimer00, -70"world");
AddPropForce(asTimer0070"world"); 

It din't work.
Quote:AddPropForce(asTimer, 70, 0, 0, "world");
AddPropForce(asTimer, 0, 0, -70, "world");
AddPropForce(asTimer, 0, 0, 70, "world");
Try more!!!
I had HAVE this as well everytime..
Some doors just wont get to move from it's hinges..
You could add MORE force, i have doors witch need for examplé;
PHP Code:
AddPropForce(asTimer005000"world"); 
---
Try using ridiculous numbers to see if it is actually working!
Then lower it's values..
FIRST you need to see if it is going open to the RIGHT direction.
Good luck, this specific question needs to be tested by the user itself, THIS time a little more then other questions.
Yep, 70 is almost nothing.

or use the Impulse one instead of Force
Yeah, Force with the quantity of 70 is worthless. The all-mighty wiki said that to use quantities from 1000 to 10000.

EDIT:
Or you could just use Impulse, but 70 is way too much. An quantity of 1 - 10 is enough.