ID:177716
 
How can I make a var that will apply to all mobs on one team?
mob/var/team = "" as text

mob/Login()
..()
var/O = input("") in list ("green","red")
src.team = "[O]"

mob/verb/TeamSay(T as text)
for(var/mob/M as mob in world)
if(M.team == src.team)
M << "[src]: [T]"
continue
else continue

I even gave you an example on how to use it :)
In response to Super16
Im sorry, I think you missunderstood me. Im looking for a way to make a var, the ammount of ammunition the team has stored, that can be accessed by the whole team. I hope that clarifies thing a bit.
In response to Jotdaniel
var/GAMMO = 0
var/RAMMO = 0

mob/var/team = ""
mob/Stat()
..()
statpanel("ammo")
if(team == "green")
stat(GAMMO)
else
stat(RAMMO)
In response to Super16
OOHH, you just put the var by itself, I was trying to put it under world. Thanks man
In response to Super16
The stat for it wont work. I cant figure out why. Doesnt really matter that much, but im just wondering how to do it.
In response to Super16
Super16 wrote:
var/GAMMO = 0
var/RAMMO = 0

This is a really really bad approach to Jotdaniel's problem and shouldn't be recommended by anyone.
The correct solution is to use a datum.

Lummox JR
Jotdaniel wrote:
How can I make a var that will apply to all mobs on one team?

The way you'd do this would be to make a datum. A datum can keep track of all kinds of information about the team: Its members, score, the location of its base, locations of its flags (in a CTF type of game), missions it might have, etc.
team
var/name
var/list/players
var/ammo // the ammo var you wanted
var/score
var/color // for HTML messages

New(nm,_color)
players=list()
name=nm
if(!_color) _color=name
color=_color

proc/TeamMsg(msg)
players << "<FONT color='[color]'><B>[msg]</B></FONT>"

proc/Join(mob/M)
if(!M) return
if(M.team && M.team!=src) M.team.Leave(M)
players+=M
TeamMsg("[M.name] joins the team.")
M.team=src

proc/Leave(mob/M)
players-=M
TeamMsg("[M.name] leaves the team.")
if(!M || M.team!=src) return
M.team=null
if(M.team && M.team!=src) M.team.Leave(M)
players+=M
M.team=src

mob
var/team/team

Logout()
if(team) team.Leave(src)

var/team/redteam=new("red")
var/team/blueteam=new("blue")

This is a basic piece of code to get you started. You can create a list of teams if you like, or create teams on the fly.

Lummox JR
In response to Lummox JR
Thanks. That will help a lot. I see where I going wrong now.