Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Scripting/Variables problem.
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#11
RE: Scripting/Variables problem.

I cleaned up your code a bit and fixed several issues that i spotted from it. I cannot test this code, nor can i guarantee anything will work, but, assuming there are no syntax errors, something should at least happen. Note, to point out some of the issues with your code: you weren't adding to the local map variables anywhere, so the map variables Area_5 and Area_6 would never equal 5 or 6; you were checking for 0 for the callback states, when you should have been checking for -1, since the callback state would never equal 0; even though the if statements you had to check against the callback states weren't necessarily wrong, since the state can only have two states and so only one block of code would be executed, but logically you'd want to toss in "else" somewhere in there; you also repeated yourself in some way unnecessarily.

PHP Code: (Select All)
void OnEnter()
{
    
//
}

void OnStart()
{
    
SetEntityPlayerLookAtCallback("weepingangel""Callback"true);
    
AddEntityCollideCallback("Player""ScriptArea_1""dreamarea"true0);
    
AddEntityCollideCallback("Player""Area_2""boo1"true0);
    
AddEntityCollideCallback("Player""Area_3""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_4""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_5""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_6""CheckAreas"false0);
}

void Callback(string &in asEntityint alState)
{
    
AddEntityCollideCallback("Player""Area""surprisemotherfucker"true0);
}

void surprisemotherfucker(string &in asParentstring &in asChildint alState)
{
    
SetEntityPlayerLookAtCallback("weepingangel_1""Callback1"true);
    
SetEntityActive("weepingangel"false);
    
SetEntityActive("weepingangel_1"true);
    
SetEntityActive("Area_3"true);
    
SetEntityActive("Area_4"true);
    
SetEntityActive("Area_5"true);
    
SetEntityActive("Area_6"true);
}

void boo1(string &in asParentstring &in asChildint alState)
{
    
SetEntityPlayerLookAtCallback("weepingangel_1""Callback2"true);
}

void Callback1(string &in asEntityint alState)
{
    
GiveSanityDamage(20.00true);
    
AddUseItemCallback("""Hammer""weepingangel_1""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_3""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_4""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_5""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_6""lolno"false);
}

void CheckAreas(string &in asParentstring &in asChildint alState)
{

    if (
alState == 1)
    {
        
SetLocalVarInt("InsideArea"1);
        
SetLocalVarInt(asChild1);
    }

    else if (
alState == -1)
    {
        
SetLocalVarInt("InsideArea"0);
        
SetLocalVarInt(asChild0);
    }
}

void Callback2(string &in asEntityint alState)
{
    if (
GetLocalVarInt("InsideArea") == 1)
    {
        if (
alState == 1)
        {
            
//
        
}

        else if (
alState == -1)
        {
            
int suffix 0;
            for (
int i 37; ++i)
            {
                if (
GetLocalVarInt("Area_"+i) == 1)
                {
                    
suffix i;
                    break;
                }
            }
            
            if (
suffix != 0)
            {
                
FadeOut(0.50);
                
FadeIn(1.50);
                
GiveSanityDamage(5true);
                
SetEntityActive("WeepingAngel_1"false);
                
SetEntityActive("WeepingAngel_3"false);
                
SetEntityActive("WeepingAngel_4"false);
                
SetEntityActive("WeepingAngel_5"false);
                
SetEntityActive("WeepingAngel_6"false);
                
SetEntityActive("WeepingAngel_"+suffixtrue);
            }
        }
    }


Tutorials: From Noob to Pro
02-09-2013, 05:02 AM
Website Find




Users browsing this thread: 1 Guest(s)