home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / WWIVMODS / MODSUNKN.ZIP / TOPTEN1.MOD < prev    next >
Text File  |  1992-01-07  |  6KB  |  221 lines

  1.  
  2.                             TOP TEN USER MOD
  3.                              by GNR 1@2395
  4.  
  5. This will print out a Gfile with the top ten users in different
  6. categories:
  7. Most Upload k, Most Download k, Logons, Posts, Best Ratio.  When
  8. a user logs on and he looks at the file, his name will be
  9. highlighted if his name is in on of the top ten lists.  The sysop
  10. is NOT included in these lists.
  11.  
  12. In this function I have the directory where my file is stored,
  13. change it to the directory you want it stored, but leave the name
  14. of the file (topusers.msg) and the double \ are not mistakes.
  15.  
  16. Put this after any function in sysopf1.c
  17.  
  18. void check_top()
  19. {
  20.   FILE *tpusers;
  21.   int count,count2,count3,count4,number,true;
  22.   char topnames[5][10][30],title[55];
  23.   long topk[5][10],cur;
  24.   userrec u;
  25.  
  26.   for(count=0;count<=4;count++)
  27.   {
  28.      for(count2=0;count2<=9;count2++)
  29.      {
  30.         strcpy(topnames[count][count2],">NOBODY<");
  31.         topk[count][count2]=0;
  32.      }
  33.   }
  34.  
  35.   number=(int)(filelength(userfile)/sizeof(userrec))-1;
  36.  
  37.   for(count=2;count<=number;count++)
  38.   {
  39.       read_user(count,&u);
  40.       if(!((u.inact) & inact_deleted))
  41.       {
  42.         for(count2=0;count2<=4;count2++)
  43.         {
  44.            switch(count2)
  45.            {
  46.                case 0:
  47.                cur=u.uk;
  48.                break;
  49.  
  50.                case 1:
  51.                cur=u.dk;
  52.                break;
  53.  
  54.                case 2:
  55.                cur=u.logons;
  56.                break;
  57.  
  58.                case 3:
  59.                cur=u.msgpost;
  60.                break;
  61.  
  62.                case 4:
  63.                if(u.dk!=0)
  64.                cur=((float) u.uk)/((float) u.dk);
  65.                if(cur>=100) cur=99.998;
  66.                break;
  67.  
  68.            }
  69.            true=0;
  70.            for(count3=9;((count3>=0) && (true==0));count3--)
  71.            {
  72.                 if(cur>topk[count2][count3])
  73.                 {
  74.                    for(count4=0;(count4<count3);count4++)
  75.                    {
  76.                    topk[count2][count4]=topk[count2][count4+1];
  77.                   
  78. strcpy(topnames[count2][count4],topnames[count2][count4+1]);
  79.                    }
  80.                  topk[count2][count3]=cur;
  81.                  if(strcmp(thisuser.name,u.name)==0)
  82.                  {
  83.                    
  84. strcpy(topnames[count2][count3],"\x1b[1;32m");
  85.                     strcat(topnames[count2][count3],u.name);
  86.                     strcat(topnames[count2][count3],"\x1b[0m");
  87.                  }
  88.                  else
  89.                  strcpy(topnames[count2][count3],u.name);
  90.                  true=1;
  91.                 }
  92.            }
  93.          }
  94.          close_user();
  95.         }
  96.       }
  97.       tpusers=fopen("GFILES\\TOPTEN\\TOPUSERS.MSG","w"); /* <----
  98. */
  99.       fprintf(tpusers,"GNR's Top Ten User List.\n");/* Put your
  100. own name! */
  101.       fprintf(tpusers,"\n");
  102.  
  103.       for(count=0;count<=4;count++)
  104.       {
  105.         switch(count) {
  106.  
  107.         case 0:
  108.         strcpy(title,"MOST UPLOAD k\n\n");
  109.         break;
  110.  
  111.         case 1:
  112.         strcpy(title,"MOST DOWNLOAD k\n\n");
  113.         break;
  114.  
  115.         case 2:
  116.         strcpy(title,"MOST LOGONS\n\n");
  117.         break;
  118.  
  119.         case 3:
  120.         strcpy(title,"MOST POSTS\n\n");
  121.         break;
  122.  
  123.         case 4:
  124.         strcpy(title,"BEST RATIO\n\n");
  125.         break;
  126.  
  127.         }
  128.  
  129.         fprintf(tpusers,title);
  130.         for(count2=9;count2>=0;count2--)
  131.         {
  132.           fprintf(tpusers,"%s",topnames[count][count2]);
  133.          
  134. for(count3=0;count3<(50-strlen(topnames[count][count2]));count3++
  135. )
  136.           {
  137.             fprintf(tpusers,".");
  138.           }
  139.           if(strchr(topnames[count][count2],'[')!=NULL)
  140.           {
  141.             for(count4=0;count4<11;count4++)
  142.              fprintf(tpusers,".");
  143.           }
  144.           fprintf(tpusers,"%d",topk[count][count2]);
  145.           fprintf(tpusers,"\n");
  146.           }
  147.         fprintf(tpusers,"\n");
  148.       }
  149.       fclose(tpusers);
  150.  
  151. -----------------------------------------------------------------
  152. -----------
  153.  
  154. Put in FCNS.H
  155.  
  156. void check_top();
  157.  
  158. -----------------------------------------------------------------
  159. -----------
  160.  
  161. Find void logon() in BBSUTL.C and add the text marked with a +.
  162.  
  163. *****************************************************************
  164. ************
  165. *      prompt("Birthdate: ",s,".  Correct? ","");                 
  166.          *
  167. *        if (!yn())                                               
  168.          *
  169. *          thisuser.year=0;                                       
  170.          *
  171. *      } while ((!hangup) && (thisuser.year==0));                 
  172.          *
  173. *      topscreen();                                               
  174.          *
  175. *      nl();                                                      
  176.          *
  177. *    }                                                            
  178.          *
  179. *                                                                 
  180.          *
  181. * +  prt(2,"Updating GNR's Top Ten User List!");    /* Put your
  182. own name! */*
  183. * +  check_top();                                                 
  184.          *
  185. * +  nl();                                                        
  186.          *
  187. *                                                                 
  188.          *
  189. *    rsm(usernum,&thisuser);                                      
  190.          *
  191. *****************************************************************
  192. ************
  193. Reposition the above lines so that they are before the external
  194. call for the
  195. logon event.  As Written the Logon event for some reason cause
  196. this mod not
  197. to print the stats just the file with a bunch of >NOBODY<'s and
  198. 0's....
  199.   You will notice that if you have the mod in as written and you
  200. go into init
  201. and take out the logon event it will work.... I just moved the
  202. call so it was
  203. done before the logon event....
  204. *****************************************************************
  205. ************
  206.         if (live_user)
  207.           topscreen();
  208.     +   prt(2,Updating XXXXX's Top Ten User List!");
  209.     +   check_top();
  210.     +   nl();nl();
  211.  
  212.         if ((syscfg.logon_c[0]) && live_user) {
  213.         nl();
  214.         Strcpy(s1,syscfg.logon_c);
  215. *****************************************************************
  216. **************
  217. That should be it, any problems email 1 @ 2395 or call The
  218. Nuclear Reactor
  219. BBS (213) 271-4232.
  220.  
  221. Modified By ─∞∞─« Dartvader »─∞∞─  12-17-89