Raised This Month: $51 Target: $400
 12% 

Check if() Task done .


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stressful
Senior Member
Join Date: Feb 2011
Old 11-30-2011 , 03:53   Check if() Task done .
Reply With Quote #1

How to check if a "task" is done ? And when its done , The "task" would stop what its doing .
__________________

Last edited by Stressful; 11-30-2011 at 06:22.
Stressful is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-30-2011 , 06:27   Re: Check if() Task done .
Reply With Quote #2

Code:
new bool:taskDone set_task( time , "function" ) public function( ) {     taskDone = true } public checkTaskDone( ) {     if( taskDone )     {         // ...     } }

Last edited by Devil259; 11-30-2011 at 10:06.
Devil259 is offline
fl0werD
Senior Member
Join Date: May 2011
Old 11-30-2011 , 06:35   Re: Check if() Task done .
Reply With Quote #3

PHP Code:
new Float:g_flTask[33];
new 
bool:g_bTask[33];

public function(
id)
{
    
g_bTask[id] = true;
    
g_flTask[id] = get_gametime() + 5.0;
}

public 
client_PreThink(id)
{
    if(!
g_bTask[id])
        return;

    if(
g_flTask[id] <= get_gametime())
    {
        
g_bTask[id] = false;

        
// task done;
    
}


Last edited by fl0werD; 11-30-2011 at 06:59.
fl0werD is offline
Send a message via ICQ to fl0werD
Snaker beatter
Veteran Member
Join Date: Sep 2011
Location: Manila, Philippines
Old 11-30-2011 , 06:38   Re: Check if() Task done .
Reply With Quote #4

Just add g_task = true on the task's function
__________________
Snaker beatter is offline
fl0werD
Senior Member
Join Date: May 2011
Old 11-30-2011 , 06:59   Re: Check if() Task done .
Reply With Quote #5

Quote:
Originally Posted by Snaker beatter View Post
Just add g_task = true on the task's function
Edited.
fl0werD is offline
Send a message via ICQ to fl0werD
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-30-2011 , 07:09   Re: Check if() Task done .
Reply With Quote #6

task_exists
When it returns 0, the task finished.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Stressful
Senior Member
Join Date: Feb 2011
Old 12-01-2011 , 22:01   Re: Check if() Task done .
Reply With Quote #7

I tried that but the plugin just skip the task . And when I swap their places , The task just keep repeating and repeating the same thing .
PHP Code:


    if(
g_flTask[id] <= get_gametime()) 
    { 
        
g_bTask[id] = false

        
// task done; 
    

    
if(!
g_bTask[id]) 
        return; 

__________________
Stressful is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-01-2011 , 23:41   Re: Check if() Task done .
Reply With Quote #8

Quote:
Originally Posted by Stressful View Post
I tried that but the plugin just skip the task . And when I swap their places , The task just keep repeating and repeating the same thing .
PHP Code:


    if(
g_flTask[id] <= get_gametime()) 
    { 
        
g_bTask[id] = false

        
// task done; 
    

    
if(!
g_bTask[id]) 
        return; 

You have tried the worst code that has been given.

drekes code will telle you if a task is finished or hasn't been launched yet.
Devil259 code is little better.
If you understand both codes, you can do something ok.

fl0werD's code is the exact example of what you must NOT do.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-01-2011 at 23:41.
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-02-2011 , 00:10   Re: Check if() Task done .
Reply With Quote #9

Quote:
Originally Posted by Stressful View Post
And when its done , The "task" would stop what its doing .
When the task is done it stops what it's doing. That is the way it's designed to work. Therefore, this part of your request means nothing.

I would suggest you tell us what you are ACTUALLY trying to do as you are likely asking the wrong questions.
__________________
fysiks is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-02-2011 , 01:03   Re: Check if() Task done .
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
fl0werD's code is the exact example of what you must NOT do.
Because of using client_PreThink
Devil259 is offline
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 00:46.


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