View Single Post
  #915  
Old 02-20-2003, 12:45 PM
Bitsys's Avatar
Bitsys Bitsys is offline
 
Join Date: Oct 2002
Posts: 444
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Update stats automatically Add-On

In newreply.php and newthread.php, between
PHP Code:
// End Itemshop code by Mewtwo and Battle Code by Bitsys 
and
PHP Code:
// send email to moderators 
in both files, place the following code:

PHP Code:
//begin auto-update stats add-on for the RPG Integration Hack by Bitsys
$userinbattle $DB_site->query_first("SELECT inbattle FROM user WHERE userid='$bbuserinfo[userid]'");
    if (
$userinbattle[inbattle] == 0) {
      
//$debugmessage .= "You must be out of a battle in order to update your stats.  Please exit or complete battle $userinbattle[inbattle] and try again.";
      //exit;
      
$userstats $DB_site->query_first("SELECT hp, maxhp, element, ma, maxma, pp, maxpp, ap, posts, xp FROM user WHERE userid='$bbuserinfo[userid]'");
      
$hp $userstats[hp];
      
$maxhp $userstats[maxhp];
      
$ele $userstats[element];
      
$ma $userstats[ma];
      
$maxma $userstats[maxma];
      
$pp $userstats[pp];
      
$maxpp $userstats[maxpp];
      
$ap $userstats[ap];
      
$posts $userstats[posts];
      
$debugmessage .=  "HP: $hp | MaxHP: $maxhp | Element: $ele | MA: $ma | MaxMA: $maxma | PP: $pp | MaxPP: $maxpp | AP: $ap | Posts: $posts<br>\n";
      
$jointime = (time() - $bbuserinfo[joindate]) / 86400;
      if (
$jointime 1) {
        
$postsperday "$posts";
      } else {
        
$postsperday sprintf("%.2f",($posts $jointime));
      }
      
$debugmessage .=  "Jointime: $jointime<br>\n";
      
$battleopt $DB_site->query_first("SELECT * FROM battle_options");
        
$level getlevel($userstats[xp], $battleopt[exprate], 1);
        
$ep floor (100 * ($level floor ($level)));
        
$showlevel floor ($level 1);
      
$debugmessage .=  "Level: $level | Showlevel: $showlevel<br>\n";
      
$hpmulti =round ($postsperday 41);
      if (
$hpmulti 7.5)
        
$hpmulti 3;
      if (
$hpmulti 2.5)
        
$hpmulti 1.5;
      if (
$hpmulti 1)
        
$hpmulti 1;
      
$debugmessage .=  "HPMulti: $hpmulti<br>\n";
      
$element $DB_site->query_first("SELECT * FROM rpg_element WHERE elementid='$ele'");
      
$hpmodifier $element[hp];
      
$mamodifier $element[ma];
      
$ppmodifier $element[pp];
      
$apmodifier $element[ap];
      
$debugmessage .=  "HPmodifier: $hpmodifier | MAmodifier:  $mamodifier | PPmodifier: $ppmodifier | APmodifier: $apmodifier<br>\n";
      
$elename $element[name];
      
$maxhpupdate = ( $level $battleopt[hpmodifier] * $hpmulti) + $hpmodifier;
      
$maxhpupdatefloor ($maxhpupdate);
      
$maxmaupdate $mamodifier + ($jointime $level $battleopt[mamodifier]) / 5;
      
$maxmaupdate floor ($maxmaupdate);
      
$maxppupdate $ppmodifier + ($jointime $level $battleopt[ppmodifier]) / 3;
      
$maxppupdate floor ($maxppupdate);
      If (
$maxhpupdate 0)
        
$maxhpupdate 0;
      If (
$maxmaupdate 0)
        
$maxmaupdate 0;
      If (
$maxppupdate 0)
        
$maxppupdate 0;
      If (
$apmodifier 0)
        
$apmodifier 0;
      If (
$maxhp != && $maxhpupdate != 0)
        
$newhp $hp * ($maxhpupdate $maxhp);
      else
        
$newhp $maxhpupdate;
      If (
$maxma != && $maxmaupdate != 0)
        
$newma $ma * ($maxmaupdate $maxma);
      else
        
$newma $maxmaupdate;
      If (
$maxpp != && $maxppupdate != 0)
        
$newpp $pp * ($maxppupdate $maxpp);
      else
        
$newpp $maxppupdate;
      
$debugmessage .=  "MaxHPupdate: $maxhpupdate | MaxMAupdate: $maxmaupdate | MaxPPupdate: $maxppupdate<br>\n";
      
$debugmessage .=  "NewHP: $newhp | NewMA: $newma | NewPP: $newpp<br>\n";
      
$DB_site->query("UPDATE user SET maxhp='$maxhpupdate', hp='$newhp', maxma='$maxmaupdate', ma='$newma', maxpp='$maxppupdate', pp='$newpp' WHERE userid='$bbuserinfo[userid]'");

      
$debugmessage .=  "Stats Updated.";
    } else {
      
$debugmessage .=  "You are in Battle.";
    }
    
//end auto-update stats add-on for the RPG Integration Hack by Bitsys 
Note that if you have modified the update stats code before, then you will have to modify it again in both of these files. Also, this code will NOT update the user's AP (anger percentage). It will remain the same.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01253 seconds
  • Memory Usage 1,861KB
  • 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
  • (3)bbcode_php
  • (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