loginadd.txt
loginhistory/loginadd.txt · 5.5 KB
From the archive loginhistory.zip
Download the archive « Back to the archive contents
-----------
save.c
-----------
Find do_last and replace it with this
void do_last(CHAR_DATA * ch, char *argument)
{
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
char name[MAX_INPUT_LENGTH];
struct stat fst;
argument = one_argument(argument, arg);
if (arg[0] == '\0')
{
send_to_char("Usage: last <playername>\n\r", ch);
send_to_char("Usage: last <# of entries OR \'-1\' for all entries OR \'today\' for all of today's entries>\n\r", ch);
send_to_char("Usage: last <playername> <count>\n\r", ch);
return;
}
if (get_trust(ch) < LEVEL_STAFF)
{
set_char_color(AT_IMMORT, ch);
send_to_char("Their godly glow prevents you from getting a good look.\n\r", ch);
return;
}
if (isdigit(arg[0]) || atoi(arg) == -1 || !str_cmp(arg, "today")) //View list instead of players
{
send_to_char("&w&RName Time Host/Ip\n\r&c&w---------------------------------------------------------------------------\n\r", ch);
if (!str_cmp(arg, "today"))
read_last_file(ch, -2, NULL);
else
read_last_file(ch, atoi(arg), NULL);
return;
}
strcpy(name, capitalize(arg));
if (argument[0] != '\0')
{
send_to_char("&w&RName Time Host/Ip\n\r&c&w---------------------------------------------------------------------------\n\r", ch);
read_last_file(ch, atoi(argument), name);
return;
}
sprintf(buf, "%s%c/%s", PLAYER_DIR, tolower(arg[0]), name);
if (stat(buf, &fst) != -1)
sprintf(buf, "%s was last on: %s\r", name, ctime(&fst.st_mtime));
else
sprintf(buf, "%s was not found.\n\r", name);
send_to_char(buf, ch);
}
-----------
tables.c
-----------
Find read_last_file and replace it with this
void read_last_file(CHAR_DATA *ch, int count, char *name)
{
FILE *fpout;
char filename[MAX_INPUT_LENGTH];
char charname[100];
int cnt = 0;
int letter = 0;
char *ln;
char *c;
char d, e;
struct tm *tme;
time_t now;
char day[MAX_INPUT_LENGTH];
char sday[5];
int fnd = 0;
sprintf(filename, "%s", LAST_LIST);
if ((fpout = fopen(filename, "r")) == NULL)
{
send_to_char("There is no last file to look at.\n\r", ch);
return;
}
for (;;)
{
if (feof(fpout))
{
fclose(fpout);
ch_printf(ch, "---------------------------------------------------------------------------\n\r%d Entries Listed.\n\r", cnt);
return;
}
else
{
if (count == -2 || ++cnt <= count || count == -1)
{
ln = fread_line(fpout);
strcpy(charname, "");
if (name) //looking for a certain name
{
c = ln;
for (;;)
{
if (isalpha(*c) && !isspace(*c))
{
charname[letter] = *c;
letter++;
c++;
}
else
{
charname[letter] = '\0';
if (!str_cmp(charname, name))
{
ch_printf(ch, "%s", ln);
letter = 0;
strcpy(charname, "");
break;
}
else
{
if (!feof(fpout))
{
fread_line(fpout);
c = ln;
letter = 0;
strcpy(charname, "");
continue;
}
else
{
cnt--;
break;
}
}
}
}
}
else if (count == -2) //only today's entries
{
c = ln;
now = time(0);
tme = localtime(&now);
strftime(day, 10, "%d", tme);
for (;;)
{
if (!isdigit(*c))
{
c++;
}
else
{
d = *c;
c++;
e = *c;
sprintf(sday, "%c%c", d, e);
if (!str_cmp(sday, day))
{
fnd = 1;
cnt++;
ch_printf(ch, "%s", ln);
break;
}
else
{
if (fnd == 1)
{
fclose(fpout);
ch_printf(ch, "---------------------------------------------------------------------------\n\r%d Entries Listed.\n\r", cnt);
return;
}
else
break;
}
}
}
}
else
{
ch_printf(ch, "%s", ln);
}
}
else
{
fclose(fpout);
ch_printf(ch, "--------------------------------------------------------------------------\n\r%d Entries Listed.\n\r", count);
return;
}
}
}
}