AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using remove_task() without check with task_exists() (https://forums.alliedmods.net/showthread.php?t=168808)

Flipper_SPb 10-04-2011 09:14

Using remove_task() without check with task_exists()
 
Is it correct? (task may be missing.)

Arkshine 10-04-2011 09:21

Re: Using remove_task() without check with task_exists()
 
No, it's fine. No need to check, you can remove directly.

Flipper_SPb 10-04-2011 10:19

Re: Using remove_task() without check with task_exists()
 
Thank you.

^SmileY 10-04-2011 18:05

Re: Using remove_task() without check with task_exists()
 
Only check if you need to check if task is run :)

Xellath 10-05-2011 11:31

Re: Using remove_task() without check with task_exists()
 
Quote:

Originally Posted by ^SmileY (Post 1568524)
Only check if you need to check if task is run :)

There is no reason why you should check if the task exists and then removing it. Removing it straight away (even though it doesn't necessarily exist) is more efficient.

ConnorMcLeod 10-05-2011 12:01

Re: Using remove_task() without check with task_exists()
 
Quote:

Originally Posted by Xellath (Post 1568830)
There is no reason why you should check if the task exists and then removing it. Removing it straight away (even though it doesn't necessarily exist) is more efficient.

You may want to know if a task is running ;)

Xellath 10-05-2011 13:35

Re: Using remove_task() without check with task_exists()
 
Quote:

Originally Posted by ConnorMcLeod (Post 1568844)
You may want to know if a task is running ;)

Yes, of course. But there is no reason to check whether it exists or not IF you're going to remove it.

Arkshine 10-05-2011 13:37

Re: Using remove_task() without check with task_exists()
 
You know he has been already answered 2 times. You simply did not understand ^SmileY's post. He was talking about checking only.

Xellath 10-05-2011 13:58

Re: Using remove_task() without check with task_exists()
 
I must have misread, his statement is correct. My bad.

^SmileY 10-05-2011 13:59

Re: Using remove_task() without check with task_exists()
 
Quote:

Originally Posted by Arkshine (Post 1568894)
You know he has been already answered 2 times. You simply did not understand ^SmileY's post. He was talking about checking only.

PHP Code:

public func(Client)
{
    if(
task_exists(Client))
    {
        
client_print(Client,3,"Your Task is running!!");

        
remove_task(Client);
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(Client,3,"Your Task is  not running!!");
        return 
PLUGIN_HANDLED;
    }
     return 
PLUGIN_HANDLED;


Only for display a message for example, if you try to remove without any message or check, only remove :3

PHP Code:

public remove(Clientremove_task(Client); 



All times are GMT -4. The time now is 19:34.

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