ID:261731
 
ok...

client
Center()
if(usr.dir == NORTH) {
var/obj/O
//O:atk = usr.atk
O = new /obj/swordn(locate(usr.x,usr.y + 1,usr.z))
O:atk = usr.atk
goto End
}
if(usr.dir == SOUTH) {
var/obj/O
//O:atk = usr.atk
O = new /obj/sword(locate(usr.x,usr.y - 1,usr.z))
O:atk = usr.atk
goto End
}
if(usr.dir == EAST) {
var/obj/O
//O:atk = usr.atk
O = new /obj/sworde(locate(usr.x + 1,usr.y,usr.z))
O:atk = usr.atk
goto End
}
if(usr.dir == WEST) {
var/obj/O
O = new /obj/swordw(locate(usr.x + 1,usr.y,usr.z))
O:atk = usr.atk
goto End
}
End
//Southeast()
// return 0

//proc/Southwest()
// return 0

obj/sword
icon='sword.dmi'
icon_state="sword"
var/atk
var/def
var/dmg
New()
sleep(3) // Just a little processing time.
for(var/mob/M in src.loc)
dmg = atk - M:def
M.HP -= dmg
sleep(2) // More processing time, it's always helped me out because if I use del() after a for() proc, and not used a sleep, it often deletes before it finishes looping.
del(src)

etc.. it makes the sword fine, but when the sword disappears byond says 'client: cannot modify null.atk'...the client is trying to modify it too late, what's with it?
I'm not sure what the problem with your code is, but I think you'd be a lot of better off it you wrote it like this:

<code>client/Center() var/target_loc = get_dir(src, src.dir) var/dmg var/obj/swordw/sword = new(target_loc) sword.dir = src.dir for(var/mob/M in target_loc) dmg = src.atk - M.def M.HP -= dmg obj/swordw icon = 'sword.dmi' icon_state = "sword" New() ..() spawn(3) del(src)</code>

Basically, when you attack it determines the turf in the direction you're attacking. Then it creates a sword object on that square, facing in that direction. Then it damages every mob in inside that turf.

The sword object also automatically deletes itself after 3 ticks. You shouldn't need to worry about modifying anything having to do with the sword object.
In response to Foomer
Oop, make that get_step() instead of get_dir().