Raised This Month: $ Target: $400
 0% 

Does set_task remove already set one?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-16-2017 , 12:14   Does set_task remove already set one?
Reply With Quote #1

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?

Last edited by siriusmd99; 02-16-2017 at 12:16.
siriusmd99 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-16-2017 , 12:21   Re: Does set_task remove already set one?
Reply With Quote #2

It will not remove the previous one. You always have to remove it manually.
__________________
Black Rose is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-16-2017 , 13:18   Re: Does set_task remove already set one?
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
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.
siriusmd99 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-16-2017 , 13:58   Re: Does set_task remove already set one?
Reply With Quote #4

Totally not true. If that was the case - you wouldn't be able to create more than one task for one player.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-16-2017 , 14:13   Re: Does set_task remove already set one?
Reply With Quote #5

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.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-17-2017 , 09:14   Re: Does set_task remove already set one?
Reply With Quote #6

Quote:
Originally Posted by PRoSToTeM@ View Post
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.
siriusmd99 is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-17-2017 , 09:36   Re: Does set_task remove already set one?
Reply With Quote #7

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"!!!");

__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-17-2017 , 13:02   Re: Does set_task remove already set one?
Reply With Quote #8

Quote:
Originally Posted by siriusmd99 View Post
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.
klippy 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 21:02.


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