jessehmusic
Senior Member
Posts: 423
Threads: 102
Joined: Dec 2011
Reputation:
8
|
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
(This post was last modified: 04-11-2012, 11:44 AM by jessehmusic.)
|
|
04-09-2012, 12:46 AM |
|
Apjjm
Is easy to say
Posts: 496
Threads: 18
Joined: Apr 2011
Reputation:
52
|
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 |
|
jessehmusic
Senior Member
Posts: 423
Threads: 102
Joined: Dec 2011
Reputation:
8
|
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);
}
}
|
|
04-09-2012, 03:20 AM |
|
Apjjm
Is easy to say
Posts: 496
Threads: 18
Joined: Apr 2011
Reputation:
52
|
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 |
|
Quotentote
Member
Posts: 118
Threads: 23
Joined: Dec 2011
Reputation:
11
|
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 |
|
Damascus
Senior Member
Posts: 646
Threads: 118
Joined: Mar 2012
Reputation:
29
|
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 |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 |
|
Datguy5
Senior Member
Posts: 629
Threads: 25
Joined: Dec 2011
Reputation:
12
|
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 |
|
jessehmusic
Senior Member
Posts: 423
Threads: 102
Joined: Dec 2011
Reputation:
8
|
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
|
|
04-09-2012, 01:02 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 |
|
|