User Tools

Site Tools


Sidebar

hpl2:tutorials:script:scripting_by_xtron_-_item_that_unlocks_a_door

Item that unlocks a door

In this tutorial will I ( xtron ) show you 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 change NAME.hps to your map name.

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

void OnStart()
{
    AddUseItemCallback("", "ITEM", "DOOR", "FUNCTION", true);
}

Change ITEM to your item, DOOR to your door name and FUNCTION can be whatever.

When you done that you will be needing the function

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

and insert it anywhere but

void OnStart()
{
 
}

    
                    
                                    
hpl2/tutorials/script/scripting_by_xtron_-_item_that_unlocks_a_door.txt · Last modified: 2013/08/22 15:12 by yourcomputer