Raised This Month: $12 Target: $400
 3% 

set_task parameter confusion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 09-15-2022 , 00:54   set_task parameter confusion
Reply With Quote #1

Suppose I have a function that requires an integer as a parameter.

PHP Code:
public Pause(const iSeconds)
{
//blablabla

How would I set a task that passes an integer?

PHP Code:
set_task(1.0"Pause"_my_variable_
results into ->>
PHP Code:
ERROR [112]: argument type mismatch (argument 4
Might be an extremely dumb question, but I couldn't figure it out for the life of me so I just made another function that called my other function with the parameter I wanted... needless to say it is extremely scuffed so hopefully someone can help me understand it ( I tried searching but none of the previous questions answered mine )
__________________

Last edited by deprale; 09-15-2022 at 00:55.
deprale is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-15-2022 , 01:32   Re: set_task parameter confusion
Reply With Quote #2

This is the easiest way

PHP Code:
set_task(1.0"Pause"my_variable
However, this also sets the task ID to this value so it depends on if you need to reference the task later or if you have other tasks that have the same ID.

The data parameter is treated like a string so there are ways to use it but if you can get away with just using the ID then that should work just fine.
__________________

Last edited by fysiks; 09-15-2022 at 01:33.
fysiks is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 09-15-2022 , 02:22   Re: set_task parameter confusion
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
This is the easiest way

PHP Code:
set_task(1.0"Pause"my_variable
However, this also sets the task ID to this value so it depends on if you need to reference the task later or if you have other tasks that have the same ID.

The data parameter is treated like a string so there are ways to use it but if you can get away with just using the ID then that should work just fine.
Yeah, I was actually trying not to use it like this thinking it's the wrong way to use it - whatever works I guess.
__________________
deprale is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-15-2022 , 04:21   Re: set_task parameter confusion
Reply With Quote #4

If you want to use the "parameter" then it should be like this

PHP Code:
new iArgs ];
iArgs ] = iSeconds;

set_task1.0"Pause"_iArgs sizeofiArgs )); 
and the fuction would be like this
PHP Code:
public Pause(iParams[])
{
new 
seconds iParams[0];
//blablabla

__________________
My plugin:

Last edited by Celena Luna; 09-15-2022 at 04:22.
Celena Luna is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 09-15-2022 , 04:50   Re: set_task parameter confusion
Reply With Quote #5

Quote:
Originally Posted by Celena Luna View Post
If you want to use the "parameter" then it should be like this

PHP Code:
new iArgs ];
iArgs ] = iSeconds;

set_task1.0"Pause"_iArgs sizeofiArgs )); 
and the fuction would be like this
PHP Code:
public Pause(iParams[])
{
new 
seconds iParams[0];
//blablabla

Thanks
__________________
deprale is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-15-2022 , 07:37   Re: set_task parameter confusion
Reply With Quote #6

You can also use enumerations helps with the readibilty...

PHP Code:
enum FUNC_PARAMS
{
    
FP_ID,
    
FP_TIME
}

new 
aParams[FUNC_PARAMS]
set_task(1.0"task_function"0aParamssizeof aParams);

public 
task_function(aParams[FUNC_PARAMS])
{
    new 
seconds aParams[FP_TIME]

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-15-2022 , 22:12   Re: set_task parameter confusion
Reply With Quote #7

If you want to pass a task ID and array of data

PHP Code:
new arrData] = { 33 44 55 };
new 
iTaskID 3434434;
    
set_task1.0 "TaskFunc" iTaskID arrData sizeofarrData ) );

public 
TaskFunc( const arrData] , iTaskID )
{
    

__________________
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 09-16-2022 , 08:35   Re: set_task parameter confusion
Reply With Quote #8

num_to_str pre-task then str_to_num post-task when doing a single number for pause. Showing the actual code is beneficial so one gets apropos answer for the case.

Quote:
Originally Posted by deprale View Post
Suppose I have a function that requires an integer as a parameter.

PHP Code:
public Pause(const iSeconds)
{
//blablabla

How would I set a task that passes an integer?

PHP Code:
set_task(1.0"Pause"_my_variable_
results into ->>
PHP Code:
ERROR [112]: argument type mismatch (argument 4
Might be an extremely dumb question, but I couldn't figure it out for the life of me so I just made another function that called my other function with the parameter I wanted... needless to say it is extremely scuffed so hopefully someone can help me understand it ( I tried searching but none of the previous questions answered mine )
__________________

Last edited by DJEarthQuake; 09-16-2022 at 08:37.
DJEarthQuake is offline
Reply


Thread Tools
Display Modes

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 05:17.


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