ID:1170560
 
(See the best response by Kaiochao.)
Code:
mob
verb

Shadow_Spar()
set hidden =1
if(canSpar)
usr.move = 0
usr.icon_state="Rest"
usr.dir=SOUTH
usr.canSpar=0
var/image/sparDir/I = image('sparDir.dmi', src)
I.pixel_y =32
I.icon_state=pick("north","south","west","east")
usr<<I

else sparBreak()
proc
sparBreak()
if(!canSpar)
usr.move=1
usr.icon_state=""
canSpar=1
for(var/image/sparDir/I in client.screen) del(I)

client
North()
if(!mob.canSpar)
for(var/image/sparDir/I in mob.client.screen)
if(I.icon_state=="north")
var/A = round(mob.maxExp/100)
var/B = round(mob.maxExp/100)*2
var/C = round(mob.maxExp/100)*3
mob.exp+=pick(A,B,C)
I.icon_state=pick("north","south","west","east")
else mob.sparBreak()
else ..()

East()
if(!mob.canSpar)
for(var/image/sparDir/I in mob.client.screen)
if(I.icon_state=="east")
var/A = round(mob.maxExp/100)
var/B = round(mob.maxExp/100)*2
var/C = round(mob.maxExp/100)*3
mob.exp+=pick(A,B,C)
I.icon_state=pick("north","south","east","west")
else mob.sparBreak()
else ..()
West()
if(!mob.canSpar)
for(var/image/sparDir/I in mob.client.screen)
if(I.icon_state=="west")
var/A = round(mob.maxExp/100)
var/B = round(mob.maxExp/100)*2
var/C = round(mob.maxExp/100)*3
mob.exp+=pick(A,B,C)
I.icon_state=pick("north","east","south","west")

else mob.sparBreak()
else ..()
South()
if(!mob.canSpar)
for(var/image/sparDir/I in mob.client.screen)
if(I.icon_state=="south")
var/A = round(mob.maxExp/100)
var/B = round(mob.maxExp/100)*2
var/C = round(mob.maxExp/100)*3
mob.exp+=pick(A,B,C)
I.icon_state=pick("north","south","west","east")
else mob.sparBreak()
else ..()


Problem description: So my problem is that every time I hit an arrow key, nothing happens. I'm assuming it has to do with the for() proc but i'm not sure about what to do.

Bump.
Best response
Before you get too far with the habit of copy/pasting your code, I'm going to force this down your throat.
//  This is called whenever a player provides movement input.
client/Move(Loc, Dir)
// If the player's not sparring, do normal stuff.
if(mob.canSpar)
return ..()

mob.sparHit(Dir)

mob
// Since there can only be one sparDir image,
// you might as well make it a variable instead of
// loop through client.images needlessly.
var tmp/image/sparDir

verb/Shadow_Spar()
set hidden = 1
if(!canSpar)
sparBreak()

else
canSpar = 0
move = 0
dir = SOUTH
icon_state = "Rest"
sparDir = image('sparDir.dmi', src)
sparDir.pixel_y = 32
sparDir.icon_state = pick("north", "south", "west", "east")
src << sparDir

// Finished sparring.
proc/sparBreak()
move = 1
canSpar = 1
icon_state = ""
del sparDir

// Takes directional input from a sparring player.
// If the sparring image's icon_state matches the direction pressed,
// then the player successfully scored a hit.
proc/sparHit(d)
var state
switch(d)
if(NORTH) state = "north"
if(SOUTH) state = "south"
if(EAST) state = "east"
if(WEST) state = "west"
else return

if(sparDir.icon_state == state)
sparDir.icon_state = pick("north", "south", "east", "west")
exp += round(maxExp / 100) * rand(1, 3)

// Apparently, if you mess up, you stop sparring.
else sparBreak()

Also, I must say that calling it "canSpar" is confusing to me. I'd be more used to something like "shadowSparring" because it's easier for me to tell what you are doing instead of what you can do.

Another thing: it would be much easier code-wise if your 'sparDir.dmi' was just one icon_state with 4 directions. For example:
proc/sparHit(d)
if(d == sparDir.dir)
sparDir.dir = pick(NORTH, SOUTH, EAST, WEST)
exp += round(maxExp / 100) * rand(1, 3)


Oh, and the for() loop had nothing to do with it.
Oh ho hoo you went so ham with this well done my goodman and thank you. I was wondering what happened to the client/North and what not? is that not an efficient way of implementing this method? I have another problem though, when the player holds the key for a period of time like 2-5 seconds or so it breaks the training. How do I make where the arrows are picked after they release the arrow key? One more thing I already had 4 icon states in my 'sparDir.dmi' file do I simply change their states to "NORTH", "SOUTH" and etc?

Edit: I'm sure my problem has to do with my client/Move I think.

client
Move(Loc, Dir) //Moving..
if(!mob.canSpar)
mob.sparHit(Dir)
if(ismob(src.mob.target)&&get_dist(src.mob.target,src.mob)> 10) src.mob.DeleteTarget()// you can change the 5 to whatever you wish

if(mob.run <= 0 && mob.move >= 1) //If a person is'nt running and can move
mob.run = 1 //Stop running..
..()
sleep(mob.rundelay) //Delay it
mob.run = 0 //Run, again
else
return //If you can't run or move you won't be able to move at all.


~Regards~
Bump.
Can I bump this once more?
Bump.
You have to change, or add the macros for the arrow keys to be when the keys are released.
In response to Super Saiyan X
Where In my interface? but that would make movement really annoying.
Bump.
In response to Luchasi
Add it to your macro list. If you don't want it to affect movement, set their commands to verbs instead of the .north/.south/ect and avoid using client/Move() for it.
mob/verb/sparInput(Dir as num|null)
set hidden = 1
if(!mob.canSpar && Dir)
mob.sparHit(Dir)


Then the macros would be:
#KEY            Macro
NORTH+UP sparInput 1
SOUTH+UP sparInput 2
EAST+UP sparInput 4
WEST+UP sparInput 8