Shattered Kingdoms
https://shatteredkingdoms.com/forums/

(zMud) Vote Reminder - By Boo
https://shatteredkingdoms.com/forums/viewtopic.php?f=42&t=20224
Page 1 of 1

Author:  Rennus_Dragonsbane [ Fri May 07, 2010 7:09 am ]
Post subject:  (zMud) Vote Reminder - By Boo

Code:
#CLASS {VoteReminder}
#VAR lastVote {22-9-2003-17-31-46}
#ONINPUT {who} {
  #mss {"function timeToVote(lastVote) { lastVote = lastVote.split('-'); now = new Date; lastVote = new Date(lastVote[2], (lastVote[1]-1), lastVote[0], lastVote[3], lastVote[4], lastVote[5]); nextVote = new Date(lastVote); nextVote.setHours( nextVote.getHours() + 12); retVal = (nextVote < now) ? 1 : 0; return retVal;}"} {javascript}
  #mss {"function votedAt() {now = new Date; retVal = now.getDate() + '-' + (now.getMonth()+1) + '-' + now.getYear() + '-'; retVal += now.getHours() + '-' + now.getMinutes() + '-' + now.getSeconds(); return retVal; }"} {javascript}
  #if (%mss( %concat( "timeToVote('", @lastVote, "')"))) {
 #yesno {You can vote on topmudsites, do you wish to vote now?} {
      Yes: lastVote = %mss( "votedAt()")
      #url {"http://www.topmudsites.com/cgi-bin/topmuds/rankem.cgi?id=dulrik"}
      } {No:}
    }
  #mss {}
  } "" {notrig}
#CLASS 0


This code snippet will be in SkBase v1.3, but I thought I'd post it here too in case you just want to use it in your Zmud script.

It uses embedded javascript in the Zmud script (because Zmud can't handle dates and times well) and everytime you type 'who'
it checks if it's more than 12 hours since your last vote on topmudsites. It is time/date based so it ensures you are prompted to vote
every 12 hours.

After 12 hours has expired, a prompt pops up, clicking Yes (you want to vote) redirects you to the URL to vote for SK and updates
the 'lastVote' variable to the current date and time , clicking No does not update the variable (which means you get reminded
until you vote :P)

Hope this is useful to you.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/