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

Now you need the code that will be inserted betwen void OnStart()s brackets ( { and } )

void OnStart()

{

AddUseItemCallback(“”, “ITEM”, “DOOR”, “FUNCTION”, true);

}

Copy the AddUseItemCallBack and paste it inside your { and } in your hps file.

Edit ITEM to your item name, DOOR to your door name and edit FUNCTION to whatever.

When you're done with that you will be needing the function:

void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(“DOOR”, false, true);
PlaySoundAtEntity(“”, “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(“”, “ITEM”, “DOOR”, “FUNCTION”, true);

}

void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(“DOOR”, false, true);
PlaySoundAtEntity(“”, “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.1310579086.txt.gz · Last modified: 2011/07/13 17:44 by xtron