ID:168240
 
What do i need to put before
 
if(M.team1 == 1)
M.loc=locate(105,89,1)
M.icon_state = ""
M.overlays -= 'flag.dmi'
M.hasflag = 0
M.density = 1

if(M.team2 == 1)
M.loc=locate(111,89,1)
M.icon_state = ""
M.overlays -= 'flag.dmi'
M.hasflag = 0
M.density = 1


in my game to make it affect all the players in the world.
Hmm, I don't really know what you are trying to do but...for(var/mob/M in world). Also, don't use var==1, var2==1. Just do if(var) or if(var2).
        
for(mob/M in world)
if(M.team1)
M.loc=locate(105,89,1)
M.icon_state = ""
M.overlays -= 'flag.dmi'
M.hasflag = 0
M.density = 1
else
M.loc=locate(111,89,1)
M.icon_state = ""
M.overlays -= 'flag.dmi'
M.hasflag = 0
M.density = 1


This should work. I removed the 2nd one and changed it as an ELSE argument. I removed "== 1" because the default of just running if([variable]) is to check if its not set to 0, null, and such. It would check if its equal to 1 in other words.
In response to Ryuo
Why did you do that? The else argument would mean if(!team1), and there are 2 seperate vars. Both if() checks are needed.
It would also be better to keep a list of the players in a team rather than a variable for each. Then you could do something like:
var/list/Teams=list("1"=list(),"2"=list())
mob/Login()
..()
if(Teams["1"].len > Teams["2"].len) Teams["2"].Add(src)
else if(Teams["1"].len < Teams["2"].len) Teams["2"].Add(src)
else Teams["[pick("1","2")]"].Add(src)

//and in your proc

for(var/mob/M in Teams["1"])
//stuff here
for(var/mob/M in Teams["2"])
//stuff here


I love associative lists now. Lummox showed me these. >=D
In response to CaptFalcon33035
CaptFalcon33035 wrote:
var/list/Teams=list("1"=list(),"2"=list())
mob/Login()
..()
if(Teams["1"].len > Teams["2"].len) Teams["2"].Add(src)
else if(Teams["1"].len < Teams["2"].len) Teams["2"].Add(src)
else Teams["[pick("1","2")]"].Add(src)

//and in your proc

for(var/mob/M in Teams["1"])
//stuff here
for(var/mob/M in Teams["2"])
//stuff here


Unfortunatly you can't recall a variable which the compiler doesn't know of at that point like that. If you're going to show something to someone, do it correctly at least. Use length() to figure out the length of the potential list, and just use += to add someone to a team.

~~> Unknown Person
In response to Unknown Person
I'm sorry. I thought it might work because I use a system just like that with a Files list. It sorts through the files and adds them to their corresponding category, just as the way you see there, except I didn't use len. I used length(), I just thought I might give .len a try, after all, I never use it.

Is there a good time and a bad time to use .len when you are at least able? And why not use the Add() proc?
In response to Artemio
Yes, if theres only 2 teams, it would effectively switch to the second team since it was not on the first one.