ID:268034
 
I tried coding something, it invovles flags. I made a stat that if the person is on the blue team, and tells them if they have the have the red flag, and if red team, tells them if they have the blue flag. No errors, but when I pick up the flag on either team, the Stat says "Have Red Flag:" and it doesnt say "Yes" or "No" next to it. Heres the code:

First, the Flag Code:

var/have_red_flag
var/have_blue_flag







obj
Red_Flag
density = 1
icon = 'Red Flag.dmi'
Bumped(mob/M)
if(istype(M, /mob))
if(M.team == "Blue")
src.loc = M
M.overlays += src.icon
world << "<font color=red size=3><b>[M] has the [src]!</b></font>"
have_red_flag = "Yes"
else
M <<"You can't pick up your own team flag!"


Blue_Flag
density = 1
icon = 'Blue Flag.dmi'
Bumped(mob/M)
if(istype(M, /mob))
if(M.team == "Red")
src.loc = M
M.overlays += src.icon
world << "<font color=red size=3><b>[M] has the [src]!</b></font>"
have_blue_flag = "Yes"
else
M <<"You can't pick up your own team flag!"




Now, the Stat Code:

mob
Stat()
..()
statpanel("Team")
if(src.redteam == team)
stat("Have the Blue Flag: [have_red_flag]")
else
stat("Have the Red Flag: [have_blue_flag]")


Please try and help!
Thanks!

~~SSJ4_Gohan_Majin
Not tring to be a bad person but maybe in your statpanel that you already have for th player's main stats, you can make it add a line that says You have the Red/Blue flag! instead of making it say yes or no. Then make it change the var to = 1 or 0 depending on if u have itor no then if u die make it dissapear, that might fix the problem, i dont see anything wrong with the code, but i was never good at detecting bugs. Either way, if you like this idea better, try it out, otherwise, i cant help you.
In response to Metroid
Never mind, I figured out how to do it.

~~SSJ4_Gohan_Majin
In response to SSJ4_Gohan_Majin
There's a better way to do it, though. Just replace the [has_flag] with [has_flag ? "Yes" : "No"].

If the thing to the left of the ? is true, then that will return the thing to the left of the colon ("Yes"), otherwise, it is the thing to the right of the colon("No").

Also, you only need one has_flag variable, because you can't hold your own team's flag.