Frictional Games Forum (read-only)
Why is the key to door script not working to me? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Why is the key to door script not working to me? (/thread-22321.html)

Pages: 1 2


Why is the key to door script not working to me? - Wolfpa - 08-04-2013

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!


RE: Why is the key to door script not working to me? - The chaser - 08-04-2013

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.


RE: Why is the key to door script not working to me? - Wolfpa - 08-04-2013

Thanks ,but it didn't work I don't know why but it didn't!

But still thanks.


RE: Why is the key to door script not working to me? - The chaser - 08-04-2013

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.


RE: Why is the key to door script not working to me? - FurtherGames - 08-04-2013

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.


RE: Why is the key to door script not working to me? - Wolfpa - 08-05-2013

A cache file has created it self in my CS map folder, should I delete it or leave it there?


RE: Why is the key to door script not working to me? - PutraenusAlivius - 08-05-2013

DELETE IT


RE: Why is the key to door script not working to me? - The chaser - 08-05-2013

.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.


RE: Why is the key to door script not working to me? - Wolfpa - 08-05-2013

Did but still it doesn't work .I checked all names and its good,soooo...
WHAT THE HELL IS WRONG??


RE: Why is the key to door script not working to me? - Tomato Cat - 08-05-2013

Are the names for your doors/scripts/keys matching with that in the level editor?

Also, is your account the administrator on your computer?