I created a key, but the key doesn't unlock the door. Here are my files.
HPS FILE: (I know "masion_Door" is spelt wrong)
void OnStart()
{
AddUseItemCallback("", "Key1", "masion_Door", "FUNCTION", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void FUNCTION(string &in item, string &in door)
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("item");
}
My extra_english.lang:
<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Dare to enter the castle tombs...</Entry>
</CATEGORY>
<CATEGORY Name="Messages">
<Entry Name="doorlock1">No need to go back outside...</Entry>
</CATEGORY>
</LANGUAGE>
My key name and door name match the names they have inside the editor.
Two things:
Your Lang problem is highlighted in red here:
<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Dare to enter the castle tombs...</Entry>
</CATEGORY>
<CATEGORY Name="Messages">
<Entry Name="doorlock1">No need to go back outside...</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemName_Key1">room key</Entry>
<Entry Name="ItemDesc_Key1">The key for my room.</Entry>
</CATERGORY>
</LANGUAGE>
and your key not unlocking your door, the problem is highlighted in red here:
void OnStart()
{
AddUseItemCallback("item", "Key1", "masion_Door", "FUNCTION", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void FUNCTION(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("item");
}
Make those changes and it should work. Oh and the "item" in your RemoveItem at the end should be changed to RemoveItem("Key1"); if you're wanting it to remove the key that unlocked the door. Unless you actually have an item named "item" it won't work.
Door unlock.
PHP Code:
void OnStart()
{
AddUseItemCallback("", "Key1", "masion_Door", "DoorUnlockKey", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void DoorUnlockKey(string &in asItem, string &in asEntity) //Syntax mistake.
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("KeyNAME");
}
extra_english.lang
PHP Code:
<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Dare to enter the castle tombs...</Entry>
</CATEGORY>
<CATEGORY Name="Messages">
<Entry Name="doorlock1">No need to go back outside...</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemName_KeyNAME">KeyName</Entry>
<Entry Name="ItemDesc_KeyNAME">KeyDesc</Entry>
</CATEGORY>
</LANGUAGE>
My key still doesn't unlock the door. I didn't copy the //Syntax mistake. because I didn't think it was needed.
Here is my HPS file:
void OnStart()
{
AddUseItemCallback("", "Key1", "masion_Door", "DoorUnlockKey", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void DoorUnlockKey(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("item");
}
Are you sure the key and door are named exactly as shown in your HPS? Sometimes even upper case and lower case makes a difference.
(05-01-2013, 12:54 PM)DeAngelo Wrote: [ -> ]Are you sure the key and door are named exactly as shown in your HPS? Sometimes even upper case and lower case makes a difference.
Yes, I assure you.
Inside the level editor:
Key name: Key1
Door name: maison_Door
(I know this is spelt wrong)
I copied them from the level editor to the HPS File.
HPS File:
void OnStart()
{
AddUseItemCallback("", "Key1", "masion_Door", "DoorUnlockKey", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void DoorUnlockKey(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("Key1");
}
You put that in the level editor it's maison_Door but in your script it's masion_Door (the i and s are switched)
(05-01-2013, 01:05 PM)DeAngelo Wrote: [ -> ]You put that in the level editor it's maison_Door but in your script it's masion_Door (the i and s are switched)
Sorry, that was my own typing mistake. It is masion_Door in both the HPS File and the Level Editor.
ONCE AGAIN, MY HPS FILE
void OnStart()
{
AddUseItemCallback("", "Key1", "masion_Door", "DoorUnlockKey", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void DoorUnlockKey(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("masion_Door", false);
PlayGuiSound("unlock.door.snt", 100);
RemoveItem("Key1");
}
This is probably a dumb question, but are you sure that your door is a level door and not just a regular swing door? Barring that, it may be best to just upload your level in a zip so that someone can take a look hands on at the level and the HPS file.
(05-01-2013, 01:12 PM)DeAngelo Wrote: [ -> ]This is probably a dumb question, but are you sure that your door is a level door and not just a regular swing door? Barring that, it may be best to just upload your level in a zip so that someone can take a look hands on at the level and the HPS file.
It's a swing door that isn't unlocking.