# Limited weapon usage

**URL:** https://forum.kirupa.com/t/limited-weapon-usage/62073
**Category:** Uncategorized
**Created:** [August 24, 2004, 6:39pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073 "2004-08-24T18:39:33Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Myctapeiro](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Myctapeiro](https://forum.kirupa.com/u/Myctapeiro)
#### Post date: [August 24, 2004, 6:39pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/1 "2004-08-24T18:39:33Z")

</div>

Does anyone know how to limit the usage of a weapon in a basic shooting game??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 24, 2004, 6:57pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/2 "2004-08-24T18:57:15Z")

</div>

What do you mean? how much ammo the user can use, or how often the user can fire?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 25, 2004, 6:29pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/3 "2004-08-25T18:29:58Z")

</div>

how much ammo the user can use. I have special weapons and i want them to be limited to three uses

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2004, 11:26pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/4 "2004-08-27T23:26:00Z")

</div>

every time the gun is fired, add 1 to a variable.  
everytime the variable changes, do a logical test to see if the variable is equal to 3, and if it is, then do whatever you want - disable the gun or whatever.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 31, 2004, 4:49pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/5 "2004-08-31T16:49:57Z")

</div>

could you give me an example of how i would incorporate that into my code this is the code i have on the weapon i want to limit:

onClipEvent (load) {  
this.\_x = \_root.spaceship.\_x;  
this.\_y = \_root.spaceship.\_y;  
}

onClipEvent (enterFrame) {  
if (Key.isDown(Key.SHIFT)){  
\_root.bomb.\_visible=true;  
this.gotoAndPlay(2);  
}  
}  
onClipEvent (enterFrame) {  
for (i=1; i\<=\_root.numEnemy; i++) {  
if (this.hitTest(\_root[“enemy”+i])) {  
\_root.score += 25;  
\_root[“enemy”+i].gotoAndStop(7);  
}  
}   
}  
onClipEvent (enterFrame) {  
for (k=1; k\<=\_root.numelaser; k++) {  
if (this.hitTest(\_root[“elaser”])){  
\_root[“elaser”+k].gotoAndStop(3);  
}  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 31, 2004, 4:51pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/6 "2004-08-31T16:51:54Z")

</div>

could you upload the fla so i can see the code in action and see what each bit does. it’d be much easier  
thanks.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 4:13pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/7 "2004-09-01T16:13:13Z")

</div>

I don’t know what the deal is but it’s not letting me upload my file.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 6:43pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/8 "2004-09-01T18:43:23Z")

</div>

possible the file is too large. you can email me it if you want.  
email it to: [paul\_scott\_1@hotmail.com](mailto:paul_scott_1@hotmail.com)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 3, 2004, 7:22pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/9 "2004-09-03T19:22:28Z")

</div>

the file is too big for hotmail also, I don’t know what else to do.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 9, 2004, 1:58pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/10 "2004-09-09T13:58:21Z")

</div>

ok, i figured out how to limit my weapons, but i used a dynamic text box and 1 gets subtracted from three when i use the special weapon. Problem: it doesn’t stop subtracting when it hits 0 and the counter subtracts too fast. How can i slow down the counter and make it stop at 0???

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 9, 2004, 4:05pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/11 "2004-09-09T16:05:19Z")

</div>

to test when it is at 0, simple do an if test.  
_target_ is the name of the dynamic text box:

```auto
if (target.text == "0") {
   //do actions once weapon limit has reached.
}

```

as for slowing down the speed it is counting down to the limit at - what method are you using to countdown? what triggers the countdown? can you upload the file?

hope this wee bitty helps you

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 9, 2004, 4:06pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/12 "2004-09-09T16:06:33Z")

</div>

oh, that’s right, you said it’s too big. maybe you can upload it to a website?  
if you’re on msn messenger, you can add me on [paul@kerb.ws](mailto:paul@kerb.ws) and send me the file using it.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 10, 2004, 4:12pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/13 "2004-09-10T16:12:40Z")

</div>

Ok, this is the code in my special weapon as of now. Hope this is enough cause I don’t actually have access to Messenger at my High School.

onClipEvent (load) {  
this.\_x = \_root.spaceship.\_x;  
this.\_y = \_root.spaceship.\_y;  
}

onClipEvent (enterFrame) {  
if (Key.isDown(Key.SPACE)){  
\_root.bomb.\_visible=true;  
this.gotoAndPlay(2);  
\_root.ammo-=1;  
}  
}  
onClipEvent (enterFrame) {  
for (i=1; i\<=\_root.numEnemy; i++) {  
if (this.hitTest(\_root[“enemy”+i])) {  
\_root.score += 25;  
\_root[“enemy”+i].gotoAndPlay(2);  
}  
}   
}  
onClipEvent (enterFrame) {  
if (\_root.ammo == 0) {  
\_root.bomb.gotoAndStop(2);  
}  
}  
onClipEvent (enterFrame) {  
for (k=1; k\<=\_root.numelaser; k++) {  
if (this.hitTest(\_root[“elaser”])){  
\_root[“elaser”+k].gotoAndStop(3);  
}  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 12, 2004, 12:14am UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/14 "2004-09-12T00:14:20Z")

</div>

hm… it’s pretty hard to tell when only seeing the code.  
where do each of the pieces of code go?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 14, 2004, 1:16pm UTC](https://forum.kirupa.com/t/limited-weapon-usage/62073/15 "2004-09-14T13:16:16Z")

</div>

The code i’ve given is on the weapon i’m trying to limit
