Page 1 of 1

reactions if varable is true

PostPosted: Wed Aug 04, 2010 7:03 pm
by PWNED
Hey Everyone!
I am having some trouble with varables.
I have a game were you can only create an actor (the bullet) if you have ammo.
so i have a var. that increases when you collide with an ammo packet and the coding for that looks like this

    ammo = ammo + 30;

then i have the script for shooting... here im totaly lost...
this is what i made
key down

    if (ammo >= 1);
    {
    CreateActor("Bullet_2", "Bullet_2", "(none)", "(none)", 0, 0, false);
    }


but the problem is that when key is down it shoots even if there is no ammo Whats wrong???????

Re: reactions if varable is true

PostPosted: Wed Aug 04, 2010 7:23 pm
by Hblade
You need to have the ammo subtract :P
Code: Select all
if (ammo >= 1)
{
Create actor...
ammo--;
}


I make mistakes like that too :o

Re: reactions if varable is true

PostPosted: Wed Aug 04, 2010 7:33 pm
by PWNED
Hblade wrote:You need to have the ammo subtract :P
Code: Select all
if (ammo >= 1)
{
Create actor...
ammo--;
}


I make mistakes like that too :o


oh lord this came up when I hit ok

Error line 1: Unknown type in binhconst
Warning line 1: Possible non relational operation
Error line 1: Undefined type for relational operation
Error line 4: Cannot apply inc\dec
Error line 27: Expected )
:shock:
and this is my code

if (Ammo >=1)
{
CreateActor("Bullet_2", "Bullet_2", "(none)", "(none)", 0, 0, false);
Ammo--;
}

plz help

Re: reactions if varable is true

PostPosted: Wed Aug 04, 2010 10:34 pm
by PWNED
ok fixed it

Re: reactions if varable is true

PostPosted: Fri Aug 06, 2010 11:41 pm
by Hblade
lol, capital A? XD

Re: reactions if varable is true

PostPosted: Sat Aug 07, 2010 10:14 am
by savvy
i never use a capital unless im distinguishing words without a space, eg: enemyShoot instead of enemy_shoot.
also, u can shorten your codes a bit.
Code: Select all
Ammo+=30;

Code: Select all
if(Ammo>1)
{
create..(bleh);
Ammo-=1; (or Ammo--;)
}

but yeah, dont bother with Ammo=Ammo+30; use Ammo+=30;