SRL Archive - SRL Bugs

system time


bolshak25

2011-07-21 10:33:25

ive noticed scripts sometimes use getsystemtime and subtract the original from the new to find how long the script has been running, but it comes up with a negative amount if it runs past a certain amount. is there a way to fix that?

e:switched them around

Dgby714

2011-07-21 10:38:45

You should subtract the old time from the new one >..> unless that's what you mean, You said it backwards.

T := GetTickCount; //Same as GetSystemTime
Wait(100);
WriteLn(GetTickCount - T);

bolshak25

2011-07-21 10:45:48

From: Dgby714
You should subtract the old time from the new one >..> unless that's what you mean, You said it backwards.

T := GetTickCount; //Same as GetSystemTime
Wait(100);
WriteLn(GetTickCount - T);


sorry, yes i meant that.

totalRuntime :=  getSystemTime - startTime
writeln('Xp/h: ' + toStr((3600 * xpGain) div (totalRuntime div 1000 + 1)));
-----Iamadam's Strong-Holder------
Running for 1040 minutes (In fight with Zombie)
Exp gained: 774260 (3551 zombies killed)
Times eaten: 236
Times banked: 8
Xp/h: -24138
Randoms found: 3
Levels - Atk: 80 Str: 93 Def: 80 HP: 87 Rng: 74

first one is where it subtracts, second is the line to show how it calculates xp/h, and proggy shows time and bugged xp/h

Awkwardsaw

2011-07-21 11:19:13

That should work. This is what I use, It's the same thing :p

result := (3600 * i) / (1 + ((GetTimeRunning) / 1000));

bolshak25

2011-07-21 11:22:22

then why does it come out negative like that? does get system just look at hour/minute so if its a new day it breaks? im not sure, but it worked for awhile, then i checked this morning and it went negative

Awkwardsaw

2011-07-21 11:29:18

From: bolshak25
then why does it come out negative like that? does get system just look at hour/minute so if its a new day it breaks? im not sure, but it worked for awhile, then i checked this morning and it went negative


Unless gettimerunning is different, I doubt it though

bolshak25

2011-07-21 11:32:55

From: Awkwardsaw
Unless gettimerunning is different, I doubt it though


is that a just a different function that gets how long its been running?
where can i find getsytemtime? so i can try to see what it reads

Dgby714

2011-07-21 12:19:21

From: bolshak25
is that a just a different function that gets how long its been running?
where can i find getsytemtime? so i can try to see what it reads


GetSystemTime on a windows system, just calls the WinAPI GetTickCount.

http://msdn.microsoft.com/en-us/library/ms724408(v=vs.85).aspx

Yago

2011-07-22 00:06:29

I think it comes out negative when your using numbers that are really big… like too big for int… looks like the exp gain might be negative though…