Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HPS file not doing anything
SetsuPotato Offline
Junior Member

Posts: 6
Threads: 2
Joined: Mar 2015
Reputation: 0
#1
HPS file not doing anything

So I started working on a custom story today. I made a key that is supposed to unlock a door but it doesn't. When I try to use the key on the door, it simply says "Cannot use item this way".
I checked through all my code and it seems right to me. I tried the same thing on another map and it didn't work either.

The HPS file:
_________________________________________________________________
void OnEnter()
{
AddUseItemCallback("", "keystair", "doorstair", "UsedKeyOnDoor", true);
}

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

void OnLeave()
{

}
_________________________________________________________________

Also, keystair= name of key and doorstair= name of door. I checked to make sure that the objects both have the right name and they do.
04-08-2015, 02:45 AM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#2
RE: HPS file not doing anything

Your function to call is "UsedKeyOnDoor"
[Image: 47bbe5b2dc.png]

However your function name down here is just "KeyOnDoor"
[Image: 3f4e1e37d7.png]

I would also double check the name of the door in your game. It should be the same as you have it here ("doorstair")
[Image: 47bbe5b2dc.png]

I have rewritten your code fixing your issue as well as another you had with your sounds. You have to have the .snt extension.

Please please please! I really want you to look over the code and take a look at your mistakes and rewrite the code yourself. You should use this as a sort of guide, but not a copy-pasta solution.

void OnEnter()
{
    AddUseItemCallback("", "theKey", "theDoor", "usedKeyOnDoor", true);
}

void usedKeyOnDoor(string, string)
{
    SetSwingDoorLocked("theDoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "theDoor", 0, false);
    RemoveItem("theKey");
}

(This post was last modified: 04-08-2015, 03:32 AM by 7heDubz.)
04-08-2015, 03:24 AM
Find
SetsuPotato Offline
Junior Member

Posts: 6
Threads: 2
Joined: Mar 2015
Reputation: 0
#3
RE: HPS file not doing anything

(04-08-2015, 03:24 AM)7heDubz Wrote: Your function to call is "UsedKeyOnDoor"
[Image: 47bbe5b2dc.png]

However your function name down here is just "KeyOnDoor"
[Image: 3f4e1e37d7.png]

I would also double check the name of the door in your game. It should be the same as you have it here ("doorstair")
[Image: 47bbe5b2dc.png]

I have rewritten your code fixing your issue as well as another you had with your sounds. You have to have the .snt extension.

Please please please! I really want you to look over the code and take a look at your mistakes and rewrite the code yourself. You should use this as a sort of guide, but not a copy-pasta solution.

void OnEnter()
{
    AddUseItemCallback("", "theKey", "theDoor", "usedKeyOnDoor", true);
}

void usedKeyOnDoor(string, string)
{
    SetSwingDoorLocked("theDoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "theDoor", 0, false);
    RemoveItem("theKey");
}

Sorry, I used a youtube video to do it. He left "usedKeyOnDoor" as "MyFunc" but I changed it to "usedKeyOnDoor" because someone else did it in another video. But I'll try to see if it works.
04-08-2015, 01:11 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: HPS file not doing anything

Return here if it doesn't! Smile

Trying is the first step to success.
04-08-2015, 06:58 PM
Find




Users browsing this thread: 1 Guest(s)