SMFHacks.com
Badge Awards => Support => Topic started by: FrizzleFried on August 09, 2012, 01:49:07 pm
-
My users are getting the karma badge automatically when they first sign in. I am guessing this is because I use the advanced reputation mod that starts everyone with 100 karma points. I'd like to set that limit from 0 to 101 so they get the badge when someone gives them karma rather than up front...
I found this line:
if ($memberContext[$memberID]['karma']['good'] != 0 && !in_array($badgeAction,$currentBadges))
Would I be correct in assuming I could change that 0 to 101 to accomplish what I am looking to do?
Thanks!
-
Oh... and to be clear... the advanced rep mod does use the "stock" karma string... but like I said, I have it starting folks with 100 karma to begin with.
-
I would change != 0 to > 100
I think that would work.
-
Yeah... that works... sort of. Unfortunately the Advanced Rep System also gives karma for posting... so as soon as I posted while testing my karma went to 102 from 100 and... welp, I got the karma badge.
Bummer... maybe I will just change it to 200 and in the description change it to "Recipient of this badge has earned 200 Karma Points or more" or something generic...
-
how to set badge for a certain amount of
giving good karma
giving bad karma
and number of topics started ?
-
You would have to create a new badge in the badge awards admin area.
Then check sources/badgeawards2.php and you will need to copy and change code such as
$badgeAction = 'topic';
if ($memberContext[$memberID]['posts'] != 0 && !in_array($badgeAction,$currentBadges))
{
$result = $smcFunc['db_query']('', "
SELECT COUNT(*) AS total FROM {db_prefix}topics
WHERE ID_MEMBER_STARTED = $memberID
");
$totalRow = $smcFunc['db_fetch_assoc']($result);
if ($totalRow['total'] > 0)
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[] = $badgeAction;
}
}
}
And
$badgeAction = 'karma';
if ($memberContext[$memberID]['karma']['good'] != 0 && !in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[] = $badgeAction;
}
}
-
You would have to create a new badge in the badge awards admin area.
Then check sources/badgeawards2.php and you will need to copy and change code such as
$badgeAction = 'topic';
if ($memberContext[$memberID]['posts'] != 0 && !in_array($badgeAction,$currentBadges))
{
$result = $smcFunc['db_query']('', "
SELECT COUNT(*) AS total FROM {db_prefix}topics
WHERE ID_MEMBER_STARTED = $memberID
");
$totalRow = $smcFunc['db_fetch_assoc']($result);
if ($totalRow['total'] > 0)
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[] = $badgeAction;
}
}
}
And
$badgeAction = 'karma';
if ($memberContext[$memberID]['karma']['good'] != 0 && !in_array($badgeAction,$currentBadges))
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[] = $badgeAction;
}
}
but how to say give badge to someone who gave 4 negative karma ?
-
I think I would just change
$memberContext[$memberID]['karma']['good']
To
$memberContext[$memberID]['karma']['bad']
For the check and see if equals 4
-
I think I would just change
$memberContext[$memberID]['karma']['good']
To
$memberContext[$memberID]['karma']['bad']
For the check and see if equals 4
is this for receiving ?
i'm looking to query if they gave good and bad karma
-
I already have actions to give a badge on negative or postiive karma and that is found in sources/Karma.php
// Badge Awards
global $sourcedir, $user_info;
require_once($sourcedir . '/badgeawards2.php');
if ($dir == 1)
{
Badges_AwardBadge($user_info['id'],'karmagood');
}
else
{
Badges_AwardBadge($user_info['id'],'karmabad');
}
// End Badge Awards