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
Door needs two keys script no effect
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#1
Door needs two keys script no effect

As the title said, my .hps is like this:
void Onstart()
{
AddUseItemCallback("", "privateroomkey_1", "Pv1", "UsedKeyOnDoor", true);
AddUseItemCallback("UseKey1", "prisonkeylight_1", "mansion_3", "KeyCounter", true);
SetLocalVarInt("KeysUsed", 0);
AddUseItemCallback("UseKey2", "prisonkeydark_1", "mansion_3", "KeyCounter", true);
}

void KeyCounter(string &in asItem, string &in asEntity)
{
AddLocalVarInt("KeysUsed", 1);
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}

Did i put something wrong? If i did please tell me Smile.

One World To Another [DEMO] coming soon.
03-16-2011, 05:36 AM
Find
Anxt Offline
Senior Member

Posts: 588
Threads: 12
Joined: Mar 2011
Reputation: 10
#2
RE: Door needs two keys script no effect

You need an if statement that is called when the "KeysUsed" int has a value of 2. So it would be like this:

Keep your OnStart the same, but have this as your function:

void KeyCounter(string &in asItem, string &in asEntity)
{
AddLocalVarInt("KeysUsed", 1);
if(GetLocalVarInt("KeysUsed")==2)
{
SetSwingDoorLocked("mansion_3", false, true)
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}
}


Also, there's no need to post a new thread about this. You already have one about this exact function. Just go back to it and post in it instead of starting another new topic.

03-16-2011, 05:52 AM
Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#3
RE: Door needs two keys script no effect

(03-16-2011, 05:52 AM)Anxt Wrote: You need an if statement that is called when the "KeysUsed" int has a value of 2. So it would be like this:

Keep your OnStart the same, but have this as your function:

void KeyCounter(string &in asItem, string &in asEntity)
{
AddLocalVarInt("KeysUsed", 1);
if(GetLocalVarInt("KeysUsed")==2)
{
SetSwingDoorLocked("mansion_3", false, true)
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}
}


Also, there's no need to post a new thread about this. You already have one about this exact function. Just go back to it and post in it instead of starting another new topic.

Okay, thanks for the tip Big Grin.
Still no effects, my collide and function is like this:
void Onstart()
{
AddUseItemCallback("UseKey1", "prisonkeylight_1", "mansion_3", "KeyCounter", true);
SetLocalVarInt("KeysUsed", 0);
AddUseItemCallback("UseKey2", "prisonkeydark_1", "mansion_3", "KeyCounter", true);
}

void KeyCounter(string &in asItem, string &in asEntity)
{
AddLocalVarInt("KeysUsed", 1);
if(GetLocalVarInt("KeysUsed")==2)
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
}

I copied your code and still no effects Sad.

One World To Another [DEMO] coming soon.
(This post was last modified: 03-16-2011, 06:45 AM by Raymond.)
03-16-2011, 05:54 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#4
RE: Door needs two keys script no effect

(03-16-2011, 05:54 AM)Raymond Wrote: I copied your code and still no effects Sad.

And there lies the problem. Sorry Raymond, but you really gotta start understanding code instead of just copying from others/letting others make it for you.

03-16-2011, 12:13 PM
Find
Viperdream Offline
Member

Posts: 124
Threads: 16
Joined: Jan 2011
Reputation: 0
#5
RE: Door needs two keys script no effect

Read this and you will understand variables:
http://wiki.frictionalgames.com/hpl2/tut...t_beginner

03-16-2011, 01:33 PM
Find
Raymond Offline
Member

Posts: 126
Threads: 24
Joined: Feb 2011
Reputation: 0
#6
RE: Door needs two keys script no effect

(03-16-2011, 01:33 PM)Viperdream Wrote: Read this and you will understand variables:
http://wiki.frictionalgames.com/hpl2/tut...t_beginner

Thanks for the link Smile.
The most confusing one is the for(int i = 0;i < 10;i++) from >>> because it's hard to understand Dodgy.
if(ScriptDebugOn())
          {
               GiveItemFromFile("lantern", "lantern.ent");
               SetPlayerLampOil(100.0f);

               for(int i = 0;i < 10;i++)
               {
                    GiveItemFromFile("tinderbox", "tinderbox.ent");

One World To Another [DEMO] coming soon.
(This post was last modified: 03-17-2011, 03:34 AM by Raymond.)
03-17-2011, 03:24 AM
Find




Users browsing this thread: 2 Guest(s)