10-13-2014, 05:18 PM
I have a script where if the player goes through an area where a door is, and has certain items in their inventory, the door will close and lock itself behind them. When they go through the area, I'm using HasItem(); to check that they have the items, but the door doesn't close or lock.
My code:
My code:
Code:
void OnStart()
{
AddEntityCollideCallback("Player", "enabledoorscript", "DoorScript", false, 1); //area to check if the door should close or not depending on if the player has items
}
void DoorScript(string &in asParent, string &in asChild, int alState)
{
if(HasItem("ITEM1") && HasItem("ITEM2") && HasItem("ITEM3")) //checking for items
{
AddEntityCollideCallback("Player", "closedoor", "CloseDoor", true, 1); //they do, so add the collision callback for the area
}
}
void CloseDoor(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("door1", true, true); //close the door
SetSwingDoorLocked("door1", true, true); //lock the door
}