ID:267662
 
Hi

i have got a shoot command but am a little stuck with Ammo

i made it a var and a stat...

but i cant get it to stop going down when you fire because when you fire it got down to 9 fire again then 8 and so on

but when it gets to 0 you can still fire and it goes in the -'s

thanks
Structure your shoot verb like this:

mob/verb/shoot()
if(usr.ammo >= 1)
//do shooting stuff
else
usr<<"You are out of ammo!"
In response to Jotdaniel
thanks for that

but the ammo in my stats keep on going into the -'s again
In response to Mousie_kebabs
You did plug in the if statement into your shooting verb, right? =)

-Camaro-
In response to Camaro
if(usr.Ammo >= 0)
else
usr << "you ate out of ammo"


In response to Mousie_kebabs
Put the rest of the verb in the MIDDLE of the if and the else.
In response to Jotdaniel
i got it all to work with no errors

but you can keep shooting when you have 0 ammo it just got to -1 and -2 to so on
In response to Mousie_kebabs
Post your shooting verb so we can see. :P

-Camaro-
In response to Camaro
mob/verb/shoot()
usr.projectile(new/obj/bullet(usr.loc),usr.dir,5)
usr.Ammo -= 1
if(usr.Ammo >= 0)
else
usr<<"You are out of ammo!"
//the above

obj
bullet
icon='mob.dmi'
icon_state = "fire"
density=1
Bump(mob/M)
if(istype(M,/mob))
del(M)
del(src)

mob
proc
projectile(obj/projectile,var/dir,var/delay)
walk(projectile,dir)
sleep(delay)
del(projectile)


i posted it all just incase :-p
In response to Mousie_kebabs
 mob/verb/shoot()
if(usr.Ammo >= 0)
usr.projectile(new/obj/bullet(usr.loc),usr.dir,5)
usr.Ammo -= 1
else
usr<<"You are out of ammo!"


-Camaro-
In response to Mousie_kebabs
I SAID put the if before the shooting stuff, what the heck do you think I meant?


if(usr.ammo >=1)
usr.projectile(new/obj/bullet(usr.loc),usr.dir,5)
usr.Ammo -= 1
else
usr<<"You are out of ammo!"
In response to Camaro
that helped alot

but

it still goes to -1

and sometimes -2
In response to Camaro
Gotta do >= 1 Camero, read my post. If you do 0 it still lets you fire if you have 0 ammo.
In response to Jotdaniel
keep yer pants on jot :-p

no need to buzz is there now?
In response to Jotdaniel
thanks jot :D

it works now :-)
In response to Mousie_kebabs
Its simple, I wont help people that dont let me help them.
In response to Jotdaniel
sorry jot...i was a little confused

i got more problems :'(

i changed it to a obj verb not a mob verb and now you can shoot to -1 again
In response to Jotdaniel
gah.. something went wrong when I replied. I copied yours and insterted it into his code.

-Camaro-
In response to Camaro
Heres a few tips, if you wana check if something is >=1 like if(usr.Ammo>=1) you can just do if(usr.Ammo)
And if you wana add or substract 1, you can just do ++ or --
Heres the code with does changes

mob/verb/shoot()
if(usr.Ammo)
usr.projectile(new/obj/bullet(usr.loc),usr.dir,5)
usr.Ammo--
else
usr<<"You are out of ammo!"

I made a mistake...
if(usr.Ammo) will be true if usr.Ammo not zero so I guess you better use usr.Ammo<=1
In response to FranquiBoy
Dont post on things of which you have no knowledge. the if(var) and if(!var) statements only work for true or false vars, 1 or 0, not vars that operate like ammunition.
Page: 1 2