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

[TUT/INFO] set_tasks: when they are and when they aren't necessary


Post New Thread Reply   
 
Thread Tools Display Modes
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 11-03-2014 , 09:59   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #61

hey guys i saw 2 different plugins using set_task(2.0, "asfasf", _,_,_, b) and set_task(2.0, "asfasf", _,_, b)
So i wanna know whats the difference between both those. (actually the "_" )
__________________
You will find everything u need :-

Last edited by Catastrophe; 11-03-2014 at 10:00.
Catastrophe is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-03-2014 , 10:46   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #62

_ mean that the param it's empty, when you don't need it. Now use at the set_task native on the wiki and find out the difference.
__________________

Last edited by HamletEagle; 11-03-2014 at 10:46.
HamletEagle is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-03-2014 , 10:51   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #63

_ actually means to use the default value and it only works with functions that define a default value for a parameter
__________________
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
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 11-03-2014 , 23:49   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #64

ok so the params after the function are id, params, len, flags, repeat. so im guessing _, _, _, "b" will take id, params, len as default ones and _, _, "b" will take params, len as default so ill have to supply some id before the first "_" , am i correct here ?
__________________
You will find everything u need :-
Catastrophe is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-04-2014 , 12:21   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #65

This is how the function is declared
Code:
native set_task(Float:time, const function[], id=0, const parameter[]="", len=0, const flags[]="", repeat=0);
So this code block
Code:
set_task(1.0, "taskExecute", 43049, _, _, "b");
is basically the same thing as
Code:
set_task(1.0, "taskExecute", 43049, "", 0, "b");
Using _ is just an indication that says "I don't care about this parameter, so use the default value". This only works for functions that define default values for parameters.
__________________
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
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 11-05-2014 , 09:53   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #66

Lol nice example thnx man.. ;)
__________________
You will find everything u need :-
Catastrophe is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-05-2014 , 10:40   Re: [TUT/INFO] set_tasks: when they are and when they aren't necessary
Reply With Quote #67

You can see and do this by expliciting the param name, only if previous params are optional as well:
Code:
set_task(1.0, "taskExecute", 43049, .flag = "b");
__________________
Arkshine 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 08:33.


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