SphereCommunity
Regarding Time Online - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Regarding Time Online (/Thread-Regarding-Time-Online)

Pages: 1 2 3


RE: Regarding Time Online - pinku - 08-06-2013 05:35 AM

Oh! hahaha.

4 hours?!
I'll just wait for this then. Surely will make my life MUCH easier.
Thanks again Mordaunt. Smile


RE: Regarding Time Online - Mordaunt - 08-06-2013 06:01 AM

Yeah he has committed the changes, 12:05 (ish) Berlin time is when the automated nightly build appears


RE: Regarding Time Online - Rattlehead - 08-06-2013 07:42 AM

wow, i was just about to suggest a way to stop a timerf function based on function name too, cus i have had issues with that in the past

so, thats friggin awesome Ben, thx man Wink

revised if using the newest nightly build

Code:
[function f_time_online]
src.ctag.online_hours += 1

[events e_online_time]
on=@login
if (<istimerf.f_time_online> == 1)
timerf stop,f_time_online
endif
src.timerf 3600,f_time_online

and ty for the reminder about ctags, saves the need for an extra IF statement Wink


RE: Regarding Time Online - Coruja - 08-09-2013 04:04 PM

<ACCOUNT.LASTCONNECTTIME> counts the total time (minutes) of your last connection. So if you stay online for 80min it will return "80", just divide it by 60 and you will get the value in hours. You can do it using just 1 code line, simple as this:
Code:
ON=@Logout
TAG0.OnlineHours += <eval <ACCOUNT.LASTCONNECTTIME>/60>



RE: Regarding Time Online - Rattlehead - 08-13-2013 07:43 AM

yeah, but then it only tallies once they log off, i think he wanted to know in game while online the tally of their hours while in game.


RE: Regarding Time Online - Coruja - 08-14-2013 04:19 AM

in this case I think its better use just 1 function to all clients instead of a timer running separately on each player. The tag will be better stored as minutes and then convert it to hours/days/etc as you need. It will get a much more accurate result compared to a tag that just count at full hours

Code:
[EVENTS e_connection_time]
ON=@Login
CTAG.ConnectionTimestamp=<SERV.TIME> //set the current timestamp on login to prevent incorrect counting

[FUNCTION CountConnectionTime]
TAG0.OnlineMinutes += <eval (<SERV.TIME>-<CTAG0.ConnectionTimestamp>)/600>
CTAG.ConnectionTimestamp=<SERV.TIME>

just add the event on all clients and keep calling "SERV.ALLCLIENTS CountConnectionTime" at each X minutes (maybe the best way is use it directly on f_onserver_timer)

PS: needs a better testing, since I'm doing it without testing any result


RE: Regarding Time Online - Rattlehead - 08-14-2013 08:16 AM

so ur saying that running a function that fires on all connected players every few minutes would be better than a function that only fires per player every hour?

i will have to disagree on this one, for multiple reasons

1) a function that fires on a per player basis every hour, will obviously only fire every hour that they are online, rarely do multiple players login at the same time, therefore the functions wont be firing at the same time, giving each their own wiggle room as far as resource are concerned

2) since the functions fire on a per player basis, you wont have the immense resource consumption of the allclients firing, if there were say 100 players on, then when all clients is fired its going to take up a good bit of resources, tie that in with firing every X minutes, and ur looking at a resource hog every X minutes rather than just a function firing every so often per players login

3) he was only interested in every hour, so it seems counter productive to have it adding every few minutes when the minutes are of no concern to the outcome of the results, so again u would be trading resource consumption for irrelevant accuracy

i would also like to point out using TAG0 on the left side of a statement is unnecessary as you are defining the tag on the left side, and tag0 is only for statements that may have the opportunity to resolve to nothing rather than 0

firing a timerf function every hour on the player is as accurate as any other way of timing an hour, logging the current server time and counting back from it really wont be anymore accurate than the timerf, not to mention more calls to the server to get the time and adding it to a ctag that gets evaluated later, thus adding to more resource consumption

just my view, i could be wrong, but i am willing to bet that my reasoning endures Wink


RE: Regarding Time Online - RanXerox - 08-15-2013 12:42 AM

There is an ACCOUNT property called TOTALCONNECTIME... does that not work?


RE: Regarding Time Online - Mordaunt - 08-15-2013 01:17 AM

Of course it works, but that's not what he wants.

He wants to reward players when they stay online for an hour, and then for each hour afterwards and only in those sessions. At least that's what I understand. So sessions less than an hour would not be rewarded, and then when they log on and complete an hour using TOTALCONNECTTIME they'd get rewarded, which isn't wanted.

At least that's how I read this whole thing


RE: Regarding Time Online - Coruja - 08-15-2013 03:26 AM

(08-14-2013 08:16 AM)Rattlehead Wrote:  so ur saying that running a function that fires on all connected players every few minutes would be better than a function that only fires per player every hour?

i will have to disagree on this one, for multiple reasons

1) a function that fires on a per player basis every hour, will obviously only fire every hour that they are online, rarely do multiple players login at the same time, therefore the functions wont be firing at the same time, giving each their own wiggle room as far as resource are concerned

2) since the functions fire on a per player basis, you wont have the immense resource consumption of the allclients firing, if there were say 100 players on, then when all clients is fired its going to take up a good bit of resources, tie that in with firing every X minutes, and ur looking at a resource hog every X minutes rather than just a function firing every so often per players login

3) he was only interested in every hour, so it seems counter productive to have it adding every few minutes when the minutes are of no concern to the outcome of the results, so again u would be trading resource consumption for irrelevant accuracy

i would also like to point out using TAG0 on the left side of a statement is unnecessary as you are defining the tag on the left side, and tag0 is only for statements that may have the opportunity to resolve to nothing rather than 0

firing a timerf function every hour on the player is as accurate as any other way of timing an hour, logging the current server time and counting back from it really wont be anymore accurate than the timerf, not to mention more calls to the server to get the time and adding it to a ctag that gets evaluated later, thus adding to more resource consumption

just my view, i could be wrong, but i am willing to bet that my reasoning endures Wink
it will work using both ways
but its not a good idea run a -active- timer on every player. I will prefer consume 0 resources and run a light-weight function on every player at each 5~10 minutes than set a active timerf running on every single connected account. Of course we cant run heavy functions on allclients, but in this case the function is ultra mega hyper very light and won't cause any lag, freeze or something like this even for 0.0000001ms

the accurary which I mean is count the connection time using the correct time instead counting only full hours. I can make multiple logins counting 15min + 5min + 20min and it will count 40 minutes. Doesnt reach a full hour yet, but another login using more 20 minutes will do it. Its better than counting 0 on all connections because I doesn't reach a full hour connected on none of them Big Grin

(08-15-2013 01:17 AM)Mordaunt Wrote:  Of course it works, but that's not what he wants.

He wants to reward players when they stay online for an hour, and then for each hour afterwards and only in those sessions. At least that's what I understand. So sessions less than an hour would not be rewarded, and then when they log on and complete an hour using TOTALCONNECTTIME they'd get rewarded, which isn't wanted.

At least that's how I read this whole thing
I would prefer using LASTCONNECTTIME / TOTALCONNECTTIME too, its more simple and optimized. But maybe only he would clarify the idea, since we're a bit confusing with everything lol