AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Does set_task remove already set one? (https://forums.alliedmods.net/showthread.php?t=293973)

siriusmd99 02-16-2017 12:14

Does set_task remove already set one?
 
I forget something about set_task. If i set a task with a specified id and then i set another one with the same id then set_task will remove the previous one or i must check with task_exists manually to remove the task and then set the new one?

Black Rose 02-16-2017 12:21

Re: Does set_task remove already set one?
 
It will not remove the previous one. You always have to remove it manually.

siriusmd99 02-16-2017 13:18

Re: Does set_task remove already set one?
 
Quote:

Originally Posted by Black Rose (Post 2495887)
It will not remove the previous one. You always have to remove it manually.

Sure? I heard the opossite once in a post from a mod but i don't remember where.
He said that native set_task has the check for already present task.

OciXCrom 02-16-2017 13:58

Re: Does set_task remove already set one?
 
Totally not true. If that was the case - you wouldn't be able to create more than one task for one player.

PRoSToTeM@ 02-16-2017 14:13

Re: Does set_task remove already set one?
 
PHP Code:

    register_clcmd("say /tt""Tt");
}

public 
Tt(player) {
    
set_task(5.0"Dd"player);
}

public 
Dd(player) {
    
client_print(playerprint_chat"!!!");


It prints message two times if I type to chat "/tt" two times almost at once.

siriusmd99 02-17-2017 09:14

Re: Does set_task remove already set one?
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2495940)
PHP Code:

    register_clcmd("say /tt""Tt");
}

public 
Tt(player) {
    
set_task(5.0"Dd"player);
}

public 
Dd(player) {
    
client_print(playerprint_chat"!!!");


It prints message two times if I type to chat "/tt" two times almost at once.

Thanks.

PRoSToTeM@ 02-17-2017 09:36

Re: Does set_task remove already set one?
 
And also /rem removes both tasks.
PHP Code:

    register_clcmd("say /add""Add");
    
register_clcmd("say /rem""Rem");
}

public 
Add(player) {
    
set_task(5.0"Show"player);
}

public 
Rem(player) {
    
remove_task(player);
}

public 
Show(player) {
    
client_print(playerprint_chat"!!!");



klippy 02-17-2017 13:02

Re: Does set_task remove already set one?
 
Quote:

Originally Posted by siriusmd99 (Post 2495907)
Sure? I heard the opossite once in a post from a mod but i don't remember where.
He said that native set_task has the check for already present task.

They probably said that remove_task() has the check, so you don't have to check if a task exists before you remove it.


All times are GMT -4. The time now is 21:02.

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