ID:145450
 
Code:
turf
Switch
var/align="red"
icon='Blue.dmi'
icon_state="switch"
Entered(atom/movable/a)
if(ismob(a))
var/mob/mobile=a
if(mobile.red)
for(var/mob/M in world)
if(M.bjailed)
M.loc=locate(8,46,2)
M.bjailed--
redtj=0
world<<"Red team freed."
else
..()
else
for(var/mob/M in world)
if(M.rjailed)
M.loc=locate(42,5,2)
M.rjailed--
bluetj=0
world<<"Blue team freed."
else
..()


Problem description:

I've tried about three different ways and have broken my head trying to figure this out. I even recoded the game(it being a small one) about four times or five. I lost count. Basically, when you enter, anyone in your team thati s jailed is free. I had it as a verb last time and it only worked for -RED-....Blue it wouldn't do anything, I have no idea why.

Any help appreciated.
After examining the code a few times, it looks like you have a pretty inefficient team-system. Am I right in thinking that blue team mobs have some blue var set to 1, and red team mobs have a red team var set to 1? If so, you're making it much more complicated than it needs to be.

Really, all you need to distinguish teams is 1 variable. The var would distinguish what team the mob was on, and could be a multi-purpose var. For example:
mob
var
team = "red" // A simple string to distinguish teams
jailed = 0 // Another var to distinguish whether the mob is jailed.

proc/Jail(n=1) // Used to jail/unjail mobs - pass a 0 to unjail.
jailed=n
if(jailed)
src << "You have been jailed!"
else
src << "You have been unjailed!"

turf
Switch
var/align = "red" // I think this was used to affect what team could use it?
icon = 'Blue.dmi'
icon_state = "switch"
Entered(a)
if(ismob(a))
var/mob/mobile = a
if(mobile.team == align) // Check to see if the mob's team var matches the switch's align var.
for(var/mob/M)
if(M.team == mobile.team && M.jailed) // If they are on the same team and are jailed.
switch(M.team) // Determine the team to find out where to locate them.
if("red")
M.loc = locate(8,46,2)
if("blue")
M.loc = locate(42,5,3)
M.Jail(0)
world << "The [mobile.team] team was freed."

As you can see, a multi-purpose team var is much more useful than going through a ton of if(mob.red), if(mob.bjailed), etc. statements.

Hope that helps some.
Hiead