Raised This Month: $ Target: $400
 0% 

New file natives...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-28-2007 , 23:38   New file natives...
Reply With Quote #1

Well Emp has gotten me this far with new file natives, but we are having a problem getting the semi-colon to the beginning of the line. Currently it is just added to the end of the line.

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Remove admins"
#define VERSION "0.1"
#define AUTHOR "SweatyBanana"

enum{TYPE_STEAM, TYPE_NAME}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("amx_removeadmin","remove_cmd",ADMIN_RCON,"amx_removeadmin <steamid or nick>");
}

public remove_cmd(id,level,cid)
{
    if( !(get_user_flags(id)&ADMIN_RCON) )
        return PLUGIN_HANDLED;

    new players[32], inum, i, player;
    new TARGET[32], playerinfo[32];
    new command_type;
    
    get_players(players,inum);
    
    read_argv(1,TARGET,31);
    remove_quotes(TARGET);

    if( equal(TARGET, "STEAM_", 6) )
    {
        command_type = TYPE_STEAM;

        for(i = 0; i < inum; i++)
        {
            player = players[i];
            
            get_user_authid(player, playerinfo, 31);
            
            if( equal(playerinfo, TARGET) )
            {
                remove_user_flags(player);
                break;
            }
        }
    }
    else
    {
        command_type = TYPE_NAME;

        for(i = 0; i < inum; i++)
        {
            player = players[i];
            
            get_user_name(player, playerinfo, 31);
            if( containi(playerinfo,TARGET) != -1 )
            {
                remove_user_flags(player);
                break;
            }
        }
    }
    
    new filename[64], text[51];
    get_configsdir(filename, 63);
    format(filename, 63, "%s/users.ini", filename);

    new file = fopen(filename, "a+");

    while(!feof(file))
    {
        fgets(file, text, 50);

        if( text[0] == ';')
            continue;

        parse( text, playerinfo, 31, text, 1);

        if( ( command_type == TYPE_STEAM && equal(playerinfo, TARGET))
        || ( command_type == TYPE_NAME && containi(playerinfo, TARGET) != -1) )
        {
            //need to rewind to the begining of this line somehow...
            fputs(file,    ";");

            console_print(id,"********************ADMIN ID REMOVAL TOOL**************");
            console_print(id,"");
            console_print(id," The target, %s, was removed from users.ini ",TARGET);
            console_print(id,"");
            console_print(id,"********************ADMIN ID REMOVAL TOOL**************");

            break;
        }
    }

    fclose(file);

    return PLUGIN_HANDLED;
}

Last edited by SweatyBanana; 05-28-2007 at 23:42.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
 


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


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