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
Trigger an event if user has an item
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#1
Trigger an event if user has an item

Okay, I've made an event that is supposed to happen if user has an item. My script looks like:

void CollideSwingCrown(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("OilContainer")){
        CreateParticleSystemAtEntity("Ghost", "ps_dust_ghost.ps", "candlestick_tri_1", false);
    
        PlaySoundAtEntity("SoundSwirl", "scare_whine_loop", "AreaBeginSwirl", 0.0f, false);
        PlaySoundAtEntity("BeginWindSound", "general_wind_whirl.snt", "Player", 4.0f, false);
        PlaySoundAtEntity("", "scare_male_terrified.snt", "Player", 0.5f, false);
    
        AddPropImpulse("chandelier_large_1", 2.0f, 0.0f, 0.0f, "World");
    
        AddTimer("Swing", 0.5f, "GhostCrown");
        AddTimer("Sanity", 1.0f, "GhostCrown");
        AddTimer("FadeOut", 2.5f, "GhostCrown");
        AddTimer("StopMusic", 15.0f, "GhostCrown");
        AddTimer("StartMusic", 16.0f, "GhostCrown");
    }
}

void GhostCrown(string &in asTimer)
{
    if(asTimer == "Swing"){
        PlayMusic("00_event_gallery.ogg", false, 1.0f, 0.0f, 10, false);
    }
    if(asTimer == "Sanity"){
        GiveSanityDamage(4.0f, true);
        
        FadeRadialBlurTo(0.1f, 0.025f);
        
        SetLampLit("chandelier_large_1", false, true);
        SetLampLit("candlestick_tri_1", false, true);
        SetLampLit("candlestick_tri_3", false, true);
        SetLampLit("candlestick_tri_2", false, true);
        SetLampLit("candlestick_floor_3", false, true);
        SetLampLit("candlestick_floor_2", false, true);
        SetLampLit("candlestick_floor_1", false, true);
        SetLampLit("candlestick_floor_4", false, true);
        SetLampLit("candlestick_wall_1", false, true);
        SetLampLit("candlestick_wall_2", false, true);
    }
    if(asTimer == "FadeOut"){
        FadeRadialBlurTo(0, 0.1f);
    }
    if(asTimer == "StopMusic"){
        StopMusic(10, 0);
    }
    if(asTimer == "StartMusic"){
        PlayMusic("12_amb.ogg", false, 1.0f, 0.0f, 10, false);
    }
}

And the item's name is OilContainer. The problem is that the event won't trigger if you have the item. What's wrong?

Creator of The Dark Treasure.
(This post was last modified: 02-13-2011, 08:45 PM by Linus Ågren.)
02-13-2011, 08:29 PM
Website Find
Acies Offline
Posting Freak

Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation: 73
#2
RE: Trigger an event if user has an item

I think the IfHasItem is missing a "==true".

[Image: mZiYnxe.png]


02-16-2011, 04:47 AM
Find




Users browsing this thread: 1 Guest(s)