AlliedModders

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

liryck 03-19-2010 17:58

tasks
 
um well srry by the threat but i have another question and well the other is tutorials forums.

so lets see i have a task in the function AwesomeMenu right so when i call AwesomeMenu the task start too right?

the task is like seta told me set_task(10.0,"random_choose",menu_id)

so i want to remove that task if the player who got the menu choose an option, the right way should be remove_task(menu_id). if im right at this moment all good.

now my question is when i call again AwesomeMenu the task start again? if not how i make to started again

wrecked_ 03-19-2010 18:20

Re: tasks
 
Just call set_task in the AwesomeMenu function.

Bugsy 03-19-2010 18:24

Re: tasks
 
Quote:

Originally Posted by liryck (Post 1122728)
um well srry by the threat but i have another question and well the other is tutorials forums.

so lets see i have a task in the function AwesomeMenu right so when i call AwesomeMenu the task start too right?

the task is like seta told me set_task(10.0,"random_choose",menu_id)

so i want to remove that task if the player who got the menu choose an option, the right way should be remove_task(menu_id). if im right at this moment all good.

now my question is when i call again AwesomeMenu the task start again? if not how i make to started again

menu_id would be the task-id. Think of it as an identification number for that particular task. If this is the only usage for tasks in your plugin then you can always use the player-id as the task-id. Otherwise you will need a little extra, let me know if this is the case.

This might help:
PHP Code:

AwesomeMenuid )
{
     
showmenuid );
     
set_task10.0 "random" id );
}

MenuChooserid )
{
      
//player (id) chose something on menu
      
remove_taskid );
}

public 
randomid )
{
     
//callfunc( id );
     //get_user_health( id );
     //or w\e



Seta00 03-19-2010 18:46

Re: tasks
 
Quote:

Originally Posted by Bugsy (Post 1122755)
menu_id would be the task-id. Think of it as an identification number for that particular task. If this is the only usage for tasks in your plugin then you can always use the player-id as the task-id. Otherwise you will need a little extra, let me know if this is the case.

Exactly. Just some minor things: (see comments)
PHP Code:

AwesomeMenuid )
{
     
showmenuid );
     
set_task10.0 "random" id);
}

MenuChooserid )
{
      
//player (id) chose something on menu
      
remove_taskid );
}

public 
randomid )
{
     
//callfunc( id );
     //get_user_health( id );
     //or w\e
     
menu_destroy(id); // after randomizing an option, close the menu



liryck 03-19-2010 18:48

Re: tasks
 
basically i have something like this. when i call again awesomemenu the task will start again?

PHP Code:

AwesomeMenuid 

     new  
menu menu_create("\yChoose Player:""menu_handler");
     new 
menu_id menu
     showmenu
id ); 
     
set_task10.0 "random_choose" menu_id ); 
}

menu_handler(id,menu,item)
{
   
//this is called only if player select something so
   
remove_task(menu_id)
}

random_choose(menu)
{
 new 
ran
            ran 
random(iNum);
            
iPlayers[ran] = iPlayers[--iNum];
            
player iPlayers[ran];    

               
cs_set_user_team(playerCS_TEAM_CT)
                
get_user_name(player,name,31)
                
                
client_print(0,print_chat,"%s Fue Elegido al Azar Para CT",name)
                
count_team++
                
                
teams[player] = 1
                team 
true
                
                check_team
(); // Check What Should be Displayed in the screen By Mile_
                
check_continue(); // Check if all players was selected to continue
        
                
menu_destroy(menu)
                
set_task(5.0,"AwesomeMenu",t_cap)
                return 
PLUGIN_HANDLED;



Seta00 03-19-2010 18:53

Re: tasks
 
Yes.

But you should triple-check this code.

liryck 03-19-2010 19:11

Re: tasks
 
well this is not the whole code is a little part only i post this just like an example will try and latter put my results

Seta00 03-19-2010 19:23

Re: tasks
 
What I meant is that there are plenty of syntax/logic errors on it.

Bugsy 03-19-2010 19:42

Re: tasks
 
Quote:

Originally Posted by Seta00 (Post 1122789)
Exactly. Just some minor things: (see comments)
PHP Code:

AwesomeMenuid )
{
     
showmenuid );
     
set_task10.0 "random" id);
}

MenuChooserid )
{
      
//player (id) chose something on menu
      //remove_task( id ); // <-- not needed, as we set task for executing only once
}

public 
randomid )
{
     
//callfunc( id );
     //get_user_health( id );
     //or w\e
     
menu_destroy(id); // after randomizing an option, close the menu



Yes it is. To my knowledge he does not want random called if the user selected a menu item.

Seta00 03-19-2010 19:46

Re: tasks
 
http://forums.alliedmods.net/showthr...54#post1122818 :oops:

My bad. Edited first post. I'm definitely going sleep now.


All times are GMT -4. The time now is 08:36.

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