Raised This Month: $ Target: $400
 0% 

.ini writing dont works :/


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-02-2013 , 17:20   Re: .ini writing dont works :/
Reply With Quote #1

Try
Code:
/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <amxmisc> 
#include <celltrie> 

#define PLUGIN "Ban by Name e ip" 
#define VERSION "1.0" 
#define AUTHOR "Roccoxx + rak(code del .ini)" 

new Trie:g_trie 
const ADMIN_FLAG = ADMIN_BAN // acceso al menu de ban 
new g_maxplayers 
public plugin_init() { 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
     
    g_trie = TrieCreate( ) 
    g_maxplayers = get_maxplayers() 
    register_clcmd("say /banmm", "show_menu_banear_jugador") 
} 

public plugin_cfg() { 
    new ConfigDir[256] 
     
    get_configsdir(ConfigDir, charsmax(ConfigDir)) 
     
    format(ConfigDir, charsmax(ConfigDir), "%s/amx_banbyroccoxx.ini", ConfigDir)  
     
    if(!file_exists(ConfigDir)) 
	{
     
		new Data[1024], File;
		create_file(File,ConfigDir)
		while (!feof(File)) { 
         
			fgets(File, Data, charsmax(Data)) 
         
			trim(Data) 
         
			if (Data[0] == ';' || !Data[0])  
				continue; 
         
			rak_remove_quotes(Data) 
         
			TrieSetCell(g_trie,Data,1)  
		}
    } 
     
    fclose(File) 
} 

create_file(File,ConfigDir[]) { 
     
    File = fopen(ConfigDir, "wt") 
     
    fprintf(File, "; Lista de pts baneados^n; File location: $moddir/addons/amxmodx/configs/amx_banbyroccoxx.ini^n^n;Enjoy") 
     
    fclose(File) 
} 

public plugin_end( )  
{  
    TrieDestroy( g_trie )  
}  

public client_connect(id){ 
    new name[32], ip[40] 
    get_user_name(id, name, charsmax(name)) 
    get_user_ip(id, ip, charsmax(ip)) 
     
    if(TrieKeyExists(g_trie, name) || TrieKeyExists(g_trie, name)){ 
        server_cmd("kick %s", name) 
    } 
} 

public show_menu_banear_jugador(id){ 
    static flags; flags = get_user_flags(id) 
    if(flags & ADMIN_FLAG){ 
        new menu = menu_create("Menu banear hacks", "banear_jugador") 
        new pos[3], name[32] 
        for(new i = 1; i <= g_maxplayers; i++){ 
            if(is_user_connected(i)){ 
                get_user_name(i, name, charsmax(name)) 
                num_to_str(i, pos, charsmax(pos)) 
                menu_additem(menu, name, pos) 
            } 
        } 
     
        menu_display(id, menu, 0) 
    } 
    else{ 
        client_print(id, print_chat, "No tienes acceso") 
    } 
     
    return PLUGIN_HANDLED 
} 

public banear_jugador(id, menu, item){ 
    if(item == MENU_EXIT || !is_user_connected(id)){ 
        menu_destroy(menu) 
        return PLUGIN_HANDLED 
    } 
     
    new iData[6]; 
    new iAccess; 
    new ip[40] 
    new iCallback; 
    new iName[64]; 
    new name[33] 
    get_user_name(id, name, charsmax(name)) 
    menu_item_getinfo(menu, item, iAccess, iData, 5, iName, 63, iCallback) 
    new iTarget = str_to_num(iData); 
    get_user_ip(iTarget, ip, charsmax(ip)) 
    TrieSetCell(g_trie, iName, 1) 
    TrieSetCell(g_trie, ip, 1) 
    aniadir_ini(iName) 
    aniadir_ini(ip) 
    server_cmd("kick %s", iName) 
    client_print(0, print_chat, "%s ha sido baneado por el admin %s", iName, name) 
     
    menu_destroy(menu) 
    return PLUGIN_HANDLED 
} 

public aniadir_ini(const nombre[]){     
    new ConfigDir[256] 
     
    get_configsdir(ConfigDir, charsmax(ConfigDir)) 
     
    format(ConfigDir, charsmax(ConfigDir), "%s/amx_banbyroccoxx.ini", ConfigDir)  
     
    new File, Line, Data[1024] 
     
    File = fopen(ConfigDir , "rt") 
     
    while(!feof(File)) { 
         
        fgets(File, Data, charsmax(Data)) 
         
        trim(Data) 
         
        Line++  
         
        if (Data[0] == ';' || !Data[0]) 
            continue; 
             
        write_file(ConfigDir, nombre, Line - 1)  
         
        break; 
    } 
     
    fclose(File) 
} 

stock rak_remove_quotes(Args[]) { 
     
    static n 
     
    if(!Args[0]) 
        return 
    else if(Args[0] == 34) { 
         
        for(n = 1;/* nothing */; n++) { 
             
            if(!Args[n] || Args[n] == 34 && !Args[n+1]) { 
                 
                Args[n] = 0 
                 
                break; 
                 
            } 
             
            Args[n-1] = Args[n] 
             
        } 
    } 
    else { 
         
        for(n = 1;/* nothing */; n++) { 
             
            if(!Args[n] || Args[n] == 34 && !Args[n+1]) { 
                 
                Args[n] = 0 
                 
                break; 
                 
            } 
        }     
    } 
}

Last edited by TheDS1337; 06-02-2013 at 17:21.
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-03-2013 , 00:25   Re: .ini writing dont works :/
Reply With Quote #2

Quote:
Originally Posted by DeagLe.Studio View Post
Try
FYI, your changes made it worse.

The problem is likely because of mixing the old (should never be used) file natives with the new (should be used instead) ones.
__________________
fysiks is offline
Reply



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 16:27.


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