Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and are struggling to install it? Cronwerks now installs mods for only $3/$2.50. Message Cronus to discuss the details or purchase.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [??]Timing script.  (Read 1121 times)

mentaljason

  • Basic Member
  • *
  • Reputation Power: 13
  • mentaljason has no influence.
  • Offline Offline
  • Posts: 28
  • MentalJason HURRAH
    • View Profile
    • WWW
[??]Timing script.
« on: January 14, 2010, 08:44:52 AM »
A simple timer to go near bars, repetitvly counts down from 5minutes to 0 and then counts how many times it does it so users know how much energy they have acumulated and also know when they will get refils etc.

NOTE: not finished yet, php or java?
Logged
Like Mccodes? Like things to be free? try My mods forum where all of the mods are free!

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [??]Timing script.
« Reply #1 on: January 14, 2010, 12:41:32 PM »
Do you mean JavaScript. Dig difference
Logged
Project Choosen - 10%
Daniel - Hanson . Com

melduk

  • Basic Member
  • *
  • Reputation Power: 10
  • melduk has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
Re: [??]Timing script.
« Reply #2 on: April 12, 2010, 11:00:51 AM »
Did this script ever get finished? This would be really good.
Logged

mentaljason

  • Basic Member
  • *
  • Reputation Power: 13
  • mentaljason has no influence.
  • Offline Offline
  • Posts: 28
  • MentalJason HURRAH
    • View Profile
    • WWW
Re: [??]Timing script.
« Reply #3 on: October 14, 2010, 07:13:21 AM »
No Completely forgot about this, It's an old post.. VERY old but i guess I'll have another try, if i remebr rightly i screwed up when trying to make it different for donators, Still Ajax would probly be better.
Logged
Like Mccodes? Like things to be free? try My mods forum where all of the mods are free!

urbanmafia

  • Basic Member
  • *
  • Reputation Power: 0
  • urbanmafia has no influence.
  • Offline Offline
  • Posts: 2
    • View Profile
Re: [??]Timing script.
« Reply #4 on: October 25, 2010, 03:40:02 PM »
why dont you add a new field within the users table called newupdate then use shrek's code from make webgames to countdown and then add a line in the cron then updates the field with a new timestamp every 5 mins or for donators it updates something else pretty simple
Logged

urbanmafia

  • Basic Member
  • *
  • Reputation Power: 0
  • urbanmafia has no influence.
  • Offline Offline
  • Posts: 2
    • View Profile
Re: [??]Timing script.
« Reply #5 on: October 25, 2010, 03:50:21 PM »
The script was not originally made by me just edited by me to work with update countdown

Original Source

run this sql:
Code: [Select]
alter table users add nxtupdate int(11) not null default 0

find:
Code: [Select]
<b>Health:</b> {$hpperc}%<br />
<img src=greenbar.png width=$hpperc height=10><img src=redbar.png width=$hpopp height=10><br /><hr />
<!-- Links -->

replace with:
Code: [Select]
<b>Health:</b> {$hpperc}%<br />
<img src=greenbar.png width=$hpperc height=10><img src=redbar.png width=$hpopp height=10><br />
<!-- Links -->

find:
Code: [Select]
<!-- Links -->
OUT;

add below:
Code: [Select]
$time = time();
if ($ir['nxtupdate'] > $time)
{
print "<html><body>
<div id='countdown'></div> till next update
<div id='notifier'></div>
<script type='text/javascript'>
(function () {
  function display( notifier, str ) {
    document.getElementById(notifier).innerHTML = str;
  }

  function toMinuteAndSecond( x ) {
    return Math.floor(x/60) + ':' + (x%60<10?'0':'')+x%60;
  }

  function setTimer( remain, actions ) {
    var action;
    (function countdown() {
       display('countdown', toMinuteAndSecond(remain));
       if (action = actions[remain]) {
         action();
       }
       if (remain > 0) {
         remain -= 1;
         setTimeout(arguments.callee, 1000);
       }
    })(); // End countdown
  }

  setTimer({$ir['nxtupdate']}-$time, {
    0: function () { display('notifier', 'Updating');       }

  });
})();
</script></body></html><hr />";
}

add this to 5 min cron
Code: [Select]
//timer countdown
$query="UPDATE users SET nxtupdate=unix_timestamp() + 300 ";
$db->query($query);


finished now you should a have a working update counter well this is how i would do it anyways.
« Last Edit: November 07, 2010, 01:07:59 PM by urbanmafia »
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.