Frictional Games Forum (read-only)

Full Version: [SOLVED] Setting message on interacting with entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
EDIT: Tried to delete this, but can't and great reply posted, so I will try and re-type the question...

How do I set a collidecallback for the player interacting with a LOCKED door?
What you need to do is select your entity in the level editor and go to the entity tab, from there enter something into the PlayerInteractCallback field (like "InteractDoor")

Then go into your code for that level and type something like
Code:
void InteractDoor(string &in asEntity)
{
    if(GetLocalVarInt("Door") != 1)
    {
        SetMessage("Message", "Message", 0);
    }
    else
    {

    }
}

In the above example lets say the variable goes to 1 when the player picks up the key. Anytime he interacts with it before the key the message will show, and anytime he interacts with it and he has the key nothing will happen.
(01-18-2011, 12:59 AM)triadtimes Wrote: [ -> ]What you need to do is select your entity in the level editor and go to the entity tab, from there enter something into the PlayerInteractCallback field (like "InteractDoor")

Then go into your code for that level and type something like
Code:
void InteractDoor((string &in asEntity)
{
    if(GetLocalVarInt("Door") != 1)
    {
        SetMessage("Message", "Message", 0);
    }
    else
    {

    }
}

In the above example lets say the variable goes to 1 when the player picks up the key. Anytime he interacts with it before the key the message will show, and anytime he interacts with it and he has the key nothing will happen.

YAY! Thank you! Big Grin
Nice. Useful to me ^^ Thanks Smile
Alternatively, you could also use if(HasItem("NameOfKey") == false)
When I use this code, the message still shows when the door is opened. (and the used key destroyed)
i.e. when I open the door or close it, it still says (in my case): This door is closed.
How do I change this, when the key used to open the door is removed from my inventory?