Raised This Month: $64 Target: $400
 16% 

Need find steamid and remove in admin simple


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Swolly
Member
Join Date: Jul 2018
Old 11-08-2018 , 11:39   Need find steamid and remove in admin simple
Reply With Quote #1

Need find steamid and remove in admin simple

I find a post but not working.
Post: https://forums.alliedmods.net/showthread.php?t=288353

Help me please, I want to delete steam id from admin simple file
Swolly is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-08-2018 , 11:45   Re: Need find steamid and remove in admin simple
Reply With Quote #2

Quote:
Originally Posted by Swolly View Post
Need find steamid and remove in admin simple

I find a post but not working.
Post: https://forums.alliedmods.net/showthread.php?t=288353

Help me please, I want to delete steam id from admin simple file
if you can upload plugin why can't you use a ftp and just edit the file?
__________________
8guawong is offline
Swolly
Member
Join Date: Jul 2018
Old 11-08-2018 , 11:51   Re: Need find steamid and remove in admin simple
Reply With Quote #3

/* 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;
}
Swolly 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:05.


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