PDA

View Full Version : Points Addon for Profile Comments


Reeve of shinra
02-15-2006, 10:00 PM
Points add on for the Profile Commenting System coded by Danny.VBT

This small add on lets you add or deduct points for new profile comments. You can use this with ebux, ucash, or any other system by changing the table and field info in the variable below.

QUICK NOTE: If your actually using decimals, this may round off the users points to the nearest whole #.

This is more or less all I needed but the same code could probably be reused for editing and deleting comments as well. If you want to enchance this in any way, by all means feel free to do so.

Step 1: Create a new phrase
(admincp -> languages and phrases -> phrase manager -> add new phrase)

Phrase Type: front end error messages
Product: vbulletin
Varname: error_not_enough_points
Text: Sorry but you do not have enough points to complete this action.

Step 2: Edit the "[Comments] Add Comment" plugin
(admincp -> Plugin System -> Plugin Manager)

Step 3: Add this code at the very top.

Change the cost to whatever you would like. Negative #'s deduct points. Postive #'s add points.
Change the table and field your points are stored in. If your are using ebux and do not have a table prefix, leave it alone. :)



/* **** Begin Points Hack **** */

// Lets define some variables.
$cost = -10; // use negative numbers to deduct points for adding a comment

// Where are your points stored? This is a default ebux without table prefix.
$pointstable = 'user'; // This is the table where the points are stored
$fieldx = 'ebux'; // This is the field where users points are stored

/* **** End Points Hack **** */



Step 4: Look for this code in the plugin


$addcomment = $db->query_write("INSERT into " . TABLE_PREFIX . "space_comments (comment_title, comment_text, comment_date, commenter_id, userid, commenter_name)
VALUES ('" . $db->escape_string($vbulletin->GPC['title']) . "','" . $db->escape_string($parsed_text) . "','" . TIMENOW . "','" . $vbulletin->userinfo['userid'] . "', '" . $vbulletin->GPC['u'] . "','" . $vbulletin->userinfo['username'] . "')
");


Step 5: Below that, add the following


/***** Begin Points Hack *****/

// OKAY NO MORE EDITING! Lets begin doing points stuff

// Lets see how many points the user has to start with
$userpointsqry = $db->query_first("
SELECT $fieldx FROM $pointstable
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

$userpoints = (int) $userpointsqry + 0;

//Lets do a quick check to see if they have enough points.

if ($cost < 0)
{
if ($userpoints < abs($cost))
{
eval(standard_error(fetch_error('error_not_enough_ points')));
}
}

// A little math to add/subtract the cost from the users existing points.
$amt = $userpoints + $cost;


// Lets update the users points now that they have made a comment
$db->query_write("
UPDATE $pointstable SET
$fieldx = '" . $db->escape_string($amt) . "'
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");
/***** End Points Hack *****/


Step 6: Save it and your done!

mholtum
02-16-2006, 04:28 AM
hmmm I am not seeing Front End Error Messages..

Could be a problem..

amizone143
02-16-2006, 08:34 AM
any screenshot bro

Snake
02-16-2006, 08:37 AM
Thanks man, this is quite nice as I've just installed eStore and removed uShop. lol

Reeve of shinra
02-16-2006, 12:53 PM
amizone143: nothing to take a screen shot of. This just adds/subtracts points, trying together to already existing and great mods.

The Chief
02-16-2006, 01:56 PM
lookin good, I will definaetly try this out later on, when Danny upgrades the comments system ;)

trackpads
03-04-2006, 02:06 PM
Ok, got a problem, instead of adding the points it replaces the points on hand with the number that I said to add by.

Help!

trackpads
03-04-2006, 02:20 PM
Ok, got a problem, instead of adding the points it replaces the points on hand with the number that I said to add by.

Help!

Also, still doing it, it takes the number I put in the hack (+10) and replaces the onhand points with that number +2.

Any ideas?

vbreal
09-23-2006, 08:31 PM
i guess this didnt work to well

vbreal
10-02-2006, 08:54 PM
did this ever work?

Reeve of shinra
10-03-2006, 02:24 AM
It did for me but to be honest, my members were not really using the profile comments hack as much as I would have liked so I stopped using it and this hack unfortunately.

Anyone is more than welcome to pick up on it if they are so inclined. I just dont have the free time to check into it.

Endurer
10-17-2006, 07:50 PM
Where can I get the "Profile Commenting System coded by Danny.VBT" ?

^SuiCyde^
11-04-2006, 06:02 AM
ditto^ that's my question.....

bo0oost
11-11-2006, 09:53 PM
I'd like to know too.

Detomah
12-05-2006, 11:04 PM
I guess nobody every fixed the problem that has happened to various people trying this hack. Shame really, would be a good incentive to be able to give my users a bonus for commenting on others profiles. not much good when it cuts the figure down to the amount it's supposed to add, instead of actually adding it though.

I may have to have a wee look and see if I can figure out the problem myself then, cause I want to use this hack.

It can't be much really, the only bit that changes the dbase is:

$amt = $userpoints + $cost;

to calculate the amount and

UPDATE $pointstable SET
$fieldx = '" . $db->escape_string($amt) . "'
WHERE userid = " . $vbulletin->userinfo['userid'] . "

to actually change it.