AlliedModders

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

vitorrd 10-11-2009 16:06

About set_task
 
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.

Arkshine 10-11-2009 16:19

Re: About set_task
 
- 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.

Bugsy 10-11-2009 16:29

Re: About set_task
 
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 );



vitorrd 10-11-2009 16:57

Re: About set_task
 
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...

Bugsy 10-11-2009 17:21

Re: About set_task
 
Quote:

Originally Posted by vitorrd (Post 959007)
...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] );



Arkshine 10-11-2009 17:21

Re: About set_task
 
Why do you want to avoid ?

vitorrd 10-11-2009 17:45

Re: About set_task
 
I don't know, it looks like a bad practice to use internal information to hide public one.

Arkshine 10-11-2009 17:49

Re: About set_task
 
Not really, after all you need to pass a random number, it makes sense to pass a number related to the player's index.

vitorrd 10-11-2009 17:56

Re: About set_task
 
Well, ok, I surrender, please don't shoot!

Arkshine 10-11-2009 18:08

Re: About set_task
 
:twisted:

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


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

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