Raised This Month: $ Target: $400
 0% 

Method Parameters


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Minimum
Senior Member
Join Date: Jun 2006
Old 12-26-2007 , 19:28   Method Parameters
Reply With Quote #1

I noticed with methods such as server_print that there is this parameter at the end described as "any:...". I was wondering if I could put this into any methods I make. I tried just passing a string in and I was met with an error saying the string is incorrectly formatted. This error occurred on the line with server_print. Code:

Code:
public printMsg(const message[],any:...) {      server_print(message);     return PLUGIN_CONTINUE; }

Code:
new name[32] = "SchmoSalt"; printMsg("Your name is %s.",name);
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-26-2007 , 19:48   Re: Method Parameters
Reply With Quote #2

Well ,in you example, it should be enough :

Code:
new name[32] = "SchmoSalt"; server_print( "Your name is %s.", name );

Anyway, you have to use vformat() to get parameters. Something like:

Code:
my_function( id ) {     new name[32] = "SchmoSalt";     printMsg( id, "Your name is %s.", name ); } printMsg( id, const sMsg[], any:... ) {     static sNew_msg[191];     vformat( sNew_msg, charsmax( sNew_msg ), sMsg, 3 );         client_print( id, print_chat, sNew_msg ); }
__________________
Arkshine is offline
Minimum
Senior Member
Join Date: Jun 2006
Old 12-26-2007 , 19:54   Re: Method Parameters
Reply With Quote #3

That works flawlessly. Thanks for the quick and accurate reply!

+karma for you.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
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 11:08.


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