Raised This Month: $ Target: $400
 0% 

[SP] ConfigMap: StringMap & SMCParser


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


Thread Tools
Display Modes

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 22:51.


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