This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Dynamic number of arguments in functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-23-2010 , 01:55   Re: Dynamic number of arguments in functions
Reply With Quote #1

For TextMsg i guess something like HLSDK would be more efficient.
Your tut is still usefull though.

PHP Code:
// Based on HLSDK ClientPrint and UTIL_ClientPrintAll from util.cpp
Util_ClientPrint(idiMsgDestszMessage[], szSubMessage1[] = ""szSubMessage2[] = ""szSubMessage3[] = ""szSubMessage4[] = "")
{
    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTg_iTextMsg, .player=id)
    {
        
write_byte(iMsgDest)
        
write_string(szMessage)
        if( 
szSubMessage1[0] )
        {
            
write_string(szSubMessage1)
        }
        if( 
szSubMessage2[0] )
        {
            
write_string(szSubMessage2)
        }
        if( 
szSubMessage3[0] )
        {
            
write_string(szSubMessage3)
        }
        if( 
szSubMessage4[0] )
        {
            
write_string(szSubMessage4)
        }
    }
    
message_end()

Code:
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 )
{
	MESSAGE_BEGIN( MSG_ONE, gmsgTextMsg, NULL, client );
		WRITE_BYTE( msg_dest );
		WRITE_STRING( msg_name );

		if ( param1 )
			WRITE_STRING( param1 );
		if ( param2 )
			WRITE_STRING( param2 );
		if ( param3 )
			WRITE_STRING( param3 );
		if ( param4 )
			WRITE_STRING( param4 );

	MESSAGE_END();
}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-23-2010 at 01:57.
ConnorMcLeod is offline
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 05:35.


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