Frictional Games Forum (read-only)

Full Version: -Simple- key open door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I dunno how to get a key to open a door. How do I do this.
Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like
It keeps saying Item cannot be used this way.

This is what I have:


void OnStart()
{
AddUseItemCallback("", "key1", "door1", "OpenS", true);
}

void OpenS(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
RemoveItem("key1");
}

See anything wrong?

Keyname: key1
Doorname: door1
(06-23-2012, 09:12 AM)andyrockin123 Wrote: [ -> ]Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like
Y U NO Play sound at entity? Tongue

Anyways Andy, I've had a goddamned problem ever since i couldn't get that closet open with a crowbar, I can't make a key unlock a door no matter every right thing i do Huh
(06-23-2012, 11:07 AM)CrazyArts Wrote: [ -> ]
(06-23-2012, 09:12 AM)andyrockin123 Wrote: [ -> ]Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like
Y U NO Play sound at entity? Tongue

Anyways Andy, I've had a goddamned problem ever since i couldn't get that closet open with a crowbar, I can't make a key unlock a door no matter every right thing i do Huh
ME TO
Have you checked the file name of the HPS file to see if it matches the file name of the MAP file?
(06-23-2012, 12:28 PM)Your Computer Wrote: [ -> ]Have you checked the file name of the HPS file to see if it matches the file name of the MAP file?
Ofcourse i have, i have checked everything.

Heck, desperately i've even copied the script from another custom story to see if it works, still no.
Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.
(06-23-2012, 12:35 PM)andyrockin123 Wrote: [ -> ]Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.
How do I get a hps file template?
(06-23-2012, 12:35 PM)andyrockin123 Wrote: [ -> ]Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.
I've got that alredy! It's the same problem with the closet, Cannot use item this way. Dammit this is slowing down my development every day Sad
Pages: 1 2