Raised This Month: $32 Target: $400
 8% 

admins.cfg to MySQL admins


Post New Thread Reply   
 
Thread Tools Display Modes
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
404UserNotFound
BANNED
Join Date: Dec 2011
Old 06-22-2015 , 20:10   Re: admins.cfg to MySQL admins
Reply With Quote #2

I sure will find this useful.

All I gotta do is convert my admins_simple.ini over to admins.cfg, then use this, then recode this to make a custom "sm_adddonator" command that adds new people to the MySQL admins database and refreshes it.
404UserNotFound is offline
Reply


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


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