Raised This Month: $ Target: $400
 0% 

tasks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 03-19-2010 , 17:58   tasks
Reply With Quote #1

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
liryck is offline
Send a message via MSN to liryck
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-19-2010 , 18:20   Re: tasks
Reply With Quote #2

Just call set_task in the AwesomeMenu function.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-19-2010 , 18:24   Re: tasks
Reply With Quote #3

Quote:
Originally Posted by liryck View Post
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

__________________
Bugsy is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-19-2010 , 18:46   Re: tasks
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
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


Last edited by Seta00; 03-19-2010 at 19:45.
Seta00 is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 03-19-2010 , 18:48   Re: tasks
Reply With Quote #5

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;

liryck is offline
Send a message via MSN to liryck
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-19-2010 , 18:53   Re: tasks
Reply With Quote #6

Yes.

But you should triple-check this code.

Last edited by Seta00; 03-19-2010 at 19:07.
Seta00 is offline
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 03-19-2010 , 19:11   Re: tasks
Reply With Quote #7

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
liryck is offline
Send a message via MSN to liryck
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-19-2010 , 19:23   Re: tasks
Reply With Quote #8

What I meant is that there are plenty of syntax/logic errors on it.
Seta00 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-19-2010 , 19:42   Re: tasks
Reply With Quote #9

Quote:
Originally Posted by Seta00 View Post
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.
__________________
Bugsy is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-19-2010 , 19:46   Re: tasks
Reply With Quote #10

http://forums.alliedmods.net/showthr...54#post1122818

My bad. Edited first post. I'm definitely going sleep now.
Seta00 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 08:36.


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