Raised This Month: $ Target: $400
 0% 

Set_task question.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-10-2013 , 15:46   Set_task question.
Reply With Quote #1

I've seen Arkshines advice and I would like to ask if my code is correct. Arkshines post:
Quote:
Originally Posted by Arkshine View Post
Add a random number after id.
Code:
set_task(0.1,"event1",id + 85447,"",0,"b")

In your function, remove this number to get the id :

Code:
public event1 ( TaskID ) {      new id = TaskID - 85447; }

And to remove the task :

Code:
remove_task( id + 85447 );


Is this correct?
PHP Code:
public client_putinserver(id)
{
    if (!
task_exists(id 1)) set_task(30.0"PrintText"id 1//Checks if task already exist, if not print text set in public PrintText
    
if (!task_exists(id 2)) set_task(600.0"AuthorText"id 2//Checks if task already exist, if not print text set in public AuthorText


Last edited by Unkolix; 02-10-2013 at 15:46.
Unkolix is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 02-10-2013 , 16:28   Re: Set_task question.
Reply With Quote #2

One question: What does id + 1 ?
Torge is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-10-2013 , 16:59   Re: Set_task question.
Reply With Quote #3

It kinda makes the task an unique id, so when you check it or remove the task you won't remove all the tasks you've coded.
Unkolix is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 02-10-2013 , 17:03   Re: Set_task question.
Reply With Quote #4

Ok, thanks, code looks very pretty.
Torge is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-10-2013 , 17:41   Re: Set_task question.
Reply With Quote #5

When using a taskid, make them already 32 numbers apart
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2013 , 17:50   Re: Set_task question.
Reply With Quote #6

Quote:
Originally Posted by YamiKaitou View Post
When using a taskid, make them already 32 numbers apart
Yes this is important to keep task-id's unique. Make each type of task have a range that will not mix with any other type of task.

This could happen:

PHP Code:
public client_putinserver(id)
{
    if (!
task_exists(id 1)) set_task(30.0"PrintText"id 1//Checks if task already exist, if not print text set in public PrintText
    
if (!task_exists(id 2)) set_task(600.0"AuthorText"id 2//Checks if task already exist, if not print text set in public AuthorText

Player id 1 task-id set at ( id + 2 ) = 1 + 2 = [3]
Player id 2 task-id set at ( id + 1 ) = 2 + 1 = [3] <- Same task-id already exists for player 1.

Try something like:

PHP Code:
const TaskPrint 5000;
const 
TaskAuthor 5100;

public 
client_putinserver(id)
{
    if (!
task_exists(id TaskPrint)) set_task(30.0"PrintText"id TaskPrint//Checks if task already exist, if not print text set in public PrintText
    
if (!task_exists(id TaskAuthor)) set_task(600.0"AuthorText"id TaskAuthor//Checks if task already exist, if not print text set in public AuthorText

__________________

Last edited by Bugsy; 02-10-2013 at 17:52.
Bugsy is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-11-2013 , 00:17   Re: Set_task question.
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Yes this is important to keep task-id's unique. Make each type of task have a range that will not mix with any other type of task.

This could happen:

PHP Code:
public client_putinserver(id)
{
    if (!
task_exists(id 1)) set_task(30.0"PrintText"id 1//Checks if task already exist, if not print text set in public PrintText
    
if (!task_exists(id 2)) set_task(600.0"AuthorText"id 2//Checks if task already exist, if not print text set in public AuthorText

Player id 1 task-id set at ( id + 2 ) = 1 + 2 = [3]
Player id 2 task-id set at ( id + 1 ) = 2 + 1 = [3] <- Same task-id already exists for player 1.

Try something like:

PHP Code:
const TaskPrint 5000;
const 
TaskAuthor 5100;

public 
client_putinserver(id)
{
    if (!
task_exists(id TaskPrint)) set_task(30.0"PrintText"id TaskPrint//Checks if task already exist, if not print text set in public PrintText
    
if (!task_exists(id TaskAuthor)) set_task(600.0"AuthorText"id TaskAuthor//Checks if task already exist, if not print text set in public AuthorText

Wow, thanks! I didn't knew that it can contain letters!
Unkolix is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2013 , 01:49   Re: Set_task question.
Reply With Quote #8

Quote:
Originally Posted by Unkolix View Post
I didn't knew that it can contain letters!
What in the world does that mean? Bugsy didn't post anything about using "letters" anywhere.
__________________
fysiks is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 02-11-2013 , 08:35   Re: Set_task question.
Reply With Quote #9

Quote:
Wow, thanks! I didn't knew that it can contain letters!
He's using a constant. At compile time, this effectively becomes:
Code:
if (!task_exists(id + 5000)) set_task(30.0, "PrintText", id + 5000) if (!task_exists(id + 5100)) set_task(600.0, "AuthorText", id + 5100)

Last edited by Backstabnoob; 02-11-2013 at 08:35.
Backstabnoob 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 20:35.


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