I have had this request from many of my users and thought it might be interesting to post here.
Once someone has given karma they are restricted from giving karma to the same person for one hour. (my settings)
How about having a time left display. Something like....
"Sorry, you can't repeat a karma action without waiting 1 hour, you have 25 minutes left."
Or something like that.
Thanks,
Lisa
Shouldn't be too hard to do. Unfortunately I'm not at home right now so I don't have a copy of SMF to look at... I'll try to post something tomorrow though.
thanks Oldiesmann, it should be really nice
and should be added as a feature i think
edit: whats this option in Karma settings?
Set wait time in hours
That's the wait time. It specifies how long (in hours) people have to wait between consecutive Karma actions on the same person.
and isnt this what Lisah746 asked for anyway?
i am confused now :P
Quote from: elmacik on October 08, 2005, 11:40:10 PM
and isnt this what Lisah746 asked for anyway?
i am confused now :P
I am asking for the time remaining before you can karma the same poster to be shown.
hmm sorry, i newly got the point
Sorry for not posting sooner Lisah. I forgot about this topic :)
Sources/Karma.php
Find
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);
Replace
// Find out if this user has done this recently...
$request = db_query("
SELECT action, logTime
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action, $time) = mysql_fetch_row($request);
mysql_free_result($request);
Find
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);
Replace
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
{
// How much longer do they have to wait (in minutes)? Round to the nearest integer...
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . ' (' . $waittime . ' more ' . $txt['totaltimelogged4'] . ')', false);
}
That will give them an (approximate) value. It rounds to the nearest integer, so the value could be off by as much as 30 seconds in either direction, but 30 seconds doesn't make that much of a difference anyway, so I don't think it's that important.
I think this should be added to the Tips and tricks board.
Quote from: JayBachatero on October 13, 2005, 12:06:27 AM
I think this should be added to the Tips and tricks board.
+1
Quote from: elmacik on October 13, 2005, 12:13:47 AM
Quote from: JayBachatero on October 13, 2005, 12:06:27 AM
I think this should be added to the Tips and tricks board.
+1
+2 and maybe intergrated into the karma mod itself. Thanks Oldiesmann. As soon as I get it intergrated I'll let you know.
I added the code exactly as it appears here and got the following error.
Parse error: parse error, unexpected ')' in /home/lisah/public_html/Sources/Karma.php on line 118
Any ideas?
Can you post the block of code from line 115 to 120?
This line looks to be the problem:
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
I'll assume that the entire result should be rounded and the line should look like this:
$waittime = round(($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
Yep. It should be. Thanks Jack :)
Quote from: Jack.R.Abbit on October 13, 2005, 06:34:55 PM
This line looks to be the problem:
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
I'll assume that the entire result should be rounded and the line should look like this:
$waittime = round(($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
Yep that did it! I did add to it 'Minutes Remaining' so it looks like.... Sorry you have 45 minutes remaining.
Thank-You everyone.
excellent trick :) i am using it now! ;D
I've got the following error. :-\
8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111
Any ideas? :-\
If you have karma description log mod, and want to use this trick, this is what you need to replace.
Sources/Karma.php
Find
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);
Replace
// Find out if this user has done this recently...
$request = db_query("
SELECT action, logTime
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action, $time) = mysql_fetch_row($request);
mysql_free_result($request);
Find
// If you are gonna try to repeat.... don't allow it.
if ($restricttime < $timelog)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);
Replace
// If you are gonna try to repeat.... don't allow it.
if ($restricttime < $timelog)
{
// How much longer do they have to wait (in minutes)? Round to the nearest integer...
$waittime = $timelog - $restricttime;
$minutes = round(($waittime / 60));
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . ' (' . $minutes . ' more minutes)', false);
}
Note: I had some troubles with the provided $waittime function referred a few posts ago, but this works perfect...
Quote from: Hoochie Coochie Man on November 18, 2007, 07:20:53 PM
I've got the following error. :-\
8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111
Any ideas? :-\
Are you still experiencing this problem?
What is your current language settings. Check you Index.english.php file to make sure it's present. If you are using a language other than english, make sure you have the appropriate index.{language}.php file in your default language folder.
Quote from: Rumbaar on December 14, 2007, 04:13:26 AM
Quote from: Hoochie Coochie Man on November 18, 2007, 07:20:53 PM
I've got the following error. :-\
8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111
Any ideas? :-\
Are you still experiencing this problem?
What is your current language settings. Check you Index.english.php file to make sure it's present. If you are using a language other than english, make sure you have the appropriate index.{language}.php file in your default language folder.
That was an old post :)
I solved my problem!
Thankyou very much anyway :)
But what about the function to be under a time-limit for each person You give a point separately, instead of not being able to give anyone else a point once You've given it to one person?
on Vbulletin boards you can change it where it is not a specific amount of time that one has to wait, but that one "must pass some reputation around before giving it to ABC person again". Is there a way to do that on SMF?
I can only think of a post count based option at the moment.
You might want to search some more or try the Mod Request section.