Quote:
Originally Posted by Dragonsys
strange, then the code should work. it should have worked by using != 0
|
This is the last block of code you posted:
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'] .""
);
}
The only issue I can see is with the quotes at the end of the query...I would write:
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']
);
}
What this should do is if a user is being issue a warning, nothing happens. If they are being issued an infraction, then if prior to the current infraction they have current active points, they will have 500 rep points deducted per current active infraction points, otherwise their rep will simply be reduced by 150.
--------------- Added [DATE]1450895509[/DATE] at [TIME]1450895509[/TIME] ---------------
Quote:
Originally Posted by Dragonsys
...Ok, let's try removing some of the unneeded code and just getting the basics.
PHP Code:
global $vbulletin, $db, $userinfo;
if ($userinfo['ipoints'] > 0)
{
$newrep = ($userinfo['reputation'] - $userinfo['ipoints']*500);
}
else
{
$newrep = ($userinfo['reputation'] - 150);
}
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET reputation = " . $newrep . "
WHERE userid = " . $userinfo['userid']
);
Does this work? It should subtract points for Warning & Infraction
|
That will only take into account a user's prior active infraction points, so there will be no difference in what's done between a warning and an infraction being issued.