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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Multipul Keys
3gamers Offline
Junior Member

Posts: 10
Threads: 6
Joined: Oct 2013
Reputation: 0
#1
Multipul Keys

Hey again, I'm trying to get it so that a door only opens when all three keys are used but it keeps giving me a fatal error: unexpected end of script. I'm not sure if my script even works but it wont even load so I can test it. Please someone look over it Smile


void OnStart()
{
AddUseItemCallback("", "key1", "MD1", "Keyfunction1", true);
AddUseItemCallback("", "key2", "MD2", "Keyfunction2", true);
AddUseItemCallback("", "key3", "MD3", "Keyfunction3", true);
AddUseItemCallback("", "key4", "level_wood_3", "Keyfunction4", true);

SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("dungeonkey1", "func1", true);
SetEntityPlayerInteractCallback("dungeonkey2", "func2", true);
SetEntityPlayerInteractCallback("dungeonkey3", "func3", true);

void OnEnter()
{

}

void OnLeave()
{

}
void Keyfunction1(string &in item, string &in door)
{
SetSwingDoorLocked("MD1", false, true);
PlayGuiSound("unlock_door.snt", 100);
RemoveItem("key1");
}

void Keyfunction2(string &in item, string &in door)
{
SetSwingDoorLocked("MD2", false, true);
PlayGuiSound("unlock_door.snt", 100);
RemoveItem("key2");
}

void Keyfunction3(string &in item, string &in door)
{
SetSwingDoorLocked("MD3", false, true);
PlayGuiSound("unlock_door.snt", 100);
RemoveItem("key3");
}

void Keyfunction4(string &in item, string &in door)
{
SetLevelDoorLocked("level_wood_3", false);
PlayGuiSound("unlock_door.snt", 100);
RemoveItem("key4");
}

void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func4();

}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func4();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func4();
}

void func4()
{
if(GetLocalVarInt("Var1") == 3)
{
SetLevelDoorLocked("level_wood_2", false);
PlayGuiSound("unlock_door.snt", 100);
RemoveItem("dungeonkey1");
RemoveItem("dungeonkey2");
RemoveItem("dungeonkey3");
}
}

Nepenthe- WIP
10-29-2013, 05:33 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#2
RE: Multipul Keys

You have not closed you OnStart

void OnStart()
{
AddUseItemCallback("", "key1", "MD1", "Keyfunction1", true);
AddUseItemCallback("", "key2", "MD2", "Keyfunction2", true);
AddUseItemCallback("", "key3", "MD3", "Keyfunction3", true);
AddUseItemCallback("", "key4", "level_wood_3", "Keyfunction4", true);

SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("dungeonkey1", "func1", true);
SetEntityPlayerInteractCallback("dungeonkey2", "func2", true);
SetEntityPlayerInteractCallback("dungeonkey3", "func3", true);

}

"What you think is irrelevant" - A character of our time

A Christmas Hunt
10-29-2013, 05:45 PM
Find
3gamers Offline
Junior Member

Posts: 10
Threads: 6
Joined: Oct 2013
Reputation: 0
#3
RE: Multipul Keys

Thank you very much! Only it was a moot point as the code itself doesn't do what I want it too. Which brings up my next question: does anyone know how to code a level door so that it requires three keys to work?

Nepenthe- WIP
(This post was last modified: 10-29-2013, 08:25 PM by 3gamers.)
10-29-2013, 05:51 PM
Find
Omenapuu Offline
Junior Member

Posts: 31
Threads: 8
Joined: Oct 2013
Reputation: 1
#4
RE: Multipul Keys

(10-29-2013, 05:51 PM)3gamers Wrote: Thank you very much! Only it was a moot point as the code itself doesn't do what I want it too. Which brings up my next question: does anyone know how to code a level door so that it requires three keys to work?

This seems a bit complicated, and I'm not sure does it work, but it should:

-----------------------
void OnStart()
{
AddUseItemCallback("doorpuzzle1", "key1", "door1", "key1", true);
AddUseItemCallback("doorpuzzle2", "key2", "door1", "key2", true);
AddUseItemCallback("doorpuzzle3", "key3", "door1", "key3", true);
SetLocalVarInt("doorpuzzle", 0);
}
void OnEnter()
{

}
void OnLeave()
{

}
void key1(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key2(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key3(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
------------------------------
That basically says, everytime you use 1 of these keys, it checks the VarInt. If it's already 2 (=you used 2 keys already and this is last) it unlocks the door. If it isn't 2 yet (=you haven't used 2 yet) it just adds one to the VarInt. So it's simple as that. And also, you can find codes here: wiki.frictionalgames.com/hpl2/amnesia/script_functions
(This post was last modified: 10-29-2013, 09:44 PM by Omenapuu.)
10-29-2013, 09:43 PM
Find
3gamers Offline
Junior Member

Posts: 10
Threads: 6
Joined: Oct 2013
Reputation: 0
#5
RE: Multipul Keys

(10-29-2013, 09:43 PM)Omenapuu Wrote:
(10-29-2013, 05:51 PM)3gamers Wrote: Thank you very much! Only it was a moot point as the code itself doesn't do what I want it too. Which brings up my next question: does anyone know how to code a level door so that it requires three keys to work?

This seems a bit complicated, and I'm not sure does it work, but it should:

-----------------------
void OnStart()
{
AddUseItemCallback("doorpuzzle1", "key1", "door1", "key1", true);
AddUseItemCallback("doorpuzzle2", "key2", "door1", "key2", true);
AddUseItemCallback("doorpuzzle3", "key3", "door1", "key3", true);
SetLocalVarInt("doorpuzzle", 0);
}
void OnEnter()
{

}
void OnLeave()
{

}
void key1(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key2(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key3(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
------------------------------
That basically says, everytime you use 1 of these keys, it checks the VarInt. If it's already 2 (=you used 2 keys already and this is last) it unlocks the door. If it isn't 2 yet (=you haven't used 2 yet) it just adds one to the VarInt. So it's simple as that. And also, you can find codes here: wiki.frictionalgames.com/hpl2/amnesia/script_functions

I put in your code and had to fix a couple of things like missing parathesis but now its giving me an error that I'm not sure how to fix or even what it means. I included a picture of the errors.

Thank you so much for your help, I REALLY appreciate it. Smile
And I checked out the wiki and have been using it for other codes but I just couldn't find anything on this.


Attached Files
.png   errors.png (Size: 28.68 KB / Downloads: 102)

Nepenthe- WIP
10-29-2013, 10:53 PM
Find
Omenapuu Offline
Junior Member

Posts: 31
Threads: 8
Joined: Oct 2013
Reputation: 1
#6
RE: Multipul Keys

(10-29-2013, 10:53 PM)3gamers Wrote:
(10-29-2013, 09:43 PM)Omenapuu Wrote:
(10-29-2013, 05:51 PM)3gamers Wrote: Thank you very much! Only it was a moot point as the code itself doesn't do what I want it too. Which brings up my next question: does anyone know how to code a level door so that it requires three keys to work?

This seems a bit complicated, and I'm not sure does it work, but it should:

-----------------------
void OnStart()
{
AddUseItemCallback("doorpuzzle1", "key1", "door1", "key1", true);
AddUseItemCallback("doorpuzzle2", "key2", "door1", "key2", true);
AddUseItemCallback("doorpuzzle3", "key3", "door1", "key3", true);
SetLocalVarInt("doorpuzzle", 0);
}
void OnEnter()
{

}
void OnLeave()
{

}
void key1(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key2(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
void key3(string &in asItem, string &in asEntity)
{
if(GetLocalVarInt("doorpuzzle" == 2)
{
SetLevelDoorLocked("door1", false);
}
else if(GetLocalVarInt("doorpuzzle" != 2)
{
AddLocalVarInt("doorpuzzle", 1);
}
}
------------------------------
That basically says, everytime you use 1 of these keys, it checks the VarInt. If it's already 2 (=you used 2 keys already and this is last) it unlocks the door. If it isn't 2 yet (=you haven't used 2 yet) it just adds one to the VarInt. So it's simple as that. And also, you can find codes here: wiki.frictionalgames.com/hpl2/amnesia/script_functions

I put in your code and had to fix a couple of things like missing parathesis but now its giving me an error that I'm not sure how to fix or even what it means. I included a picture of the errors.

Thank you so much for your help, I REALLY appreciate it. Smile
And I checked out the wiki and have been using it for other codes but I just couldn't find anything on this.

Oh, instead of
----
if(GetLocalVarInt("doorpuzzle" == 2)
----
type if(GetLocalVarInt("doorpuzzle") == 2
and
----
else if(GetLocalVarInt("doorpuzzle" != 2)
----
type if(GetLocalVarInt("doorpuzzle") != 2)

That should help.
But going to sleep now, hope it worked.
10-29-2013, 11:10 PM
Find
3gamers Offline
Junior Member

Posts: 10
Threads: 6
Joined: Oct 2013
Reputation: 0
#7
RE: Multipul Keys

It worked beautifully thank you very very much!

Nepenthe- WIP
10-29-2013, 11:27 PM
Find




Users browsing this thread: 1 Guest(s)