/* * allows a user to rename their room */ void personal_room_rename(UR_OBJECT user, char *inpstr) { if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } if (word_count < 2) { write_user(user, "Usage: myname <name you want room to have>\n"); return; } if (strcmp(user->room->owner, user->name)) { write_user(user, "You have to be in your personal room to rename it.\n"); return; } if (strlen(inpstr) > PERSONAL_ROOMNAME_LEN) { write_user(user, "You cannot have a room name that long.\n"); return; } if (strlen(inpstr) - teslen(inpstr, 0) < 1) { write_user(user, "You must enter a room name.\n"); return; } strcpy(user->room->show_name, inpstr); vwrite_user(user, "You have now renamed your room to: %s\n", user->room->show_name); if (!personal_room_store(user->name, 1, user->room)) { write_syslog(SYSLOG | ERRLOG, 1, "ERROR: Unable to save personal room status in personal_room_rename()\n"); } }
/* * Show the wizzes that are currently logged on, and get a list of names from the lists saved */ void wiz_list(UR_OBJECT user) { static const char *const clrs[] ={"~FC", "~FM", "~FG", "~FB", "~OL", "~FR", "~FY"}; char text2[ARR_SIZE]; char temp[ARR_SIZE]; UR_OBJECT u; UD_OBJECT entry; int invis, count, inlist; int linecnt, rnamecnt; enum lvl_value lvl; /* show this for everyone */ write_user(user, "+----- ~FGWiz List~RS -------------------------------------------------------------+\n\n"); for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { *text2 = '\0'; count = 0; inlist = 0; sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); for (entry = first_user_entry; entry; entry = entry->next) { if (entry->level < WIZ) { continue; } if (is_retired(entry->name)) { continue; } if (entry->level == lvl) { if (count > 3) { strcat(text2, "\n "); count = 0; } sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, entry->name); strcat(text2, temp); ++count; inlist = 1; } } if (!count && !inlist) { sprintf(text2, "~FR[none listed]\n~RS"); } strcat(text, text2); write_user(user, text); if (count) { write_user(user, "\n"); } } /* show this to just the wizzes */ if (user->level >= WIZ) { write_user(user, "\n+----- ~FGRetired Wiz List~RS -----------------------------------------------------+\n\n"); for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { *text2 = '\0'; count = 0; inlist = 0; sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); for (entry = first_user_entry; entry; entry = entry->next) { if (entry->level < WIZ) { continue; } if (!is_retired(entry->name)) { continue; } if (entry->level == lvl) { if (count > 3) { strcat(text2, "\n "); count = 0; } sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, entry->name); strcat(text2, temp); ++count; inlist = 1; } } if (!count && !inlist) { sprintf(text2, "~FR[none listed]\n~RS"); } strcat(text, text2); write_user(user, text); if (count) { write_user(user, "\n"); } } } /* show this to everyone */ write_user(user, "\n+----- ~FGThose currently on~RS ---------------------------------------------------+\n\n"); invis = 0; count = 0; for (u = user_first; u; u = u->next) if (u->room) { if (u->level >= WIZ) { if (!u->vis && (user->level < u->level && !(user->level >= ARCH))) { ++invis; continue; } else { if (u->vis) { sprintf(text2, " %s~RS %s~RS", u->recap, u->desc); } else { sprintf(text2, "* %s~RS %s~RS", u->recap, u->desc); } linecnt = 43 + teslen(text2, 43); rnamecnt = 15 + teslen(u->room->show_name, 15); vwrite_user(user, "%-*.*s~RS : %-*.*s~RS : (%1.1s) %s\n", linecnt, linecnt, text2, rnamecnt, rnamecnt, u->room->show_name, user_level[u->level].alias, user_level[u->level].name); } } ++count; } if (invis) { vwrite_user(user, "Number of the wiz invisible to you : %d\n", invis); } if (!count) { write_user(user, "Sorry, no wizzes are on at the moment...\n"); } write_user(user, "\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); }
/* * give, take and view money of users currently logged on */ void global_money(UR_OBJECT user) { UR_OBJECT u; const char *name; int cash; if (word_count < 2) { write_user(user, "Usage: money -l/-g/-t [<user> <amount>]\n"); return; } /* list all users online and the amount of cash they have */ if (!strcasecmp(word[1], "-l")) { char text2[ARR_SIZE]; int x, cnt, user_cnt; write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, "| ~FC~OLUser money listings~RS |\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); x = user_cnt = 0; *text2 = '\0'; for (u = user_first; u; u = u->next) { ++user_cnt; cnt = 13 + teslen(u->recap, 13); if (!x) { /* build up first half of the string */ sprintf(text, "| %-*.*s $%6d ", cnt, cnt, u->recap, u->money); ++x; } else if (x == 1) { /* build up full line and print to user */ sprintf(text2, " %-*.*s $%6d ", cnt, cnt, u->recap, u->money); strcat(text, text2); write_user(user, text); *text = '\0'; *text2 = '\0'; ++x; } else { sprintf(text2, " %-*.*s $%6d |\n", cnt, cnt, u->recap, u->money); strcat(text, text2); write_user(user, text); *text = '\0'; *text2 = '\0'; x = 0; } } /* If you have only printed first half of the string */ if (x == 1) { strcat(text, " |\n"); write_user(user, text); } if (x == 2) { strcat(text, " |\n"); write_user(user, text); } write_user(user, "+----------------------------------------------------------------------------+\n"); sprintf(text, "Total of ~OL%d~RS user%s", user_cnt, PLTEXT_S(user_cnt)); vwrite_user(user, "| %-80s |\n", text); write_user(user, "+----------------------------------------------------------------------------+\n\n"); return; } /* give money to users */ if (!strcasecmp(word[1], "-g")) { if (word_count < 4) { write_user(user, "Usage: money -l/-g/-t [<user> <amount>]\n"); return; } u = get_user_name(user, word[2]); if (!u) { write_user(user, notloggedon); return; } if (u == user && user->level < GOD) { write_user(user, "You cannot give money to yourself.\n"); return; } cash = atoi(word[3]); if (cash < 1) { write_user(user, "You must supply an amount to give.\n"); return; } u->money += cash; name = user->vis || u->level < WIZ ? user->recap : invisname; vwrite_user(user, "You give $%d to %s~RS.\n", cash, u->recap); vwrite_user(u, "%s~RS kindly gives $%d.\n", name, cash); sprintf(text, "%s gives $%d.\n", user->name, cash); add_history(u->name, 1, text); return; } /* take money from users */ if (!strcasecmp(word[1], "-t")) { if (word_count < 4) { write_user(user, "Usage: money -l/-g/-t [<user> <amount>]\n"); return; } u = get_user_name(user, word[2]); if (!u) { write_user(user, notloggedon); return; } if (u == user) { write_user(user, "You cannot take money away from yourself.\n"); return; } cash = atoi(word[3]); if (cash < 1) { write_user(user, "You must supply an amount to take.\n"); return; } if (u->money < cash) { vwrite_user(user, "%s~RS has not got that much money.\n", u->recap); return; } u->money -= cash; name = user->vis || u->level < WIZ ? user->recap : invisname; vwrite_user(user, "You take $%d from %s~RS.\n", cash, u->recap); vwrite_user(u, "%s~RS takes $%d from you.\n", name, cash); sprintf(text, "%s takes $%d.\n", user->name, cash); add_history(u->name, 1, text); return; } write_user(user, "Usage: money -l/-g/-t [<user> <amount>]\n"); }