Raised This Month: $ Target: $400
 0% 

About set_task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-11-2009 , 16:06   About set_task
Reply With Quote #1

After reading set_task's funcwiki page (and finding it pretty weird, by the way) I've got into a small question. I want to make a task that will pass a player's ID and a string as parameters.

1 - Do I have to "hide" the ID within the string's array?
2 - Is the parameter[] array internally copied in AMXX or is it kept inside Pawn for efficiency (similar to Lua)?

Thanks in advance.
vitorrd is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-11-2009 , 16:19   Re: About set_task
Reply With Quote #2

- You can, but you can pass the id as taskid too, it's fine.
- Not sure to understand, you can check yourself by looking at amxmodx.cpp and CTask.cpp.
__________________
Arkshine is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-11-2009 , 16:29   Re: About set_task
Reply With Quote #3

You do not have to hide the id in the string array. You can pass the player id as task-id and then the string by itself.
PHP Code:
public TheFuncid )
{
    new 
szMsg[] = "Hello there";

    
set_task1.0 "PrintFunc" id szMsg sizeofszMsg ) );
}

public 
PrintFuncszText[] , id )
{
    
client_printid print_chat szText );

__________________

Last edited by Bugsy; 10-11-2009 at 16:34.
Bugsy is offline
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-11-2009 , 16:57   Re: About set_task
Reply With Quote #4

Thank you, both of you. I'll have a look at the implementation (I was trying to avoid passing the player's ID as Task ID but...
vitorrd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-11-2009 , 17:21   Re: About set_task
Reply With Quote #5

Quote:
Originally Posted by vitorrd View Post
...I was trying to avoid passing the player's ID as Task ID but...
Care to explain why?

If you don't want to pass player-id as task-id (for whatever reason) you will have to 'hide' the player id in the passed array.

PHP Code:
public TheFuncid )
{
    new 
Data];
    
    
Data] = id;
    
formatexData] , "hello" );
    
    
set_task1.0 "PrintFunc" Data sizeofData ) );
}

public 
PrintFuncData[] )
{
    
client_printData] , print_chat Data] );

__________________
Bugsy is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-11-2009 , 17:21   Re: About set_task
Reply With Quote #6

Why do you want to avoid ?
__________________
Arkshine is offline
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-11-2009 , 17:45   Re: About set_task
Reply With Quote #7

I don't know, it looks like a bad practice to use internal information to hide public one.
vitorrd is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-11-2009 , 17:49   Re: About set_task
Reply With Quote #8

Not really, after all you need to pass a random number, it makes sense to pass a number related to the player's index.
__________________
Arkshine is offline
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-11-2009 , 17:56   Re: About set_task
Reply With Quote #9

Well, ok, I surrender, please don't shoot!
vitorrd is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-11-2009 , 18:08   Re: About set_task
Reply With Quote #10



Use an array if you feel like to use this way, but it will be really a pain to creat e each time when you can pass directly the index. :p
__________________
Arkshine 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 22:36.


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