UTIL VarArgs: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
<code> | <code> | ||
int iCreepers = 3; | int iCreepers = 3; | ||
char * pFortress = "My Awesome Fort."; | char * pFortress = "My Awesome Fort."; | ||
char * pOutput = UTIL_VarArgs( "There are %i creepers outside of your %s.", iCreepers, pFortress ); | char * pOutput = UTIL_VarArgs( "There are %i creepers outside of your %s.", iCreepers, pFortress ); | ||
Msg("%s", output); | Msg("%s", output); | ||
// prints: There are 3 creepers outside of your My Awesome Fortress. | // prints: There are 3 creepers outside of your My Awesome Fortress. |
Revision as of 19:16, 11 April 2011
This function will build a C-String similar to printf. It is server-side only!
Example:
int iCreepers = 3;
char * pFortress = "My Awesome Fort.";
char * pOutput = UTIL_VarArgs( "There are %i creepers outside of your %s.", iCreepers, pFortress );
Msg("%s", output);
// prints: There are 3 creepers outside of your My Awesome Fortress.
This is useful for quickly building a composite string.
char * pOutput = UTIL_VarArgs( "X:%f Y:%f Z:%f\n", vec.x, vec.y, vec.z );