Frictional Games Forum (read-only)

Full Version: Key help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having a problem getting a key to open a door, can you please help?
waterworks_door=Door
waterworks_key=Key
Here is the script:

void OnStart()
{
AddUseItemCallback("", "waterworks_key", "waterworks_door", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("waterworks_door", false, true);
PlaySoundAtEntity("", "unlock_door", "waterworks_door", 0, false);
RemoveItem("waterworks_key");
}

note: I have more script than this but it is working fine.

Thanks Smile
Doesn't look like it's wrong. Are you getting an error or something? Are the names in the editor and script correct (exactly the same)?
(09-26-2012, 08:25 PM)Nemet Robert Wrote: [ -> ]Doesn't look like it's wrong. Are you getting an error or something? Are the names in the editor and script correct (exactly the same)?
I don't get an error message on start-up of my CS, but when I use the key on the door it either doesn't unlock, or I get the message "can't use item in this way" or something. Sad
(09-27-2012, 05:13 AM)wagiwombledog Wrote: [ -> ]
(09-26-2012, 08:25 PM)Nemet Robert Wrote: [ -> ]Doesn't look like it's wrong. Are you getting an error or something? Are the names in the editor and script correct (exactly the same)?
I don't get an error message on start-up of my CS, but when I use the key on the door it either doesn't unlock, or I get the message "can't use item in this way" or something. Sad

make sure you have both the names of the key and the door in the level editor correctly matching. you have to press enter once youve typed in the name of an entity in the level editor, or else it'll go back to default. id check some errors in the script but im out of time atm