AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do i make a message appear to a player every 2 hours (his time spent on a server) (https://forums.alliedmods.net/showthread.php?t=273233)

redivcram 10-15-2015 15:56

How do i make a message appear to a player every 2 hours (his time spent on a server)
 
*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?

OciXCrom 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
 
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.

redivcram 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
 
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

HamletEagle 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
 
Quote:

Originally Posted by OciXCrom (Post 2353438)
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 ?

redivcram 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
 
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

OciXCrom 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
 
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.

redivcram 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
 
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.

OciXCrom 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
 
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.


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

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