Raised This Month: $ Target: $400
 0% 

Macros with optional arguments


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-17-2011 , 17:34   Macros with optional arguments
Reply With Quote #1

Can I make macros with optional arguments?
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-18-2011 , 13:03   Re: Macros with optional arguments
Reply With Quote #2

Give an example of what you are trying to do.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 03-18-2011 , 23:20   Re: Macros with optional arguments
Reply With Quote #3

I guess he means like get_systime or something like that, how you can put an optional offset. Or set a default value.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-19-2011 , 16:23   Re: Macros with optional arguments
Reply With Quote #4

After a quick look at the Pawn Language Guide, I was not able to find anything indicating this is possible with Pawn.

You're better off just using a function.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-19-2011 , 16:44   Re: Macros with optional arguments
Reply With Quote #5

You have to think outside the box. %1 can be more than one argument.

For Example:
Code:
stock nfv_get_data(const filename[], const key[], name[], data[]="", len=0, const identifier=';', const key_tell_start=0, &key_tell_find=0, const name_tell_start=0, &name_tell_find=0, key_copy[]="", const key_len=0, name_copy[]="", const name_len=0)
#define player_get_data(%1,%2) nfv_get_data(nfv_player_file(%1),%2)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-25-2011 , 07:48   Re: Macros with optional arguments
Reply With Quote #6

I tell about this
PHP Code:
#define set_user_money(%1,%2,%3) cs_set_user_money(%1,%2,%3)
// How not to use 3rd argument in this code
set_user_money(id16000
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-25-2011 , 15:43   Re: Macros with optional arguments
Reply With Quote #7

Code:
#define set_user_money(%1) cs_set_user_money(%1)
You don't need to do it for each argument.

You could also just do this:
Code:
#define set_user_money cs_set_user_money
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
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 07:25.


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