MaTPlays
Junior Member
Posts: 21
Threads: 5
Joined: Aug 2013
Reputation:
0
|
Key to a level door
Hello everyone
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 |
|
DeAngelo
Senior Member
Posts: 263
Threads: 26
Joined: Feb 2013
Reputation:
11
|
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);
|
|
08-08-2013, 09:38 PM |
|
MaTPlays
Junior Member
Posts: 21
Threads: 5
Joined: Aug 2013
Reputation:
0
|
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 |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
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)
Aculy iz dolan.
|
|
08-08-2013, 10:25 PM |
|
MaTPlays
Junior Member
Posts: 21
Threads: 5
Joined: Aug 2013
Reputation:
0
|
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 |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
|
08-08-2013, 11:07 PM |
|
MaTPlays
Junior Member
Posts: 21
Threads: 5
Joined: Aug 2013
Reputation:
0
|
RE: Key to a level door
Ok, I deleted it. Now everything is working. Thanks for help.
|
|
08-08-2013, 11:10 PM |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
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 |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
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)
Aculy iz dolan.
|
|
08-09-2013, 11:20 AM |
|
MaTPlays
Junior Member
Posts: 21
Threads: 5
Joined: Aug 2013
Reputation:
0
|
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 |
|
|