AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin to Admin Sql (https://forums.alliedmods.net/showthread.php?t=153692)

fmfs10 03-27-2011 16:34

Admin to Admin Sql
 
Hello! I created a script to take all the admins from my servers that are in users.ini and add it to my sql db. It worked, the problem was that from a determined point of the file, the server just restarts. I just erase a part of the file that already was read, and it worked. But I want to know. Why the server restarts from a determined point?

Here is the script:

PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    
register_plugin("ADD ADMIN SQL""1.0""KoN")
    
}

public 
plugin_cfg() {
    
    new 
configs_dir[64]
    
get_configsdir(configs_dir,charsmax(configs_dir))
    
    new 
adminpath[100]
    
formatex(adminpath99"%s/users.ini"configs_dir)
    
    new 
File=fopen(adminpath,"r");
    
    if (
File)
    {
        new 
Text[512];
        new 
Flags[32];
        new 
Access[32]
        new 
AuthData[44];
        new 
Password[32];
        
        while (!
feof(File))
        {
            
fgets(File,Text,sizeof(Text)-1);
            
            
trim(Text);
            
            
// comment
            
if (Text[0]==';' || Text[0]=='/' || Text[0]==' '
            {
                continue;
            }
            
            
Flags[0]=0;
            
Access[0]=0;
            
AuthData[0]=0;
            
Password[0]=0;
            
            
// not enough parameters
            
if (parse(Text,AuthData,sizeof(AuthData)-1,Password,sizeof(Password)-1,Access,sizeof(Access)-1,Flags,sizeof(Flags)-1) < 2)
            {
                continue;
            }
            
            
server_cmd("amx_addadmin ^"%s^" ^"%s^" ^"%s^" name"AuthDataAccessPassword)
            
//server_cmd("amx_addadmin ^"%s^" ^"%s^" ^"%s^" steamid", AuthData, Access, Password)
        
}
        
        
fclose(File);
    }



lucas_7_94 03-27-2011 23:26

Re: Admin to Admin Sql
 
The plugin doesn't have sence , you open a ini , and you never uses it.

fmfs10 03-28-2011 12:20

Re: Admin to Admin Sql
 
It's has a sense, and it worked for me... lol
The only problem was that from a determined line, it was restarting server.

As I'm migrating from normal Admin style to Admin SQL style, I did this plugin to read from the users.ini and automatically add admin so it is a lot faster for me, as I have a lot of admins from my server and I don't want to add one per one in my SQL database :)


All times are GMT -4. The time now is 14:30.

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