Frictional Games Forum (read-only)

Full Version: The "IF" with HasItem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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
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);
  }
}
(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);
}
}



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.
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
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.
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)
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.
(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
(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
}
Pages: 1 2 3