How to do a door swing lock script?
the door is :castle_1
script area: Shut1
this is the script if you can help:
Code:
void OnStart(){ AddEntityCollideCallback("Player", "Shut1", "CloseDoors", true, 1);}
void OnEnter(){}
void OnLeave(){}
void CloseDoors(string &in asParent, bool abChild, bool abEffects){ setSwingDoorLocked("castle_1", true, true);}
void OnStart()
{
AddEntityCollideCallback("Player", "Shut1", "CloseDoors", true, 1);
}
void CloseDoors(string &in asParent, bool abChild, bool abEffects)
{
setSwingDoorLocked("castle_1", true, true);
}
That should work
This should work. Includes the wind sound. If the sound does not play, you will have to make a Script Area near the door, title it something and change the name at: "PlaySoundAtEntity("", "general_wind_whirl.snt", "
castle_1", 0, false);" to the name of the Script Area and it will work fine. Also, organizing your script with "Enter"s and "Tab"s can help a LOT.
Your issues(fixed):
- An entity collide does not have "bool abEffects", It is "int alState".
- SetSwingDoorLocked was spelled: "setSwingDoorLocked" again with the capitalizations buddy =]
Just copy and paste this all.
Code:
void OnStart()
{
AddEntityCollideCallback("Player", "Shut1", "CloseDoors", true, 1);
}
void OnEnter()
{
}
void OnLeave()
{
}
void CloseDoors(string &in asParent, bool abChild, int alState)
{
SetSwingDoorLocked("castle_1", true, true);
PlaySoundAtEntity("", "general_wind_whirl.snt", "castle_1", 0, false);
}
(11-11-2011, 01:24 PM)proshitness Wrote: [ -> ]the door didn't work =\
Didn't work? Are you talking about locking a closed door, or by slamming an open door shut and than lock the door?
slamming an open door shut and than lock the door
(11-11-2011, 02:45 PM)proshitness Wrote: [ -> ]slamming an open door shut and than lock the door
well than you need to add propforce:
AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);
Use this instead of PropForce:
SetSwingDoorClosed("castle_1", true, true);
It's much easier
Here is the full thing:
void OnStart()
{
AddEntityCollideCallback("Player", "Shut1", "CloseDoors", true, 1);
}
void CloseDoors(string &in asParent, bool abChild, bool abEffects)
{
SetSwingDoorClosed("castle_1", true, true);
SetSwingDoorLocked("castle_1", true, true);
}