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


Regarding Time Online - pinku - 08-05-2013 01:56 PM

Hey there!

With this function, I can calculate the total online time a player was online:

Code:
IF ( <TAG0.LASTCONNECTTIME> == 0 )
TAG0.LASTCONNECTTIME=<TIME>
IF (<TAG0.TOTALCONNECTTIME> == 0)
TAG0.TOTALCONNECTTIME=0
ENDIF
RETURN <eval ((<TAG0.TOTALCONNECTTIME> + <TIME> - <TAG0.LASTCONNECTTIME>)/10 )>

With this, they can grab prizes for 10 minutes online, 1 hour online, 1 day online, etc...

However, let's say I want to give my players one point (just +1 from a tag) per hour online:

Code:
<counts online time>
<1 hour online>
<eval tag bla +1>
<counts again online time from 0>
<1 hour online>
<eval tag bla +1>
...
...

How can I start it? Can someone enlighten me?

Thanks once again!


RE: Regarding Time Online - Rattlehead - 08-05-2013 02:03 PM

are u wanting to give them a tag from total online hours? or just hours from when they login?

will you be taking away from this tag? if not simply add @login

on=@login
src.tag.totalhours <eval <src.account.totalconnecttime> / 60>


RE: Regarding Time Online - pinku - 08-05-2013 02:28 PM

Thanks for your attention!

I want them to get a TAG (that is going to work like a point, but this does not matter anyway) for every 1 hour online.
Let me --try-- Tongue to explain better what I want to happen, without more TAGS on our way. I'll use gold as a reward.

Code:
Player logins in, time starts counting;
Player completes 1 hour online;
Player gets 1000 gold;
Timer restarts;
Player stays one more hour logged in;
Player gets 1000 gold;
Timer restarts;
...
...
Player log out, timer stops.

Did I make it easier or I failed miserably? Tongue

Thanks again!


RE: Regarding Time Online - Rattlehead - 08-05-2013 05:53 PM

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

[events e_online_time]
on=@login
if ((<isempty <src.tag.online_hours>>) || (<src.tag.online_hours> > 0))
src.tag.online_hours = 0
endif
src.timerf 3600,f_time_online

they log in, the trigger fires it checks to see if they have the tag, or if the tag is more than 0, if so it makes the tag 0 and after 3600 seconds (one hour) the function fires adding 1 to the tag.

untested, wrote on the fly Wink gl


RE: Regarding Time Online - pinku - 08-06-2013 01:15 AM

Thanks A LOT. I'm sure this will work for me! Smile


RE: Regarding Time Online - Mordaunt - 08-06-2013 02:44 AM

If you're not wanting to carry any time from the previous session you could use ctag instead of tag, which is automatically removed when a player logs out, thus reducing memory usage for your server.


RE: Regarding Time Online - darksun84 - 08-06-2013 03:19 AM

Pay attention to use timerf.
If the player logs out , timerf will still continue to run(while a timer item will stop), also you can't stop a timerf function without actually stopping all the timerf functions a player have! So you have to add some check for preventention(like checking if the player is online when the timerf finish)


RE: Regarding Time Online - pinku - 08-06-2013 04:03 AM

(08-06-2013 02:44 AM)Mordaunt Wrote:  If you're not wanting to carry any time from the previous session you could use ctag instead of tag, which is automatically removed when a player logs out, thus reducing memory usage for your server.

Thanks for the tip Mordaunt! They are always welcome.

(08-06-2013 03:19 AM)darksun84 Wrote:  Pay attention to use timerf.
If the player logs out , timerf will still continue to run(while a timer item will stop), also you can't stop a timerf function without actually stopping all the timerf functions a player have! So you have to add some check for preventention(like checking if the player is online when the timerf finish)

Thanks for the tip, darksun!

I haven't tested TIMERF in this case yet, but I'm sure a timer item will not stop. o:
I know that because I have a script to stop the timer from a certain memory.

Or are you talking about something else? =P


RE: Regarding Time Online - darksun84 - 08-06-2013 04:08 AM

An item with a timer equipped in layer 30


RE: Regarding Time Online - Mordaunt - 08-06-2013 05:28 AM

As of tonight's build (which is available in about 4 hours) according to ben there is a new feature you may want to play with for what you are doing:

Quote:Added #2177: - <ISTIMERF.functionname> to check if a timer exists. Returns the time left in sec if it exists or 0 if not.
TIMERF STOP,functionname to stop a specific timerf.