View Single Post
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-19-2021 , 14:17   Re: [TUT] SourcePawn Scripting - Tips, Basics to Advanced
Reply With Quote #48

You can also mention the "stringize" operator (inherited from Pawn) which converts arguments to packed strings in a macro.
I don't find it that useful but still here's an example:
Code:
// Note that spaces inside parentheses count too!!! STRINGIZE( abc123 ) = " abc123 "
#define STRINGIZE(%0) #%0

ConVar myplugin_enabled; // typical toggle convar

Action ServerCmd_DoStuff(int args) {
	if ( !myplugin_enabled.BoolValue ) {
		PrintToServer( "Plugin is disabled! " ... STRINGIZE(myplugin_enabled) ... " = 0" ); // "Plugin is disabled! myplugin_enabled = 0"
		return Plugin_Handled;
	}

	// ...

	return Plugin_Handled;
}
__________________
MAGNAT2645 is offline