reactions if varable is true

Non-platform specific questions.

reactions if varable is true

Postby PWNED » Wed Aug 04, 2010 7:03 pm

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???????
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: reactions if varable is true

Postby Hblade » Wed Aug 04, 2010 7:23 pm

You need to have the ammo subtract :P
Code: Select all
if (ammo >= 1)
{
Create actor...
ammo--;
}


I make mistakes like that too :o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: reactions if varable is true

Postby PWNED » Wed Aug 04, 2010 7:33 pm

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
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: reactions if varable is true

Postby PWNED » Wed Aug 04, 2010 10:34 pm

ok fixed it
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: reactions if varable is true

Postby Hblade » Fri Aug 06, 2010 11:41 pm

lol, capital A? XD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: reactions if varable is true

Postby savvy » Sat Aug 07, 2010 10:14 am

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;
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest