From: "Cox SMTP central" <bphutchins@COX.NET> > I need some help getting started with a highscore listing for my mud > (bpl18 with olc/dg_scripts). I do not want this to be held in a file, > as it will be reset at each reboot. I want the player to type > ..highscore.. and it will check the players stats vs what has already > been posted, or if this is first person to check, then it will check > against a default value. For starters, I am just trying to compare max > hitpoints. I believe I will need to have a new structure to hold the > current highscores, but I am not understanding exactly how this works. > I have tried to find something similar in the code to use as > reference, but I can't seem to find anything. Any help is greatly > appreciated... > Mailer code follows. ACMD(do_highscore) { struct highscorelist_t { char str_name[MAX_NAME_LENGTH]; sbyte str; char int_name[MAX_NAME_LENGTH]; sbyte intel; } highscorelist; if (highscorelist.str == 0) { /* this user gets to fill in the first stats */ highscorelist.str = GET_STR(ch); strncpy(highscorelist.str_name, GET_NAME(ch), MAX_NAME_LENGTH-1) highscorelist.str_name[MAX_NAME_LENGTH-1] = '\0'; highscorelist.intel = GET_INT(ch); strncpy(highscorelist.int_name, GET_NAME(ch), MAX_NAME_LENGTH-1) highscorelist.int_name[MAX_NAME_LENGTH-1] = '\0'; } if (GET_STR(ch) > highscorelist.str) { highscorelist.str = GET_STR(ch); strncpy(highscorelist.str_name, GET_NAME(ch), MAX_NAME_LENGTH-1) highscorelist.str_name[MAX_NAME_LENGTH-1] = '\0'; } if (GET_STR(ch) > highscorelist.intel) { highscorelist.intel = GET_INT(ch); strncpy(highscorelist.int_name, GET_NAME(ch), MAX_NAME_LENGTH-1) highscorelist.int_name[MAX_NAME_LENGTH-1] = '\0'; } send_to_char("Current highscores:\r\n" "-----------------------------------------------\r\n" "Strength : %2d %-30s\r\n" "Intelligence: %2d %-30s\r\n" "-----------------------------------------------\r\n", highscorelist.str, highscorelist.str_name, highscorelist.intel, highscorelist.int_name); } This implementation has the obvious advantage that it can quite easily save the struct to disk as binary, if you wish[1]. Welcor [1] I actually misread your question and first made this as a saving version - figures, right ?. -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT