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
HasItem problem [SOLVED]
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#1
HasItem problem [SOLVED]

What's wrong with this code? I have the key but it doesn't trigger the event.

void CollideAreaLiving(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("key_storage") == true){
//Slime Fades
        SetPropActiveAndFade("slime_6way_1", true, 1.5f);
        SetPropActiveAndFade("slime_anim_wall_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_2", true, 1.5f);
//Effects
        StartScreenShake(0.115, 2.0f, 0.1f,0.3f);
        FadeSepiaColorTo(100.0f, 4.0f);
        FadeRadialBlurTo(0.15f, 6.0f);
        PlaySoundAtEntity("", "guardian_activated.snt", "Player", 0, false);
//Timer to remove effects
        AddTimer("FadeGone", 3.0f, "GuardianTimer");
    }
}

The code still won't get triggered if I have that key. What's wrong with it?

Creator of The Dark Treasure.
(This post was last modified: 04-22-2011, 01:52 PM by Linus Ågren.)
04-09-2011, 07:58 AM
Website Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#2
RE: HasItem problem

Mind posting the error message?

04-09-2011, 09:51 AM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#3
RE: HasItem problem

Oh sorry, I forgot to remove that part. Edited post above. The problem is now only that the script won't get activated even if I have the item.

Creator of The Dark Treasure.
04-09-2011, 11:37 AM
Website Find
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#4
RE: HasItem problem

Remove the " == true" from if(HasItem("key_storage") == true), like this
void CollideAreaLiving(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("key_storage")){
//Slime Fades
        SetPropActiveAndFade("slime_6way_1", true, 1.5f);
        SetPropActiveAndFade("slime_anim_wall_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_2", true, 1.5f);
//Effects
        StartScreenShake(0.115, 2.0f, 0.1f,0.3f);
        FadeSepiaColorTo(100.0f, 4.0f);
        FadeRadialBlurTo(0.15f, 6.0f);
        PlaySoundAtEntity("", "guardian_activated.snt", "Player", 0, false);
//Timer to remove effects
        AddTimer("FadeGone", 3.0f, "GuardianTimer");
    }
}
(This post was last modified: 04-09-2011, 01:36 PM by Dalroc.)
04-09-2011, 01:36 PM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#5
RE: HasItem problem

The collidebox STILL won't get triggered o0.

Creator of The Dark Treasure.
04-09-2011, 11:25 PM
Website Find
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#6
RE: HasItem problem

Could you post the EntityCollideCallback that calls CollideAreaLiving?
04-09-2011, 11:44 PM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#7
RE: HasItem problem

Sure, here you go:
AddEntityCollideCallback("Player", "AreaLiving", "CollideAreaLiving", true, 1);

Creator of The Dark Treasure.
04-09-2011, 11:57 PM
Website Find
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#8
RE: HasItem problem

Spotted the problem (I think). You are destroying the Callback when it's triggered the first time.
Set abDeleteOnCollide to false and it should work.. You will have to find another way to remove the Callback only when you have the item. Example would be to use a variable and add a condition to your if conditional to only execute when the player has the key AND when the variable has the right value.
04-10-2011, 12:12 AM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#9
RE: HasItem problem

YES! It works! I never realized it would be such an easy answer. Thanks a thousand times. I've been trying to figure out why it didn't work for so long! Big Grin

Creator of The Dark Treasure.
04-22-2011, 01:51 PM
Website Find
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#10
RE: HasItem problem [SOLVED]

Glad I could help! Smile
04-22-2011, 03:52 PM
Find




Users browsing this thread: 4 Guest(s)