vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Major Additions - vBCredits - Ultimate Points System (https://vborg.vbsupport.ru/showthread.php?t=172399)

imported_silkroad 06-23-2009 12:55 PM

Hi Dark!

Maybe this is better, just add this to credits_daily.php ?

$twoyearsago = time() - 63072000;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits = 0 WHERE lastactivity < $twoyearsago");

and also, this:

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits_canearn = 0 WHERE lastactivity < $twoyearsago");

So, the first query zeros out all the old credits of users inactive for more than two years, the second query turns off all credit earnings for the same group.

However, I need to turn credits_canearn back on when a user become active again, something like:

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits_canearn = 1 WHERE lastactivity > $twoyearsago");

Thoughts?

imported_silkroad 06-24-2009 11:33 AM

Update; I ended up with a simple vB cron file that does this once a day:

Quote:

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits = 0 WHERE lastactivity < (UNIX_TIMESTAMP() - (60 * 60 * 24 * 365 * 2))");

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits_canearn = 0 WHERE lastactivity < (UNIX_TIMESTAMP() - (60 * 60 * 24 * 365 * 2))");

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits_canearn = 1 WHERE lastactivity > (UNIX_TIMESTAMP() - (60 * 60 * 24 * 365 *2))

Darkwaltz4 06-24-2009 03:11 PM

to simplify, you could add just this one query to the bottom of credits_daily

PHP Code:

$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "user SET credits_canearn = (lastactivity > " . (TIMENOW 63072000) . "), credits = credits * credits_canearn"); 


imported_silkroad 06-24-2009 04:03 PM

Great idea, thanks!

Quote:

$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET credits_canearn = (lastactivity > " . (TIMENOW - 63072000) . "), credits = credits * credits_canearn")
;

But I don't understand it, ROTFL :D

Darkwaltz4 06-24-2009 04:12 PM

:p well its a combination of a couple sql tricks. the first sets the canearn flag to 1 or 0 (true or false, but it gets typecasted to int because thats the column type) based on the activity date.

the second multiplies your credits against that flag... if you can earn credits, then its 1 * your credits = your credits stay the same. if you cant earn credits, then its 0 = your credits are now 0.

imported_silkroad 06-24-2009 04:34 PM

Oh, so the () around the lastactivity condition makes it boolean?

Wow! I would call you Master, and me Grasshopper, but I don't want to end up in the closet of a hotel room in Bangkok with ropes "everywhere" :D

Darkwaltz4 06-24-2009 04:53 PM

in response to the... first part

the > makes it boolean, but the column (credits_canearn) is int, so boolean true becomes int 1 and boolean false becomes int 0. the parens are just for clarification

imported_silkroad 06-25-2009 05:22 PM

Quote:

Originally Posted by Darkwaltz4 (Post 1836512)
in response to the... first part

the > makes it boolean, but the column (credits_canearn) is int, so boolean true becomes int 1 and boolean false becomes int 0. the parens are just for clarification

Clever. Thanks!

animcentral 06-25-2009 05:46 PM

is this support point per forum?
i need a points system that support Point Per forum to set point per forums

Darkwaltz4 06-26-2009 01:56 AM

yep, it has forum overrides


All times are GMT. The time now is 05:47 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05576 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete