Frictional Games Forum (read-only)

Full Version: Help with GetLocalVarInt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have script that we must put three wheels to machine after my next function must show message if GetLocalVarInt = 3. Of course don't show

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Plax", true, 1);
AddEntityCollideCallback("cogwheel_tiny01_4", "StickyArea_3", "CollideWheel", false, 1);
AddEntityCollideCallback("cogwheel_tiny01_5", "StickyArea_1", "CollideWheel", false, 1);
AddEntityCollideCallback("cogwheel_tiny01_6", "StickyArea_2", "CollideWheel", false, 1);
}


void CollideWheel(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("asChild", 1);
    PlaySoundAtEntity("", "impact_metal_low", "Player", 0.05f, false);
    
}


void StartSectionDead(string &in asChild, int alVal)
{
if(GetLocalVarInt("asChild") != 3) {
SetMessage("Journal", "Slime", 0);
}
}
I don't see anywhere where "StartSectionDead" is actually being called.

Also, != 3 means not equal to 3.
If i set "==" too is don't work. Hmm how I call this function when three wheels is putting ?

I check it but still is dead

Code:
void CollideWheel(string &in asParent, string &in asChild, int alState)
{
    AddLocalVarInt("asChild", 1);
    PlaySoundAtEntity("", "impact_metal_low", "Player", 0.05f, false);
    if(GetLocalVarInt("asChild") == 3) {
      AddEntityCollideCallback("Player", "ScriptArea_2", "StartSectionDead", false, 1);
}
}


void StartSectionDead(string &in asParent, string &in asChild, int alState)
{
SetMessage("Journal", "Slime", 0);
}
You must set a local var int first be adding.

Use this:

SetLocalVarInt("asChild", 0); in your void OnStart()

It's just all messed up... :/
You don't need to use quotation marks when using the asChild reference. asChild is already a string, and you use " " to denote a string. You're basically saying ""asChild"". Also, you need to script the collide callback in your OnStart, as well as declare the variable beforehand. Like Kyle said, use SetLocalVarInt() to declare your variable. Since we don't know what your asChild is named, you'll need to do that on your own.
Easy I finished this problem yesterday ;] thanks all