Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 12-19-2015, 10:59 PM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Do you mean then a deduction based only on the points being issued at the time, and not on the cumulative total of active points? If so, I would have to investigate to see how to retrieve that value.

The code I posted does exactly the opposite of that...it uses $userinfo['ipoints'] which does not include the points currently being given, but rather the number of points accumulated by the user before the current infraction.

edit: Try using the hook location "infraction_update_complete", and at that hook, the points for the current infraction is in $vbulletin->GPC['points']. Then you can base the rep deduction on that and update the user table.
No, the current script works fine. I want it to deduct based on the current active points, so using ipoints is correct.

However, I don't want to issue and deduction when the user is only issued a warning (infraction without points).
Reply With Quote
  #12  
Old 12-20-2015, 01:27 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you use the code I posted in post #8, then the deduction will be based on the accumulated active points prior to the infraction being issued. So, for example, suppose a user has 3 active points, and you then issue a warning...$userinfo['ipoints'] will be equal to 3.

But, if you use the hook location and variable I suggested in post #10, then $vbulletin->GPC['points'] will be equal to 0.
Reply With Quote
  #13  
Old 12-22-2015, 08:40 PM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Mark

PHP Code:
global $vbulletin$db$userinfo;

if (
$vbulletin->GPC['points'] == 0) {
    continue;
}

$points $userinfo['ipoints'];
$rep $userinfo['reputation'];

if (
$points 0)
{
    
$newrep = ($rep $points*500);
}
else
{
    
$newrep = ($rep 150);
}

$vbulletin->db->query_write("
    UPDATE " 
TABLE_PREFIX "user
    SET reputation = " 
$newrep "
    WHERE userid = " 
$userinfo['userid']
); 
This is what my revised code looked like, on the hook that you suggested. I'm getting a server 500 error when I try to issue a warning.

Any ideas?
Reply With Quote
  #14  
Old 12-22-2015, 08:57 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why are you using continue without a loop?

I would remove this, it is rather pointless in that code:
PHP Code:
if ($vbulletin->GPC['points'] == 0) {
    continue;

or comment it out until you are ready to do something with it. This might be the cause of your 500 error
Reply With Quote
  #15  
Old 12-22-2015, 11:23 PM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dragonsys View Post
why are you using continue without a loop?

I would remove this, it is rather pointless in that code:
PHP Code:
if ($vbulletin->GPC['points'] == 0) {
    continue;

or comment it out until you are ready to do something with it. This might be the cause of your 500 error
I am trying to prevent the bottom code from running if the infraction points being handed out = 0.
Reply With Quote
  #16  
Old 12-22-2015, 11:49 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is not how your code is working. You need to put the bottom inside the if statement. I can post the code when I get home if someone doesn't beat to it

--------------- Added [DATE]1450838239[/DATE] at [TIME]1450838239[/TIME] ---------------

try this:

PHP Code:
global $vbulletin$db$userinfo;

if (
$vbulletin->GPC['points'] != 0) {
    
$points $userinfo['ipoints'];
    
$rep $userinfo['reputation'];

    if (
$points 0)
    {
        
$newrep = ($rep $points*500);
    }
    else
    {
        
$newrep = ($rep 150);
    }

    
$vbulletin->db->query_write("
        UPDATE " 
TABLE_PREFIX "user
        SET reputation = " 
$newrep "
        WHERE userid = " 
$userinfo['userid']
    );

Reply With Quote
  #17  
Old 12-23-2015, 12:56 AM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried that - it doesn't work.

I don't get the server 500 error anymore, but it no longer deducts points if the infraction points being handed out is > 0
Reply With Quote
  #18  
Old 12-23-2015, 01:40 AM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry, i think I read what you wanted backwards, try this:
PHP Code:
global $vbulletin$db$userinfo;

if (
$vbulletin->GPC['points'] == 0) {
    
$points $userinfo['ipoints'];
    
$rep $userinfo['reputation'];

    if (
$points 0)
    {
        
$newrep = ($rep $points*500);
    }
    else
    {
        
$newrep = ($rep 150);
    }

    
$vbulletin->db->query_write("
        UPDATE " 
TABLE_PREFIX "user
        SET reputation = " 
$newrep "
        WHERE userid = " 
$userinfo['userid']
    );

Reply With Quote
Благодарность от:
MarkFL
  #19  
Old 12-23-2015, 02:24 AM
Chris.08i Chris.08i is offline
 
Join Date: Oct 2008
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply.

I already have that exact code on my forums - yet it still does not work. It also doesn't make sense to me.

When I read your code, it basically only runs the deduction code when it ISNT an infraction, and IS a warning.

I want the deduction code to only run when there IS points applied to the infraction.

I hope I am making sense.
Reply With Quote
  #20  
Old 12-23-2015, 02:29 AM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, that is what I gave you the first time
PHP Code:
$vbulletin->GPC['points'] != 
but you said it didn't work. So I changed it to this:
PHP Code:
$vbulletin->GPC['points'] == 

So what determines an infraction vs a warning, in the code?

--------------- Added [DATE]1450845203[/DATE] at [TIME]1450845203[/TIME] ---------------

the continue you had in your code is what was causing the 500 error for you, as a continue is used to exit a loop, and you did not have a loop. So I moved the code you wanted to run when points is 0, to inside your if statement. Should it run when points is 0, or when it is not 0?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:01 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.04459 seconds
  • Memory Usage 2,283KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete