Frictional Games Forum (read-only)

Full Version: [HELP] Script Enabling/Variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Is there a way to make it so you can not use a script until something else happens so lets say, someone wants to cook something over a fire, well there has to be a check made that the fire is on before the item can be cooked. I also need help with the fact that a player can not put down a jar to pick up drops of something until they stab into the something and have it leak out.
Local variables is the thing you are looking for
Code:
void OnStart()
{
    SetLocalVarInt("FireActive", 0);
}

void InteractFire(string &in asEntity, int alState)
{
    SetLocalVarInt("FireActive", 1);
}

void InteractStove(string &in asEntity, int alState)
{
      if(GetLocalVarInt("FireActive") == 1)
      {
      //Script which can happen after the fire is turned on
      }
      else
      {
      //What happens if the fire isn't active
      }
}
//Extra var scripts: AddLocalVarInt("FireActive", 1) obviously adds the value 1 to FireActive
//Put the Interact-names in the entity field "on interact" or something like that. It will call up this function.
If there is anything you'd like to know, feel free to let me know.
If that looks complicated to you I'd recommend you should study this:
http://wiki.frictionalgames.com/hpl2/tut...lvariables
I think local variables can be avoided if the sequence of callbacks are done properly. FullGameSave may also play a role here.
I'm seeming to have problems with this, here's my code.
Code:
    //===========================================
    // This runs when the player enters the map
    void OnEnter()
    {
     SetLocalVarInt("Proccess", 0);
       SetLocalVarInt("Fire", 0);
     AddTimer("brute", 13.0f, "noisy");
     AddUseItemCallback("phekeg", "breakkegknife", "winekegpop", "boomkegopen", true);
      AddUseItemCallback("phekegs", "glass_container_1", "boardone", "boomkegopen2", true);
       AddUseItemCallback("phekegs2", "fullowine", "sheetmet", "boomkegopen23", true);
       AddUseItemCallback("phekegs23", "tinderbox_1", "bonfire_1", "boomkegopen233", true);
    
    }
     void boomkegopen233(string &in asItem, string &in asEntity)
     {
     SetLocalVarInt("Fire", 1);
     }
     void boomkegopen23(string &in asItem, string &in asEntity)
     {
     if (GetLocalVarInt("Fire") == 1)
     {
     SetEntityActive("glasnotdone", true);
     RemoveItem("fullowine");
     AddTimer("brute223", 5.0f, "outahere34");
     }
    
     }
          void outahere34(string &in asTimer)
     {
         if (GetLocalVarInt("Proccess") == 1)
     {
     SetEntityActive("glasnotdone", false);
     SetEntityActive("done", true);
     }
    
     }
    
     void boomkegopen2(string &in asItem, string &in asEntity)
     {
     SetEntityActive("glass_container_2", true);
     AddTimer("brute223", 5.0f, "outahere3");
     RemoveItem("glass_container_1");
     PlaySoundAtEntity("bruto23", "19_pour_blood.snt", "Player", 0.0f, false);
     }
     void outahere3(string &in asTimer)
     {
     SetEntityActive("glass_container_2", false);
     SetEntityActive("fullowine", true);
     }
    
     void boomkegopen(string &in asItem, string &in asEntity)
     {
     PlaySoundAtEntity("bruto2", "19_inject.snt", "Player", 0.0f, false);
     SetEntityActive("breakkeg_1", true);
     AddTimer("brute23", 2.0f, "outahere");
     RemoveItem("breakkegknife");
     SetLocalVarInt("Proccess", 1);
     }
     void outahere(string &in asTimer)
     {
     SetEntityActive("wineout", true);
     SetEntityActive("breakkeg_1", false);
     FadeInSound("wineout", 1.0f, true);
     CreateParticleSystemAtEntity("hhgh", "ps_liquid_epoxy.ps", "breakkeg_1", true);
     }
     void noisy(string &in asTimer)
     {
     PlaySoundAtEntity("bruto", "enabled01.snt", "brutenoise", 0.0f, false);
     AddTimer("brute2", 4.5f, "noie");
     }
     void noie(string &in asTimer)
     {
          PlayMusic("04_amb.ogg", true, 1.0, 0.0f, 0, false);
}
    //===========================================
    // This runs when the player leaves the map
    void OnLeave()
    {
     }
What problems? Is there any error message, or does only 1 part of it not work? Go detailed with the problem.
There still is no restriction, I'm able to commit the scripts even if I haven't done the previous action leading up.
Hmm I still can not find the source of error.
If anyone could help me I'd be very grateful, I'd very much like to continue my work. Sad
Pages: 1 2 3