Frictional Games Forum (read-only)
The "IF" with HasItem - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: The "IF" with HasItem (/thread-14628.html)

Pages: 1 2 3


The "IF" with HasItem - jessehmusic - 04-09-2012

Hello im trying to make a Jump Scare when player got The_gone_key
but i get error when i add "If HasItem(The_gone_key);"


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_4", "Scary1", true, 1);

}

void Scary1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("agrippa_headless_1", true);
if HasItem(The_gone_key);
}


ther error says "Compiling void void Scary1(string &in asParent, string &in asChild, int alState)"

and the other is

"Err ,expected "("
any clue


RE: The "IF" with HasItem - Apjjm - 04-09-2012

You will want your code to look at follows:
Code:
void Scary1(string &in asParent, string &in asChild, int alState)
{
//Things that should happen if regardless of if you have the key or not
if(HasItem("The_gone_key"))
  {
    //Scary Stuff happens here for when you have the key
  }
}

assuming you want to make aggrippa headless appear when the key has gone:
Code:
void Scary1(string &in asParent, string &in asChild, int alState)
{
if(HasItem("The_gone_key"))
  {
    SetEntityActive("agrippa_headless_1", true);
  }
}



RE: The "IF" with HasItem - jessehmusic - 04-09-2012

(04-09-2012, 12:52 AM)Apjjm Wrote: You will want your code to look at follows:
Code:
void Scary1(string &in asParent, string &in asChild, int alState)
{
//Things that should happen if regardless of if you have the key or not
if(HasItem("The_gone_key"))
  {
    //Scary Stuff happens here for when you have the key
  }
}

assuming you want to make aggrippa headless appear when the key has gone:
Code:
void Scary1(string &in asParent, string &in asChild, int alState)
{
if(HasItem("The_gone_key"))
  {
    SetEntityActive("agrippa_headless_1", true);
  }
}
dosnt work :S the Script activate when i dont have the key :/





void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_4", "Scary1", true, 1);

}
void Scary1(string &in asParent, string &in asChild, int alState)
{
if(HasItem("The_gone_key"))
{
SetEntityActive("agrippa_headless_1", true);
PlaySoundAtEntity("", "alois_amb_idle.snt", "Player", 0, false);
}
}






RE: The "IF" with HasItem - Apjjm - 04-09-2012

Can you enable debug messages and tell me what is shown when you run the code:

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_4", "Scary1", true, 1);
AddDebugMessage("+OnStart",false);
}
void Scary1(string &in asParent, string &in asChild, int alState)
{

if(HasItem("The_gone_key"))
{
SetEntityActive("agrippa_headless_1", true);
PlaySoundAtEntity("", "alois_amb_idle.snt", "Player", 0, false);
AddDebugMessage("+Scary1_KeyTrigger",false);
}

AddDebugMessage("+Scary1",false);
}
It is probably a name mismatch somewhere.


RE: The "IF" with HasItem - Quotentote - 04-09-2012

i would make it a bit easier. i guess you want agrippa to spawn as soon as the player enters that area right? i would make the area inactive and activate it when you picked up that key..
less pro but easier xD



RE: The "IF" with HasItem - Damascus - 04-09-2012

Instead of using if(HasItem) I instead usually add the callback when you pick up the item. Otherwise, I can never get it to stop calling the function when it's not ready yet.



RE: The "IF" with HasItem - SilentStriker - 04-09-2012

I remember a script that always messed up, it didn't trigger but then I realised that I went throught the area and the trigger was removed so I changed so the callback would be removed on trigger x)


RE: The "IF" with HasItem - Datguy5 - 04-09-2012

When this is done can someone help me with my if function?I dont wanna start a new thread about it.Im trying that if player doesnt have item,the player will look at it.


RE: The "IF" with HasItem - jessehmusic - 04-09-2012

(04-09-2012, 03:40 AM)Apjjm Wrote: Can you enable debug messages and tell me what is shown when you run the code:

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_4", "Scary1", true, 1);
AddDebugMessage("+OnStart",false);
}
void Scary1(string &in asParent, string &in asChild, int alState)
{

if(HasItem("The_gone_key"))
{
SetEntityActive("agrippa_headless_1", true);
PlaySoundAtEntity("", "alois_amb_idle.snt", "Player", 0, false);
AddDebugMessage("+Scary1_KeyTrigger",false);
}

AddDebugMessage("+Scary1",false);
}
It is probably a name mismatch somewhere.
dosnt work at all :S


RE: The "IF" with HasItem - SilentStriker - 04-09-2012

(04-09-2012, 10:49 AM)Datguy5 Wrote: When this is done can someone help me with my if function?I dont wanna start a new thread about it.Im trying that if player doesnt have item,the player will look at it.
try
if(HasItem("nameofitem") == false){
//Event here
}