Set_Task problem
I'm trying to use set_task to run a function when a round has 8 minutes left. I am using a plugin that Connor made that returns the amount of seconds remaining in a round, but whenever I set the task, it runs immediately, even if it isn't 8:00 minutes left in the round.
PHP Code:
8 * 60 means that when there are 8 minutes left ( 8 minutes times 60 seconds ) Any ideas as to what the problem is? |
Re: Set_Task problem
|
Re: Set_Task problem
Quote:
@nikhilgupta345: Assume get_remaining_seconds() returns 60 (1 minute left in the round) 8 * 60 = 480 60 - 480 is a negative number. Obviously you can't do things in the past, and set_task sets the minimum time interval to be 0.1 seconds. You should check that the time hasn't expired yet ( get_remaining_seconds() > 8*60 ) For the next part we need to play around a little bit: Let's say that there are 10 minutes left in the round currently. That means that get_remaining_seconds() == 600. If we want it to happen with 480 seconds left, then you need to find how many seconds are in between (you can do this by subtracting the numbers) edit: Seems to be fine actually. |
Re: Set_Task problem
:O how is it in wrong order?
It takes the amount of seconds left (in case of 10 minutes: 600), and then subtracts 480 from that That gives you 120 seconds, which is when it will run.\ So then the function will run in 120 seconds or 2 minutes right? Also, my code is going by a vote menu that occurs in the beginning of the round, and my code also sets the roundtime to 9 minutes, so I dont think there is a problem with the time remaining. The vote gives 10 seconds to vote, which starting at 9 minutes, which end at 8:50, leaving 50 seconds to go. Any other ideas? |
Re: Set_Task problem
Bah, don't know how I screwed that one up.
The easiest way to figure it out would be to put your time calculation into a variable, then print that variable in client_print [obviously remove that when you figure it out]. |
Re: Set_Task problem
Hmm, wtf? Im getting -10 when I try get_remaining_seconds...I'm guesing that's the problem....
EDIT: Just decided to just get the remaining time just with my plugin directly instead of usign the other one. Works fine now. Thanks for your help :) |
| All times are GMT -4. The time now is 19:55. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.