Frictional Games Forum (read-only)

Full Version: unlock door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm new doing stories, but I really wanna do one. Now I have a problem with unlock a door, I saw tutorials, and I did what they said but didin't work.
my key's name is firstdoorkey and door's name is firstdoor.
I've got this is my ola.hps:
////////////////////////////
// Run first time starting map
void OnStart()
{
(
AddUseItemCallback("", "firstdoorkey", "firstdoor", "UsedKeyOnDoor", "true");
)

void MyFunc(string &in asItem, string &in asEntity)
(
SetSwingDoorLocked("firstdoor", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor", 0, false);
RemoveItem("firstdoorkey");
)
////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}




and this in my extra english lang:

<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Hello There! Welcome to my first custom story, hope you enjoy! Big Grin</Entry>
<CATEGORY>
<CATEGORY Name="Inventory>
<Entry Name="ItemDesc_firstdoorkey">"Key to First door"</Entry>
<Entry Name="ItemName_firstdoorkey">First door key</Entry>

</CATEGORY>
<LANGUAGE>



so, can someone find any probem? Thanks so much! Big Grin
I'll walk you through the mistakes then post a full revision Big Grin

Spoiler below!

void OnStart()
{ <-----Extra bracket
( <---Here you used parentheses instead of a bracket
AddUseItemCallback("", "firstdoorkey", "firstdoor", "UsedKeyOnDoor", "true"); <----true should not be declared (in quotation marks)
) <---Here you used parentheses instead of a bracket

void MyFunc(string &in asItem, string &in asEntity) <---This function is MyFunc, but in the callback you used UsedKeyOnDoor
( <---Here you used parentheses instead of a bracket
SetSwingDoorLocked("firstdoor", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor", 0, false);
RemoveItem("firstdoorkey");
) <---Here you used parentheses instead of a bracket



Finally, here's a full revision; copy and paste this into your hps file. Make sure to delete any previous contents:

Spoiler below!


void OnStart()
{
AddUseItemCallback("", "firstdoorkey", "firstdoor", "UsedKeyOnDoor", true);
}

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



void OnEnter()
{

}


void OnLeave()
{

}


If you have any more problems after this, they're not script (hps) related.

Hope that helped!
wow, Andyrockin went faster than me.

Well, rodrigo, Andyrockin's script should be useful for you. Also, this site is a very good one for you:

http://wiki.frictionalgames.com/hpl2/tutorials/start

Here are a lot of tutorials.
I just copy that instead of mine and...... it worked!! thank you so much man Big Grin

Thank you too, The chaser