View Single Post
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 09-27-2020 , 02:34   Re: [SP] ConfigMap: StringMap & SMCParser
Reply With Quote #7

I have this stock:
Code:
#define _BOOL(%1) view_as< bool >( %1 )

stock bool StringToBool(const char[] str, bool simple=true) {
	if ( simple )
		return _BOOL( StringToInt( str ) );

	if ( strcmp( str, "true", false ) == 0 || strcmp( str, "yes", false ) == 0 || strcmp( str , "on", false ) == 0 || str[0] == '1' )
		return true;

	return false;
}
Sometimes i use words like "true" in my configs, sometimes only "0" and "1". You can use same method if you want.
__________________

Last edited by MAGNAT2645; 09-27-2020 at 02:37. Reason: Added _BOOL define
MAGNAT2645 is offline