AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set_Task problem (https://forums.alliedmods.net/showthread.php?t=154838)

nikhilgupta345 04-13-2011 19:34

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:

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?

lis_16 04-13-2011 19:40

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

use flag d

Emp` 04-13-2011 19:49

Re: Set_Task problem
 
Quote:

Originally Posted by lis_16 (Post 1449187)

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.

nikhilgupta345 04-13-2011 20:10

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?

Emp` 04-13-2011 20:14

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

nikhilgupta345 04-13-2011 20:17

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.