AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove tasks (https://forums.alliedmods.net/showthread.php?t=54490)

mateo10 04-27-2007 15:15

Remove tasks
 
Can you do like this to remove tasks (if the player has like 3 tasks)?
Code:
new players[32], num; get_players(players, num); new player; for(new i=0;i<num;i++) {     player = players[i];     while(task_exists(player))         remove_task(player); }

ConnorMcLeod 04-27-2007 15:24

Re: Remove tasks
 
That's why you have to ad a constant number to a task :

set_task(1.0,"task1",1578+id)

set_task(1.0,"task2",2790+id)


Then you can check if each task exists.

Brad 04-27-2007 20:10

Re: Remove tasks
 
If you want all tasks associated with a player to end, you don't have to do as connorr said. You can just use their id in all of them. Then, when you remove_task, it will remove all tasks in that plugin for that id.

However, if you want finer control over each, do as connorr said.

ConnorMcLeod 04-28-2007 03:32

Re: Remove tasks
 
So, 2 tasks can have the same id at the same moment without any trouble ?

Styles 04-28-2007 03:49

Re: Remove tasks
 
they can but when u remove it you will remove both at once. I just learned this.

mateo10 04-28-2007 04:07

Re: Remove tasks
 
So my script does work?

ConnorMcLeod 04-28-2007 07:14

Re: Remove tasks
 
If you don't need to remove those tasks separatly, yes.

FPcokE 03-14-2014 07:32

Re: Remove tasks
 
Quote:

Originally Posted by ConnorMcLeod (Post 470380)
That's why you have to ad a constant number to a task :

set_task(1.0,"task1",1578+id)

set_task(1.0,"task2",2790+id)


Then you can check if each task exists.

If i set the task with the same constant number, will that override the old task or just create another task with the same number?

Anyway, how would you remove only one of those tasks?
And how will you get the id without the constant number?

YamiKaitou 03-14-2014 07:37

Re: Remove tasks
 
Quote:

Originally Posted by FPcokE (Post 2111251)
If i set the task with the same constant number, will that override the old task or just create another task with the same number?

Create a new one with the same number

Quote:

Anyway, how would you remove only one of those tasks?
If you only want to remove 1 of the tasks, then each task must have a unique number

Quote:

And how will you get the id without the constant number?
TaskID - Const = ClientID

FPcokE 03-14-2014 07:58

Re: Remove tasks
 
Quote:

Originally Posted by YamiKaitou (Post 2111253)
Create a new one with the same number


If you only want to remove 1 of the tasks, then each task must have a unique number


TaskID - Const = ClientID

Thank you for your reply, i did figure it out after a couple of tests though :P
I must remove the task before creating a new one, in order to avoid multiple tasks with the same command.


All times are GMT -4. The time now is 06:40.

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