/* Please don't use this plugin */
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "[ANY] Admin Remover",
description = "Removes a line from admins_simple.ini",
author = "Headline",
version = "1.0",
url = "http://colosseum-gaming.com"
};
public void OnPluginStart()
{
RegAdminCmd("sm_removeadmin", Command_RemoveAdmin, ADMFLAG_ROOT, "Removes an admin from admins_simple.ini");
}
public Action Command_RemoveAdmin(int client, int args)
{
if (args != 1)
{
ReplyToCommand(client, "[SM] usage : sm_removeadmin <STEAM_X:Y:ZZZZZZ>");
return Plugin_Handled;
}
char sArg1[128];
GetCmdArg(1, sArg1, sizeof(sArg1));
if (StrContains(sArg1, "STEAM_") == -1)
{
ReplyToCommand(client, "[SM] usage : sm_removeadmin <STEAM_X:Y:ZZZZZZ>");
return Plugin_Handled;
}
if (RemoveEntryFromFile(sArg1, "admin_simple.ini"))
{
ReplyToCommand(client, "[SM] Admin %s has been deleted!", sArg1);
}
else
{
ReplyToCommand(client, "[SM] No such admin existed!", sArg1);
}
return Plugin_Handled;
}
/* returns true if found */
bool RemoveEntryFromFile(const char[] sSearch, const char[] fileName)
{
char sLine[128], path[PLATFORM_MAX_PATH];
ArrayList array;
File hFile;
bool found;
BuildPath(Path_SM, path, sizeof(path), "addons/sourcemod/configs/%s", fileName);
hFile = OpenFile(path, "r");
found = false;
array.Clear();
while (!hFile.EndOfFile() && hFile.ReadLine(sLine, sizeof(sLine)))
{
if(StrContains(sLine, sSearch) == -1)
{
array.PushString(sLine);
}
else
{
found = true;
}
}
hFile = OpenFile(path, "w");
for (int i = 0; i < array.Length; i++)
{
array.GetString(i, sLine, sizeof(sLine));
hFile.WriteLine(sLine);
}
delete array;
return found;
}
|