Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Cronyne

What is wrong with this scripts?(solved!)

Recommended Posts

Issue has been solved. And I also compressed both scripts into one. Here is the script for anyone that wants to use it.

#include "zcommon.acs"

script 1 (void)

{
    if (CheckInventory ("Minigun") > 0)
        {
            if (CheckInventory("Clip") < 1)
                {
                    ActivatorSound("gatlgun",127);
                    Delay(105);
                    GiveInventory("Clip",200);
                }
        }
    else
        {
            TakeInventory("Clip",400);
            GiveInventory("Minigun",1);
            TakeInventory("Clip",400);
            GiveInventory("Clip",200);
        }
}

Share this post


Link to post

1. You're missing the curly brackets ( { and } ) that are supposed to define your if and else blocks.
http://remilia.zdoom.org/wiki/A_Quick_Beginners_Guide_to_ACS#Conditional_execution_.28if_.2F_else.29

2. CheckInventory returns the number of items in your inventory. '>' Compares this number to 1. So your "player doesn't have a chaingun" script would launch ONLY AND ONLY when the player has TWO OR MORE chainguns in his inventory (which is, btw, impossible).

Share this post


Link to post

Thank you, I'll keep that in mind, but I got a new issue popping up.

Here's the new script


#include "zcommon.acs"

script 1 (void)
{
if (CheckInventory("Minigun") 1)
{
ACS_Execute(2,0,0,0,0);
}
else
{
TakeInventory("Clip",400);
GiveInventory("Minigun",1);
TakeInventory("Clip",100);
GiveInventory("Clip",20);
}

}

script 2 (void)
{
if (CheckInventory("Clip") 0)
{
ActivatorSound("gatlgun",127);
Delay(105);
GiveInventory("Clip",20);
}
else
{
(void)
}
}



On my CheckInventory lines, Doom builder tells me I'm missing a bracket, these> ) kind.

I don't see where.

Share this post


Link to post

"CheckInventory("Clip") 0" is illegal. You need a comparison operator (or just use the function name without anything else if the function returns a true/false value and you're fine with that). For example, the chaingun check should be
"CheckInventory("Minigun") == 0"
OR
"CheckInventory("Minigun") < 1"

There's a bunch of other ways to do it, too, but those two are the easiest to understand.

Share this post


Link to post

Please use code tags, like so:

#include "zcommon.acs"

script 1 (void)
{
    if (CheckInventory("Minigun") > 0)
        ACS_Execute(2,0,0,0,0);
    else 
    {
        TakeInventory("Clip",400);
        GiveInventory("Minigun",1);
        TakeInventory("Clip",100);
        GiveInventory("Clip",20);
    }
}

script 2 (void)
{
    if (CheckInventory("Clip") > 0)
    {
        ActivatorSound("gatlgun",127);
        Delay(105);
        GiveInventory("Clip",20);
    }
}
By the way, the "else void" part is completely useless. You do not need to use an else to make nothing happen. And you only need curly brackets in if/else or while statements if you have several instructions, when you have only one, such as after the if in script 1, it's not needed; when you have several, such as after the else of the same script, it is absolutely necessary.

Share this post


Link to post

... You just gave me the entire script I needed. (minus a few modifications).

Thanks both of you! I'll keep all this info in mind for the future.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×