Frictional Games Forum (read-only)

Full Version: Script help for level door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the script for a locked level door. the key you need is level_4_key.
It is supposed to activate a grunt when the door is unlocked (as a scare).

void UseKey(string &in asItem, string &in asEntity)
{
AddUseItemCallback("", "level_4_key", "level4", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("level4", true);
PlaySoundAtEntity("", "unlock_door", "level4", 0, false);
RemoveItem("level_4_key");
SetEntityActive("servant_grunt", true);
}

Where did I go wrong?
Put
Code:
AddUseItemCallback("", "level_4_key", "level4", "UsedKeyOnDoor", true);
in your OnStart function.

Like this:
PHP Code:
void OnStart()
{
    
AddUseItemCallback("""level_4_key""level4""UsedKeyOnDoor"true);

I thought unlocking level doors use a different script.

EDIT : Never mind.
Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.
(02-10-2013, 02:43 AM)NaxEla Wrote: [ -> ]Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.

Lol. I didn't read it clearly in the first place.
I really need to improve my reading.
(02-10-2013, 02:56 AM)No Author Wrote: [ -> ]
(02-10-2013, 02:43 AM)NaxEla Wrote: [ -> ]Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.

Lol. I didn't read it clearly in the first place.
I really need to improve my reading.

I did notice that. Thanks for pointing it out.