Frictional Games Forum (read-only)

Full Version: Why is the key to door script not working to me?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I tried to do everything but it just won't unlock the damn door!
This is my script:

void OnStart()
{
AddUseItemCallback("", "key", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key", "OnPickup");
}
void UsedKeyOnDoor("key", "locked_door1")
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key");
}
void OnPickup(string &in asEntity, string &in type)
{
    SetEntityActive("servant_grunt_1", true);
    ShowEnemyPlayerPosition("servant_grunt_1");
}

Just pls tell me what is wrong or missing!
void OnStart()

{

AddUseItemCallback("", "key", "locked_door1", "UsedKeyOnDoor", true);

SetEntityCallbackFunc("key", "OnPickup");

}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{

SetSwingDoorLocked("locked_door1", false, true);

PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);

RemoveItem("key");

}

void OnPickup(string &in asEntity, string &in type)

{

SetEntityActive("servant_grunt_1", true);

ShowEnemyPlayerPosition("servant_grunt_1");

}

There, I think it should work now.
Thanks ,but it didn't work I don't know why but it didn't!

But still thanks.
Check if the names in the level editor and the script match. If there's any .map_cache, delete it.
And, remain that your script must end with .hps (for example, level.hps) and that it must match with the name of your map.
void OnStart()
{
AddUseItemCallback("", "key", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key");
}
void OnPickup(string &in asEntity, string &in type)
{
    SetEntityActive("servant_grunt_1", true);
    ShowEnemyPlayerPosition("servant_grunt_1");
}


This should work.


If it doesn't, you probably haven't matched the names properly. "locked_door1" must be the name of the door in the level editor.

"key" must be the name of the key in the level editor.

Are you trying to open a swing door? Or a level door? A swing door doesn't load another map. A level door does.
A cache file has created it self in my CS map folder, should I delete it or leave it there?
DELETE IT
.map_cache are some kind of memory of the map, and the game will load them instead the .map. That means, that if you make changes in your map, and there's a .map_cache, when you start your map in Amnesia, the changes won't be shown.
Did but still it doesn't work .I checked all names and its good,soooo...
WHAT THE HELL IS WRONG??
Are the names for your doors/scripts/keys matching with that in the level editor?

Also, is your account the administrator on your computer?
Pages: 1 2