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
Keys on Doors...
ryan1431 Offline
Junior Member

Posts: 14
Threads: 10
Joined: Dec 2012
Reputation: 0
#1
Keys on Doors...

Okay, so I've been working getting a single key on a single door for about half a week now... and its really annoying so i was wondering if some1 could help me.

I use HPL with amnesia (windowed) open with debug, so when i make a change on HPL, i save it and go to amnesia and press quick map reload. I tweaked my ".hps" file (void stuff) as i should have to get the key registered and working. This is what i have in that file...

void OnStart()
{
AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true);
}

void OPEN(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(mansion_2, false, true);
PlaySoundAtEntity("", "unlock_door", mansion_2, 0, false);
RemoveItem(studykey_1);
}

Using this information, which is 100% correct (names n stuff), i get 6 Error reports when i try to quick reload.
These are the errors:

1)main (5,1) : INFO : Compiling void OPEN(string&in, string&in)
2)main (8,24) : ERR : 'mansion_2' is not declared
3)main (9,5) : ERR : No matching signatures to 'PlaySoundAtEntity(string@&, string@&, int, const uint, const bool)
4)main (9,5) : INFO : Candidates are:
5)main (9,5) : INFO : void PlaySoundAtEntity(string&in, string&in, string&in, float, bool)
6)main (10,16) : ERR : 'studykey_1' is not declared
12-01-2012, 07:54 AM
Find
JMFStorm Offline
Member

Posts: 205
Threads: 8
Joined: Aug 2011
Reputation: 28
#2
RE: Keys on Doors...

(12-01-2012, 07:54 AM)ryan1431 Wrote:
2)main (8,24) : ERR : 'mansion_2' is not declared
3)main (9,5) : ERR : No matching signatures to 'PlaySoundAtEntity(string@&, string@&, int, const uint, const bool)
6)main (10,16) : ERR : 'studykey_1' is not declared
You don't know how to read? The errors are indicated right here. Just copy paste this over your current so it all probably starts to work:

void OnStart()
{
AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true);
}

void OPEN(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("studykey_1");
}

12-01-2012, 08:06 AM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#3
RE: Keys on Doors...

void OnStart()
{
AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true);
}

void OPEN(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem(studykey_1);
}


You forgot to declare mansion_2 two times in the OPEN function.

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
12-01-2012, 08:09 AM
Website Find
ryan1431 Offline
Junior Member

Posts: 14
Threads: 10
Joined: Dec 2012
Reputation: 0
#4
RE: Keys on Doors...

(12-01-2012, 08:06 AM)JMFStorm Wrote: TYVM man!!! i'm so relieved!!! i have one more question...

if i want to keep making more keys and stuff do i just add all the stuff below the other key stuff? or do i have to add new "{ }" 's

(12-01-2012, 07:54 AM)ryan1431 Wrote:
2)main (8,24) : ERR : 'mansion_2' is not declared
3)main (9,5) : ERR : No matching signatures to 'PlaySoundAtEntity(string@&, string@&, int, const uint, const bool)
6)main (10,16) : ERR : 'studykey_1' is not declared
You don't know how to read? The errors are indicated right here. Just copy paste this over your current so it all probably starts to work:

void OnStart()
{
AddUseItemCallback("", "studykey_1", "mansion_2", "OPEN", true);
}

void OPEN(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("studykey_1");
}
12-01-2012, 10:32 AM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#5
RE: Keys on Doors...

Just for the sake of clarity: he didn't forget to declare
mansion_2 - he forgot to put it in quotes, and make it a string literal (that is: "mansion_2" ).

The compiler, reaching the token mansion_2 saw that it wasn't in quotes, so it assumed it's a variable, but it couldn't figure out what kind of variable it was, since such a variable was never declared.
A declaration is when you introduce a variable to your code, like this:
string targetDoor = "mansion_2";


This declares a string variable named targetDoor, which can then be used later on in various places in the code (assuming it's a global var), like this:
PlaySoundAtEntity("", "unlock_door", targetDoor, 0, false);
(This post was last modified: 12-01-2012, 09:15 PM by TheGreatCthulhu.)
12-01-2012, 09:13 PM
Find




Users browsing this thread: 2 Guest(s)