1 point every hour

marly

Regular Member
Joined
Nov 4, 2010
Messages
297
Reaction score
67
Trying to implement a function to my site that, every hour your logged in, you get 1 point.
Or you have an image next to login that changes to "receive point" every hour.
This to reward dedication.
I've studies some jquery, but have yet to find a solid solution.
Any point in the right direction, you rock!
 
I think one way to do it is to send ajax request to some server script periodically.
And in that script you can compare last time this request was sent by user, and make decisions from the timespans between this requests.
 
Code:
function Main() {
    var time;   
    time = 0;

    var points;   
    points = 0;

    for (time = 0 ; time <= 59 ; time += 1) {
        points = points + 1;
        output("points: " + points);
        output(points);
    }
}



function output (text) {
    //window.alert(text);
    console.log(text);
}


Not tested the above but I believe this simple code I written should achieve in the simplistic sense what you are trying to do and get you started in the right direction.

As in respect of time in Javascript you can use EPOCH time and calculate manually to do it on an hour basis (my code does it for 60 seconds) or you can use this really easy JS library, JS is just as good as Jquery in my opinion, especially for doing something simple like this there is not much point in jquery you can achieve the same perhaps easier with javascript, check out the time library here: momentjs.com I can't post links yet I think so apologies for that.
 
Thanks so much for your input will try and implement this!! Will let you know how it worked.
 
I did something like this. It was logging work hours. Like Sergey Yermak said used Ajax to update your server. But on your client side, use set_interval as the timer. You also have to keep track of the timers on the server-side. Otherwise I can just launch multiple tabs and game the system. ;D
 
I did something like this. It was logging work hours. Like https://www.blackhatworld.com/members/sergey-yermak.950140/ said used Ajax to update your server. But on your client side, use set_interval as the timer. You also have to keep track of the timers on the server-side. Otherwise I can just launch multiple tabs and game the system. ;D
Thanks so much for your input will try and implement this!! Will let you know how it worked.

It works, just it prints to console currently so you need to assign it to appropiate class, div or whatever how your website works in terms of outputs.
 
Back
Top