ID:144239
 
Code:
obj
Red_Flag
icon='other.dmi'
icon_state="red"
layer=999
Enter(A)
if(ismob(A))
var/mob/M = A
if(M.team==2)
M.overlays+=/obj/Red_Flag
M.team2flag=1
if(M.team==1)
if(M.team1flag==1)
redscore+=1
M.overlays-=/obj/Blue_Flag
M.team1flag=0
else
if(istype(A,/obj/)) del(A)


Problem description:

whats wrong witht his code?
I don't know if I am helping, But 1 why have you redefined what A is and changed it to M and also what is wron with the code?

-Digi Hero
Are you sure you want to delete any objects that end up on the flag's location? Y/N

Also instead of "if(team1flag==1)" try "if(team2flag==1)" because you want to get the ENEMY flag to your flag, not your flag to your flag. Also you may want to add the flag to the person's contents.

Sorry if my suggestions were not helpful.
In response to Atomixkid
Make the M. stuff into A.
Poal wrote:
Problem description:

whats wrong witht his code?

You call THAT a problem description? -_-
Anyway, is that even your code? What's up with your detailed explanation of whats happening and whats supposed to happen?
Anyway, you wanna know what's wrong with it? Fine.

--It uses Enter(), which is only for the purpose of deciding whether movement should be allowed or not, and therefore breaks movement to that atom by always returning false. You want to use something different such as Entered().

--You're using the Enter() on an /obj...which means it will only be called when something attempts to move inside the actual obj, not into the turf the obj is on. If you want the flag as a turf, which it should be, you need to use something such as a Trigger() proc.

--You have an unneeded typecasting; for this block of code, you can just initially define A as a mob.

--You should be using switch() to check the team, or turn one of the if()s to an 'else' statement.

--(team1flag var) You're not using boolean checks where able and apparently simply bad design.