XP Counter

Posted by Simon on Sat 18 Aug 2001 07:38 AM — 4 posts, 19,484 views.

Sweden #0
Hey, I am working on an xp counter but I'm not really getting it working :(
This is what I am triggering on:

You have 496,903,292 total xp, with 6,786,388 to next level and 24,325,293 to level.

I set those to 3 different variables, TotXp, XpTNL and XPToSp.

Then I want it to count over how much xp I made the last hour, and how much I've made the last 10 hours. So I figure I'd have to add some variables and a timer! I've never worked with timers before so I have no idea how to do that :(
Australia Forum Administrator #1
The first part is pretty easy, working out the current amounts and putting into a variable, something like this:


Trigger: You have * total xp, with * to next level and * to level.
Label: Experience
Script: Experience


The script below would collect that data, strip the commas from the numbers, convert into doubles (which will hold a large number) and put into variables.

However knowing how many you go "in the last hour" is a bit trickier. I don't think a timer would help, however you could investigate using the "Now" function to find the current time, and the "DateDiff" function to find how many hours have elapsed.

I don't know how to easily do all that without maintaining a list of how many XP you had, say, every hour, and comparing your current one to the one in that list.

I hope that gives you something to go on with ...


Sub Experience (strTriggerName, trig_line, arrWildCards)
dim TotXp, XpTNL, XPToSp 

  ' get rid of commas and convert to a double (floating point number)
  TotXp  = CDbl (world.Replace (arrWildcards (1), ",", "", true))
  XpTNL  = CDbl (world.Replace (arrWildcards (2), ",", "", true))
  XPToSp = CDbl (world.Replace (arrWildcards (3), ",", "", true))

  world.SetVariable "TotXp", TotXp  
  world.SetVariable "XpTNL", XpTNL
  world.SetVariable "XPToSp", XPToSp

End Sub


Sweden #2
hmm ok... I worked a bit on it and got most of it working.. just one problem, is there any way to get a different formatting on the date diff than just the one that shows the amount of seconds that has passed? (using the "s" in it)

Thanx for the help :)

/Simon
Australia Forum Administrator #3
Sure, you have the following options:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second