psx.txt
snippets · 1.2 KB · 2010-03-30
psx: immortal ps command for act_wiz.c.
Download « Back to the snippets list
/*
* Ok this should slap right into your act_wiz.c (have mine in act_wiz2.c)
* Just put the code into the file, add the do_ps to interp.c and interp.h
* and voila, you can no use ps inside your mud, make sure you put the
* TEXT (TXT) file somewhere appropriate for your mud! update the code accordingly
* Also note, you may need to change its trigger name in interp.c to something other then
* ps (mine is psu) due to name conflicts.
*
* Syn
*/
void do_ps ( CHAR_DATA *ch, char *argument ) //<-- fuckin thing wont work!
{
if ( argument[0] == '\0' )
{
send_to_char ( "ps what?\n\r", ch );
return;
}
FILE *fp=NULL;
char proc[MSL];
char line[80];
char buf[MAX_STRING_LENGTH];
BUFFER *output;
output = new_buf(); // <-- This doesnt need to be large at all - Syn
xprintf( proc, "ps %s > ../txt/ps.txt ", argument );
system( proc );
//* open file *
fp = fopen( "../txt/ps.txt","r" );
while( fgets( line, 80, fp ) != NULL )
{
sprintf(buf, "%s", line);
add_buf(output,buf);
}
fclose( fp );
send_to_char( buf_string(output), ch );
free_buf(output);
return;
}