User Tools

Site Tools


Sidebar

hpl2:tutorials:script:scripting_by_xtron_-_item_that_unlocks_a_door

This is an old revision of the document!


In this tutorial ( the first one actually ) will I ( xtron ) show you! ( the person who reads this ) how to make a item that unlocks a specific door!.


THE DOOR:

You will need to create that lovely little door by doing like this:

Entities (7) > Door > Select a door that you want to use and change the name of it.

When you're done adding this door you will need to lock it by doing like this:

Press the door you want to lock > Entity > Check the “Locked” box.

THE ITEM:

To unlock your door you will need an item, it could be anything from the item tab, do like this:

Entities (7) > Item > And take a pick. Change the name of the item you chose. (A key is the smartest choice for a door but other items will make it rare)

If you want a name for your item (OPTIONAL):

Click on your item > Entity > At the bottom there's a box named “CustomSubItemTypeName” You can type anything, don't have to be the key name.

Open your extra_lang and add this code (if you don't already have it ofcourse)

<CATEGORY Name="Inventory">
 
 
<Entry Name="ItemDesc_item1">Item description</Entry>
<Entry Name="ItemName_item1">Item name</Entry>
 
 
</CATEGORY>

replace item1 with the name you chose in “CustomSubItemTypeName” in the editor and change the name and description to what ever you

want.

THE SCRIPT:

First off you will need a .hps file and I guess you already have it but to be sure wClean HPS FILE


void OnStart()

{

AddUseItemCallback(_fckg_QUOTfckg_QUOT_, “ITEM”, “DOOR”, “FUNCTIONNAME”, true);

}
|
I'm assuming that you're using the .hps file I uploaded. Copy the AddUseItemCallBack script in to your .hps file inside the brackets were it say
void OnStart. Just like in the box. Edit the ITEM to your item name and then the DOOR to your door name and the function name can be anything. When you're done with that you can copy the: |
void FUNCTIONNAME(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(“DOOR”, false, true);
PlaySoundAtEntity(_fckg_QUOT
fckg_QUOT_, “unlock_door”, “door1”, 0, false);
RemoveItem(“ITEM”);
}

and insert it anywhere but


void OnStart()

{

}

Change the FUNCTIONNAME to the function name you picked in the previous step.

Change the DOOR to your door name and then the ITEM to your item name and then it's all done!.

When you're done it should look something like this:


void OnStart()
{
AddUseItemCallback(_fckg_QUOTfckg_QUOT_, “ITEM”, “DOOR”, “FUNCTION”, true);

}



void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(“DOOR”, false, true);
PlaySoundAtEntity(_fckg_QUOT
fckg_QUOT_, “unlock_door”, “door1”, 0, false);
RemoveItem(“ITEM”);
}

If you got any questions please PM me on the forum

Created by xtron



hpl2/tutorials/script/scripting_by_xtron_-_item_that_unlocks_a_door.1310578415.txt.gz · Last modified: 2011/07/13 17:33 by xtron