Raised This Month: $ Target: $400
 0% 

Set_Task problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 04-13-2011 , 19:34   Set_Task problem
Reply With Quote #1

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:
set_taskfloatget_remaining_seconds() - ( 60 ) ), "startDodgeballDay" ); 
get_remaining_seconds returns seconds left in round.
8 * 60 means that when there are 8 minutes left ( 8 minutes times 60 seconds )

Any ideas as to what the problem is?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
lis_16
Senior Member
Join Date: Feb 2008
Old 04-13-2011 , 19:40   Re: Set_Task problem
Reply With Quote #2

http://www.amxmodx.org/funcwiki.php?go=func&id=253

use flag d
lis_16 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-13-2011 , 19:49   Re: Set_Task problem
Reply With Quote #3

Quote:
Originally Posted by lis_16 View Post
Not what he wants.

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

Last edited by Emp`; 04-13-2011 at 20:15.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 04-13-2011 , 20:10   Re: Set_Task problem
Reply With Quote #4

: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?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-13-2011 , 20:14   Re: Set_Task problem
Reply With Quote #5

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].
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 04-13-2011 , 20:17   Re: Set_Task problem
Reply With Quote #6

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
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 04-13-2011 at 20:25.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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 19:54.


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