ItsMods

Full Version: uninitialised variable accomplishment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I getan error uninitialised variable accomplishment.
It is my very first script, so it's normal to have obvius bugs or unnecessary code.
Could you help me?
Thanks in advance

It's about COD WaW but I post it here because there isn't a COD WaW section.

Code:
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_utility;

main()
{
correct = getent( "pass", "targetname" );
wrorgs = getentarray("wrong","targetname");

for(i=0; i<wrorgs.size; i++)
wrorgs[i] thread wrongs();

for(i=0; i<correct.size; i++)
correct[i] thread dartcheck();
}

dartcheck()
{
    while (1)
    {    
        self waittill("damage");

        if ( isDefined( accomplishment ) )
        {
            accomplishment = 0;
        }
        else
        {
        thread discover();
        }
        break;
        wait .05;
    }
}

wrongs()
{
    self waittill("damage");
    accomplishment = 0;
    iprintlnbold( "Wrong target! You are allowed to enter the secret room");
}

discover()
{
    iprintlnbold( "You discovered the secret!");
    wait .05;
    secret_door = getent( "secret_door", "targetname" );
    wait .05;
    secret_door MoveTo( secret_door.target, .5, 1, 1 );
}
I have never got an accomplishment error, no idea.
(03-27-2012, 20:10)Yamato Wrote: [ -> ]I have never got an accomplishment error, no idea.

The variable is accomplishment. not the error. I'll post a screenshot tommorow.
(03-27-2012, 20:12)tsoPANos Wrote: [ -> ]
(03-27-2012, 20:10)Yamato Wrote: [ -> ]I have never got an accomplishment error, no idea.

The variable is accomplishment. not the error. I'll post a screenshot tommorow.

Ahhh lol, try this:

Code:
dartcheck()
{
accomplishment = 0; //set it to whatever, if it doesnt have value left it as = undefined;
while (1)
{
You need to initialise the variable before using it:

if ( isDefined( accomplishment ) )
{
accomplishment = 0;
}

There you want to know if "isDefined( accomplishment )" that hasn't been uninitialised, just declare the variable first before using it.

Thanks Barata...
Code:
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_utility;

main()
{
level.accomplishment = undefined;

correct = getent( "pass", "targetname" );
wrorgs = getentarray("wrong","targetname");

for(i=0; i<wrorgs.size; i++)
wrorgs[i] thread wrongs();

for(i=0; i<correct.size; i++)
correct[i] thread dartcheck();
}

dartcheck()
{
    while (1)
    {    
        self waittill("damage");

        if ( isDefined( level.accomplishment ) )
        {
            level.accomplishment = 0;
        }
        else
        {
        thread discover();
        }
        break;
        wait .05;
    }
}

wrongs()
{
    self waittill("damage");
    level.accomplishment = 0;
    iprintlnbold( "Wrong target! You are allowed to enter the secret room");
}

discover()
{
    iprintlnbold( "You discovered the secret!");
    wait .05;
    secret_door = getent( "secret_door", "targetname" );
    wait .05;
    secret_door MoveTo( secret_door.target, .5, 1, 1 );
}