31 Jul, 2010, om wrote in the 1st comment:
Votes: 0
Let me first say this: I am not a coder. I'm a copy and paster. I can usually fix small problems, and use common sense to figure out why something failed to work, or failed to compile, but I cannot write my own code. I intend to rectify this soon as I will be going to school for Computer Science in the Fall, but for right now I need a little help.

if (i == -1)
chprintf(ch, "Unable to find a path to %s.\n\r", PERS(victim, ch));
else
chprintf(ch, "%s is %s from here.\n\r", PERS(victim, ch), dir_name[i]);
check_improve(ch, gsn_track, TRUE, 1);
}


My mud does not have chprintf, so would this do as a replacement?

if (i == -1)
act( "You couldn't find a path to $N from here.",
ch, NULL, victim, TO_CHAR );
else
sprintf( buf, "$N is %s from here.", dir_name[i] );
act( buf, ch, NULL, victim, TO_CHAR );
check_improve(ch, gsn_track, TRUE, 1);
}


It compiles, and works.. but my concern is will it break anything?

[edit]
btw, that is my first time actually -writing- code. most of it was guessing and common sense.
31 Jul, 2010, bbailey wrote in the 2nd comment:
Votes: 0
om said:
if (i == -1)
act( "You couldn't find a path to $N from here.",
ch, NULL, victim, TO_CHAR );
else
sprintf( buf, "$N is %s from here.", dir_name[i] );
act( buf, ch, NULL, victim, TO_CHAR );
check_improve(ch, gsn_track, TRUE, 1);
}


One issue I see is that the second call to act() will always be executed. If you want multiple statements to be attached to a control statement like if/else/for/while/etc, you need to enclose them in a single block.


if (i == -1)
act( "You couldn't find a path to $N from here.", ch, NULL, victim, TO_CHAR );
else {
sprintf( buf, "$N is %s from here.", dir_name[i] );
act( buf, ch, NULL, victim, TO_CHAR );
}
check_improve(ch, gsn_track, TRUE, 1);
}
31 Jul, 2010, om wrote in the 3rd comment:
Votes: 0
Thanks. I'll use that instead!
0.0/3