Raised This Month: $ Target: $400
 0% 

admins.cfg to MySQL admins


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 06-21-2015 , 11:52   admins.cfg to MySQL admins
Reply With Quote #1

Super simple

Code:
public void OnPluginStart() 
{ 
	RegConsoleCmd("sm_parse", test); 
} 

public Action test(int client, int args) 
{ 
	Handle SMC = SMC_CreateParser(); 
	
	SMC_SetReaders(SMC, NewSection, KeyValue, EndSection); 
	SMC_ParseFile(SMC, "admins.cfg"); //...cstrike/file.txt or ...tf/file.txt 
	
	CloseHandle(SMC); 
	
	return Plugin_Handled; 
} 

char sname[64];
char sauth[16];
char sidentity[32];
char sflags[32];
char simmunity[10];

public SMCResult NewSection(Handle smc, const char[] name, bool opt_quotes) 
{ 
	if(!StrEqual(name, "Admins"))
	{	
		Format(sname, sizeof(sname), "%s", name);
	}
} 

public SMCResult KeyValue(Handle smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes) 
{ 
	if(StrEqual(key, "auth"))
	{
		Format(sauth, sizeof(sauth), "%s", value);
	}
	else if(StrEqual(key, "identity"))
	{
		Format(sidentity, sizeof(sidentity), "%s", value);
	}
	else if(StrEqual(key, "flags"))
	{
		Format(sflags, sizeof(sflags), "%s", value);
	}
	else if(StrEqual(key, "immunity"))
	{
		Format(simmunity, sizeof(simmunity), "%s", value);
	}
} 

public SMCResult EndSection(Handle smc) 
{ 
	PrintToServer("INSERT INTO sm_admins (name, authtype, identity, flags, immunity) VALUES ('%s', '%s', '%s', '%s', '%s');" ,sname, sauth, sidentity, sflags, simmunity); 
}
I figured someone might find it usefull
__________________
Pelipoika is offline
 



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 18:38.


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