Page 1 of 1

Attribute scripting won't work

Posted: Wed Aug 06, 2008 5:43 pm
by Danimita92
Hi everybody, I was scripting, and suddenly this happened. I have this in the order:

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
}
}]
THe console says Parse error near ""*
Now if I take away
HighLevel("Eliminar");
return 0;
It works.
And if I take away
ModifyAttribute("BalasTotales", +20, "Arma1");
It also works.

So

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            HighLevel("Eliminar");
            return 0;
        }
}
}]
and

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
        }
}
}]
work, but together they won't. Why?

Re: Attribute scripting won't work

Posted: Thu Aug 07, 2008 4:26 pm
by Danimita92
BTW, i added the attribute in the previous order, like this:

Code: Select all

AddAttribute("BalasTotales", -1, 100, "Arma1");

Re: Attribute scripting won't work

Posted: Thu Aug 07, 2008 4:35 pm
by Juutis
I see nothing wrong with it. Could the bracets around the GetAttribute() mess it up?

Could you post the Eliminar order? Or even better, the whole script.

Re: Attribute scripting won't work

Posted: Thu Aug 07, 2008 4:48 pm
by Danimita92
Okay, so I've changed a few things. For example add the order Idle which I didn't have before since it never actually got passed the CogerArma order. Anyway, so now it won't even let me play, because the "Send Report" message appears. The three triggers it asks for are already on the map.

Code: Select all

{
    BALAS [0]
    SLOT [0]
    BALASTOTALES [0]
 
Spawn[()
    {
        Console(true);
        AddAttribute("BalasTotales", -1, 100, "Arma1");
        LowLevel("CogerArma");
    }]

CogerArma[()
{
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES -1)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES = 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            self.think = "Buscarslot";
            return 0;
        }
    }
}]

Buscarslot[()
    {
        if(GetEventState("Slot1") = false)
        {
            SLOT = 1;
            ActivateTrigger("Slot1");
            self.think = "Idle";
        }
        else
        {
            if(GetEventState("Slot2") = false)
            {
                SLOT = 2;
                ActivateTrigger("Slot2");
                self.think = "Idle";
            }
            else
            {
                if(GetEventState("Slot3") = false)
                {
                    SLOT = 3;
                    ActivateTrigger("Slot3");
                    self.think = "Idle";
                }
                else
                {
                    HighLevel("Eliminar");
                }
            }
        }
    }]

Eliminar[()
{
    Remove(true);
}]

Idle[()
{
    //Nothing yet
}]
    
}

Re: Attribute scripting won't work

Posted: Thu Aug 07, 2008 5:17 pm
by Juutis
Removed some unneeded stuff; brackets, spaces, plus signs. Works fine for me now:

Code: Select all

{
    BALAS [0]
    SLOT [0]
    BALASTOTALES [0]

Spawn[()
    {
        Console(true);
        AddAttribute("BalasTotales",-1,100,"Arma1");
        LowLevel("CogerArma");
    }]

CogerArma[()
{
    if(FastDistance("Player",20))
    {
        BALASTOTALES = GetAttribute("BalasTotales", "Arma1");
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES -1)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES = 0)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            self.think = "Buscarslot";
            return 0;
        }
    }
}]

Buscarslot[()
    {
        if(GetEventState("Slot1") = false)
        {
            SLOT = 1;
            ActivateTrigger("Slot1");
            self.think = "Idle";
        }
        else
        {
            if(GetEventState("Slot2") = false)
            {
                SLOT = 2;
                ActivateTrigger("Slot2");
                self.think = "Idle";
            }
            else
            {
                if(GetEventState("Slot3") = false)
                {
                    SLOT = 3;
                    ActivateTrigger("Slot3");
                    self.think = "Idle";
                }
                else
                {
                    HighLevel("Eliminar");
                }
            }
        }
    }]

Eliminar[()
{
    Remove(true);
}]

Idle[()
{
    //Nothing yet
}]
   
}
If it crashes, double check that you have a pawn called Arma1 in the level.

Re: Attribute scripting won't work

Posted: Thu Aug 07, 2008 6:32 pm
by Danimita92
Well, yet again, it was a problem from the program. I reinstalled it in another folder and it worked fine :evil: