SRL Archive - Help and Support

Calculating experience per hour


TomTuff

2010-12-21 02:01:53

So I'm trying to fix up all the last little bugs in my most recent script (Working very well so far, and I've learned from past releases to fix all the bugs before you release ;)), but i can't quite get the exp/hr to work :(

At first i tried

X64 := Round((Players[i].Integers[12]*3600000)/PlayerWorked(i));

Where X64 is an Int64, and Players.Integers[12] is the players experience gained. That didn't work, and was spitting out apparently random numbers (Some were negative… lol)

So now i'm trying this:

X64 := Round(Players[i].Integers[12]/3600000);
But It's only putting out 0 :(

How should i do this? Help appreciated :)

i luffs yeww

2010-12-21 02:17:37

What if they only gain 12 exp? 12/3600000 is 0.000003333, rounded is 0.

So, you need to not round, and hope they gain a lot of exp.. over 3,600,000.. in one session..

KingKong

2010-12-21 02:18:42

First get the amount of experience gained, then get the time from the start of script then do this to get xp per hr

Round((totalxphere * 60.0)/(TimeFromMark(x) / 60000.0))

TomTuff

2010-12-21 02:18:47

From: i luffs yeww
What if they only gain 12 exp? 12/3600000 is 0.000003333, rounded is 0.

So, you need to not round, and hope they gain a lot of exp.. over 3,600,000.. in one session..


Well for one, that's the wrong way to calculate it, and 2, using the same formula, I've gained 26k exp and it's putting out 0 still…

There must be a way? lol

KingKong

2010-12-21 02:19:55

did you declare the variables as integers by any chance?

TomTuff

2010-12-21 02:24:11

From: kongking
did you declare the variables as integers by any chance?


From: TomTuff
..X64 is an Int64..




nope.

KingKong

2010-12-21 02:27:33

try it as extended variable, and try using the method i stated above(its not actually mine, belongs to deathscytex).

TomTuff

2010-12-21 02:31:33

From: kongking
First get the amount of experience gained, then get the time from the start of script then do this to get xp per hr

Round((totalxphere * 60.0)/(TimeFromMark(x) / 60000.0))


From: kongking
try it as extended variable, and try using the method i stated above(its not actually mine, belongs to deathscytex).


Ahhh didn't see the post.

Let's try it :)

EDIT: Also, that can be simplified down to XP / (1000 * Time) ;)


EDIT: Wrong forum so hard :( reported to be moved.

Quickmarch

2010-12-21 05:01:33

SCAR/Simba will think you're doing an integer division so you need to tell it to do a decimal one. Change 3600000 to 3600000.0 (Wrap the formula in the 'Round' function if you want an integral result).

TomTuff

2010-12-21 05:08:18

Wow Quickmarch, I love you. IT'S ALIVE :D

Bad Boy JH

2010-12-22 01:46:01

Having the / 3600000 at the begging, stuffs you up because it becomes 1, having it at the end stuffs you up because you can get an integer so high that it reaches over the maximum (2^32 - 1 off memory) and changes to a negative…

TomTuff

2010-12-22 01:52:31

From: Bad Boy JH
Having the / 3600000 at the begging, stuffs you up because it becomes 1, having it at the end stuffs you up because you can get an integer so high that it reaches over the maximum (2^32 - 1 off memory) and changes to a negative…


If you read the thread, the problem is solved.

But thanks, that would have been true if i was still having the problem :p

Narcle

2010-12-22 04:45:30

I suggest you use the formula kongking mentioned:
round( (Experience*60.0)/(PlayerWorked(CurrentPlayer)/60000.0))

This is the formula I use because if you use too big of a number eventually, if your script runs long enough, your xp*36*10^5 formula will get to big for Simba to hold as a variable and go negative as Bad Boy mentioned. I've had this happen when I first started scripting.

(You can declare the var as a Int64, but its really not necessary if done correctly.)

Bad Boy JH

2010-12-22 08:12:30

its the wtf moment followed by 15 minutes of bug testing that got it really irritating