View Single Post
  #87  
Old 11-01-2005, 04:55 AM
TJFweb TJFweb is offline
 
Join Date: Dec 2001
Posts: 191
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by WetWired
This is the code that the plugin uses to separate the post count into digits:
Code:
    //Separate out postcount
    $WWU002postcount=$WWU002user['posts'];
    if($WWU002postcount<1){
      $WWU002_postsd=array(1=>'s',2=>'s',3=>'s',4=>'s',5=>'s',6=>'s',7=>'s',8=>'s',9=>'0');
    }else{//($WWU002postcount<1)
      for($i=9;$i>0;$i--){
        $WWU002digit=$WWU002postcount%10;
        $WWU002postcount=floor($WWU002postcount/10);
        if(($WWU002digit==0)&&($WWU002postcount==0)){
          $WWU002_postsd[$i]='s';
        }else{//(($WWU002digit==0)&&($WWU002postcount==0))
          $WWU002_postsd[$i]=$WWU002digit;
        }//endif(($WWU002digit==0)&&($WWU002postcount==0))
      }//endfor($i=9;$i>0;$i++)
    }//endif($WWU002postcount<1)
First, it stores the value to process in a working variable so the original value is not corrupted, then it has a special case to display 0 for any value under 1 (because postcount shouldn't go negative, and the code doesn't have provisions for displaying negative numbers). After that, it works from least significant digit to most significant, by dividing the value by 10 and using the remainder as the digit for that place. If we've passed all the siginificant digits (because our working value is zero), then zero digits are converted to space padding.

You should be able to use the same code to separate out the digits for any value, just change the second line to assign $WWU002postcount to the new value to break down, and replace occurrances of $WWU002_postsd with a different variable to hold the digits.



From the opening post:
Visiting each day and posting the configured amount of times per day for the configured number of weeks will yeild 100% activity. Posts are checked individually for each day, so days cannot be skipped then spammed up afterwards. The weight of visiting for the day relative to posting is configurable. Weeks are weighted so the most recent has a bigger impact on the activity percent than the most distant.

For an in-depth explaination (this file is included with the mod):
https://vborg.vbsupport.ru/attachmen...chmentid=33478
Awesome... Thanks a lot for the code ;-)

Now all I need to do is try to get it to work with another variable I have. Unfortunately I don't know why a hook can't use a specific variable when it can be called when placed in the postbit. This isn't to do with the Activity Mod (at most it's an adaptation of a feature of the Activity Mod) so I made a post here instead: https://vborg.vbsupport.ru/showthread.php?t=99795
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02560 seconds
  • Memory Usage 1,767KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete