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
Key to a level door
MaTPlays Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2013
Reputation: 0
#1
Key to a level door

Hello everyone Smile
That's me again. I'm looking for a totorial or help from you, how to make a key which unlocking a level door. Thanks!
08-08-2013, 09:32 PM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#2
RE: Key to a level door

Exact same way you'd make a key unlock a swing door, but instead of the "setswingdoorlocked" part you'd use
SetLevelDoorLocked(string& asName, bool abLocked);

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
08-08-2013, 09:38 PM
Find
MaTPlays Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2013
Reputation: 0
#3
RE: Key to a level door

Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
08-08-2013, 09:49 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#4
RE: Key to a level door

(08-08-2013, 09:49 PM)MaTPlays Wrote: Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

There, it should be fixed. It's:

SetLevelDoorLocked(string& asName, bool abLocked);
For swing doors:

SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
08-08-2013, 10:25 PM
Find
MaTPlays Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2013
Reputation: 0
#5
RE: Key to a level door

Now the error is, that this is unexpected end of file. Idk why, because I changed nothing at the end :/






void OnStart()
{
SetSkyBoxActive(true);
SetSkyBoxTexture("Name.dds");
SetPlayerLampOil(0.0f);
AddUseItemCallback("", "Keymaindoor', "Door_1", "UseKeyOnDoor_1", true);
}




void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}




void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("Door_3"))
{
SetMessage("Messages", "Msgname", 0);
}
}




void DoorLockedPlayer_1(string &in entity)
{
if(GetLevelDoorLocked("Door_1", true)
{
SetMessage("Messages", "Msgname1", 0);
}
}
08-08-2013, 10:36 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#6
RE: Key to a level door

The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amn..._functions

You'll have to make a workaround for this...

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
08-08-2013, 11:07 PM
Find
MaTPlays Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2013
Reputation: 0
#7
RE: Key to a level door

Ok, I deleted it. Now everything is working. Thanks for help.
08-08-2013, 11:10 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#8
RE: Key to a level door

(08-08-2013, 11:07 PM)The chaser Wrote: The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amn..._functions

You'll have to make a workaround for this...

Oh wait. You're right. It doesn't exist. :U
(This post was last modified: 08-09-2013, 12:15 AM by Tomato Cat.)
08-09-2013, 12:08 AM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#9
RE: Key to a level door

I have thought a workaround:

Make a script area that has the shape of the level door, and name it "AreaLevel". Now, go to the Area panel and search for Player Interact Callback. There, put "Touch" (without quotation marks)
You know you can use items (like keys) in ScriptAreas, right?

Put this in your script:

void OnStart()
{
SetLocalVarInt("Area_locked_level", 1);
SetEntityCallbackFunc("Key", "WhenPicked"); //Key must be the name of your key
}

void WhenPicked (string &in asEntity, string &in asType)
{
SetLocalVarInt("Area_locked_level", 0);
}

void Touch (string &in asEntity)
{
if (GetLocalVarInt("Area_locked_level") == 1)
{
SetMessage("Messages", "Msgname1", 0);
}
if (GetLocalVarInt("Area_locked_level") == 0)
{
SetLevelDoorLocked("Door_1", false);
SetEntityActive("AreaLevel", false);
}
}

The player won't have to use the key by itself, but I think it's a good workaround.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
08-09-2013, 11:20 AM
Find
MaTPlays Offline
Junior Member

Posts: 21
Threads: 5
Joined: Aug 2013
Reputation: 0
#10
RE: Key to a level door

Wow, man, thanks! It really working. I'm beginner, learning by creating a custom story. I need to understand a lot of scripts, and that's why I'm asking here for help.
08-09-2013, 07:18 PM
Find




Users browsing this thread: 4 Guest(s)