The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regarding Time Online
Author Message
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #1
Regarding Time Online
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!
08-05-2013 01:56 PM
Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #2
RE: Regarding Time Online
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>

[Image: matts_siggy.gif]
08-05-2013 02:03 PM
Find all posts by this user Like Post Quote this message in a reply
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #3
RE: Regarding Time Online
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!
(This post was last modified: 08-05-2013 02:28 PM by pinku.)
08-05-2013 02:28 PM
Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #4
RE: Regarding Time Online
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

[Image: matts_siggy.gif]
08-05-2013 05:53 PM
Find all posts by this user Like Post Quote this message in a reply
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #5
RE: Regarding Time Online
Thanks A LOT. I'm sure this will work for me! Smile
08-06-2013 01:15 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #6
RE: Regarding Time Online
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.

[Image: 2nis46r.jpg]
08-06-2013 02:44 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #7
RE: Regarding Time Online
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)
(This post was last modified: 08-06-2013 03:21 AM by darksun84.)
08-06-2013 03:19 AM
Find all posts by this user Like Post Quote this message in a reply
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #8
RE: Regarding Time Online
(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
(This post was last modified: 08-06-2013 04:03 AM by pinku.)
08-06-2013 04:03 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #9
RE: Regarding Time Online
An item with a timer equipped in layer 30
08-06-2013 04:08 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #10
RE: Regarding Time Online
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.

[Image: 2nis46r.jpg]
08-06-2013 05:28 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)