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
The "IF" with HasItem
jessehmusic Offline
Senior Member

Posts: 423
Threads: 102
Joined: Dec 2011
Reputation: 8
#1
The "IF" with HasItem

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

http://www.moddb.com/mods/jessehmusic - Hospital of horror , WIP
(This post was last modified: 04-11-2012, 11:44 AM by jessehmusic.)
04-09-2012, 12:46 AM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: The "IF" with HasItem

You will want your code to look at follows:
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:
void Scary1(string &in asParent, string &in asChild, int alState)
{
if(HasItem("The_gone_key"))
  {
    SetEntityActive("agrippa_headless_1", true);
  }
}
(This post was last modified: 04-09-2012, 12:53 AM by Apjjm.)
04-09-2012, 12:52 AM
Find
jessehmusic Offline
Senior Member

Posts: 423
Threads: 102
Joined: Dec 2011
Reputation: 8
#3
RE: The "IF" with HasItem

(04-09-2012, 12:52 AM)Apjjm Wrote: You will want your code to look at follows:
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:
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);
}
}




http://www.moddb.com/mods/jessehmusic - Hospital of horror , WIP
04-09-2012, 03:20 AM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: The "IF" with HasItem

Can you enable debug messages and tell me what is shown when you run the 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.
(This post was last modified: 04-09-2012, 03:41 AM by Apjjm.)
04-09-2012, 03:40 AM
Find
Quotentote Offline
Member

Posts: 118
Threads: 23
Joined: Dec 2011
Reputation: 11
#5
RE: The "IF" with HasItem

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

Cruel ways 2: Something went wrong
8.04.2012


04-09-2012, 06:21 AM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#6
RE: The "IF" with HasItem

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.

04-09-2012, 09:30 AM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#7
RE: The "IF" with HasItem

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)

04-09-2012, 09:57 AM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#8
RE: The "IF" with HasItem

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, 10:49 AM
Find
jessehmusic Offline
Senior Member

Posts: 423
Threads: 102
Joined: Dec 2011
Reputation: 8
#9
RE: The "IF" with HasItem

(04-09-2012, 03:40 AM)Apjjm Wrote: Can you enable debug messages and tell me what is shown when you run the 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

http://www.moddb.com/mods/jessehmusic - Hospital of horror , WIP
04-09-2012, 01:02 PM
Website Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#10
RE: The "IF" with HasItem

(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
}

04-09-2012, 01:11 PM
Find




Users browsing this thread: 5 Guest(s)