Frictional Games Forum (read-only)

Full Version: Need help with my script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,
this script doesn't work. "icounter" must be declared and expression must be in boolean type.

PHP Code:
void OnStart()
{
int icounter 1;
}

void counter(string &in asStickyAreastring &in asBodyName)
{
if (
icounter 2) ++icounter
Here^ "icounter" should be declared
PHP Code:
else GiveSanityBoostSmall();


I don't need to declare "icounter". I could be in boolean type but I don't know why it doesn't work this way.

Any suggestions?
icounter is a local variable, which is why the function counter does not recognize it.

EDIT: Also, it says your expression is not of type Boolean because icounter isn't declared, so it's meaningless. It's the same as saying: If three is less than banana then this.
To make it a global variable (visible to every function) move it out of the OnStart() function. For example, like this:
PHP Code:
int icounter 1;

void OnStart()
{
}

void counter(string &in asStickyAreastring &in asBodyName)
{
    if (
icounter 2) ++icounter
    else 
GiveSanityBoostSmall();

(05-26-2013, 12:58 AM)TheGreatCthulhu Wrote: [ -> ]To make it a global variable (visible to every function) move it out of the OnStart() function. For example, like this:
PHP Code:
int icounter 1;

void OnStart()
{
}

void counter(string &in asStickyAreastring &in asBodyName)
{
    if (
icounter 2) ++icounter
    else 
GiveSanityBoostSmall();


Thanks! Now it works, you deserved a reputation Smile