Raised This Month: $ Target: $400
 0% 

How do i make a message appear to a player every 2 hours (his time spent on a server)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-15-2015 , 15:56   How do i make a message appear to a player every 2 hours (his time spent on a server)
Reply With Quote #1

*Title*

For example, I have a plugin that stores player's played time in seconds. How do I make a message appear to the player every 2 hours? I don't mean every 2 hours of the global server time, I mean his time.. the player's time. If he just joined, and plays for 2 hours, a message appears (client_print, doesn't matter), then he takes a break... next day he joins again and his time is 2 hours, because he spent two hours yesterday and left, then he plays another 2 hours and the message appears again...

How can I make this?
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-15-2015 , 17:15   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #2

Saving and loading the time is the first step. I'm using a plugin that unlocks special skills when you reach X played minutes, but I haven't figured out a way to inform the player when he reaches them, excluding a task repeatedly doing a check every minute.

Last edited by OciXCrom; 10-15-2015 at 17:15.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-16-2015 , 09:01   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Saving and loading the time is the first step. I'm using a plugin that unlocks special skills when you reach X played minutes, but I haven't figured out a way to inform the player when he reaches them, excluding a task repeatedly doing a check every minute.
A task is fine, why people like to overthink ?
__________________
HamletEagle is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-15-2015 , 18:25   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #4

A good math should be the answer, but I can't think of anything... except writing a library that checks every 2 freaking hours like
PHP Code:
if(timespent[id] == 3600 && timespent[id] == 7200 &&/*infinity*/
, I'm not going to to that since It's not even necessary. If only we could think of something... Like checking timespent[id] for example (It holds spent time since last disconnect, because on client_disconnect the native get_user_time(id) is used), and dividing, creating and saving more values that would hold a number... It's so confusing
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-16-2015 , 10:10   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #5

OciXCrom may I see that plugin? (If It's not for public than you don't have to show me)

Edit: Nevermind, I'm talking about player's time

Last edited by redivcram; 10-16-2015 at 10:11.
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-16-2015 , 13:12   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #6

No, it's private. Yes, it's about the player's time. The saving part just sums up the player's time, I haven't added any checks like you're asking to. I guess that a task on the player every minute would be the most efficient way of doing it.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-16-2015 , 14:18   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #7

Wait.... can I actually do it with the for loop in the function that checks every 2 hours? I just need to find the final number with math.
I guess I wont host a server more than 3 months. So that would make X the final number.... It should go like this
PHP Code:
for(new 0Xi+= 7200); // 7200 seconds is 2 hours 
Thn you take the variable where the spent time is hold and check if the variable equals to i... the key for the loop
You can just replace 7200 with 60 if your plugin checks every minute.
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-16-2015 , 18:50   Re: How do i make a message appear to a player every 2 hours (his time spent on a ser
Reply With Quote #8

I didn't quite understand what you mean. You need to set a task when the player connects. The best way would be to set the task time to 120 - X minutes, where X would be the time left to 2 hours. You can probably find X from the player's time, but some math is required for this one.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode