Frictional Games Forum (read-only)

Full Version: Script Unlocking Door [HELP]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

ok so.. i got the key working with all the names and things... problem is.. i cant unlock the door now.. i will place my .HPS file and .lang file here..maybe you can guys help me out !

HPS FILE
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

void MyFunc(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("housedoor", false, true);
PlaySoundAtEntity("", "unlock_door", "housedoor", 0, false);
RemoveItem(Housedoorkey);
}

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

}

---------------------------------------------------------

.LANG file

<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description"> A young adult searching for his missing dad ENJOY!!</Entry>
</CATEGORY>
<CATEGORY Name ="Inventory">
<Entry Name="ItemDesc_Housedoorkey">"Our main key of our House"</Entry>
<Entry Name="ItemName_Housedoorkey">" Main House key"</Entry>

</CATEGORY>

</LANGUAGE>

Wretic.
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

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

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









That should work.

Try this Smile////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

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

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

}
it still says Can't Use this item this way! ;[
Tongue im sorry but i dont know anything about scripts sorry!
And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?
(01-30-2012, 08:04 PM)trollox Wrote: [ -> ]And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?
yes
Never suggest to manually type the name of the door and item for the UsedKeyOnDoor function. That's bad programming. One of the reasons for the existence of functions is to not repeat yourself.

A proper function definition would be:
PHP Code:
void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem); // though this is unnecessary given the current use of AddUseItemCallback

(01-30-2012, 08:16 PM)wretic91 Wrote: [ -> ]
(01-30-2012, 08:04 PM)trollox Wrote: [ -> ]And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?
yes
Then i have no ideas mate :/ i'm sort of new to scripting aswell try asking flamez3 he's a pro on scripts.