AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can anyone change this sql plugin to non sql. (https://forums.alliedmods.net/showthread.php?t=143153)

GarbageBox 11-15-2010 05:41

Can anyone change this sql plugin to non sql.
 
Here is the sql version, I dont know how to change to be a non sql version.
Can sb help me to change it.
I want save the stuff in amxmodx\data.
Code:

//-----------------// Funname
new fun_name[33][32];
new steam_id[33][35];
//-----------------// Funname


// Funname System
register_cvar("amx_funname","0");                                                // Enable/Disable Funname System
register_cvar("amx_funname_save","0");                                        // Enable/Disable Funname Save System


// Funname System
setting_funname                                = get_cvar_num("amx_funname");                                // Enable/Disable Funname System
setting_funname_save                = get_cvar_num("amx_funname_save");                        // Enable/Disable Funname Save System


register_clcmd("say","allchat")






public client_putinserver(id)
{
        if(setting_sqlserver_open && setting_funname && setting_funname_save)
        {
                sql_load_data(id)
        }
        return PLUGIN_CONTINUE
}


public sql_load_data(id)
{
        new NetAddr[32]
        get_user_ip(id, NetAddr, 31, 1)

        new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
        new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
       
        get_user_authid(id, steam_id[id], 34)
        if(equal(steam_id[id],"VALVE_ID_LAN"))
        {
                new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE name_ip= '%s';",hkcs_tab,NetAddr);
                SQL_Execute(hkcs_query_acc)
                       
                if(SQL_NumResults(hkcs_query_acc))
                {
                        SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30)                // Set Funname
                }
                else
                if(!SQL_NumResults(hkcs_query_acc))
                {
                        new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`name_ip`,`name`) VALUES ('%s','%s');",hkcs_tab,NetAddr,default_name);
                        SQL_Execute(query)                        // Set Up Funaname
                        format(fun_name[id], 12, "%s",default_name)
                }
        }
        else
        {
                new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE steam_id= '%s';",hkcs_tab,steam_id[id]);
                SQL_Execute(hkcs_query_acc)
                       
                if(SQL_NumResults(hkcs_query_acc))
                {
                        SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30)
                }
                else
                if(!SQL_NumResults(hkcs_query_acc))
                {
                        new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`steam_id`,`name_ip`) VALUES ('%s','%s');",hkcs_tab,steam_id[id],NetAddr);
                        SQL_Execute(query)
                        format(fun_name[id], 12, "%s",default_name)
                }
        }
        SQL_FreeHandle(hkcs_sql)
}


public allchat(id)
{
        if(!is_user_connected(id))
        {
                return PLUGIN_HANDLED
        }
        new system_msg[150]       
        new all_msg[200]
        new name[32]
        get_user_name(id, name, 31)
       
        read_args(all_msg, 200)
        remove_quotes(all_msg)

        replace_all(all_msg, 200, "%", "%")
        format(all_msg, 200, " %s", all_msg)                        // Get Say Message

        new check_name[32]
        new send_msg[192],get_msg[256]
        format(get_msg, 200, "%s", all_msg)                        // Copy Message
        strtok(get_msg[1],check_name,30,send_msg,170,' ')        // Separate Message

        if(containi(check_name,"/fun_name") != -1 && setting_funname)
        {
                if(!send_msg[0])
                {
                        format(system_msg, 149, "%s^x04 Funname must long than 1 word", setting_plugin_name)
                        client_color(id, id, system_msg)
                        return PLUGIN_HANDLED
                }
                new fun_len = strlen(send_msg);
                if(fun_len > 15)
                {
                        format(system_msg, 149, "%s^x04 Funname must less then 15 words", setting_plugin_name)
                        client_color(id, id, system_msg)
                        return PLUGIN_HANDLED
                }
                format(fun_name[id], 30, "%s",send_msg)
                format(system_msg, 149, "%s^x04 Funname change to^x03 %s", setting_plugin_name,fun_name[id])
                client_color(id, id, system_msg)
                if(setting_sqlserver_open && setting_funname_save)
                {
                        if(equal(steam_id[id],"VALVE_ID_LAN"))
                        {
                                new NetAddr[32]
                                get_user_ip(id, NetAddr, 31, 1)
                                new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
                                new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
                                new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s' WHERE ( `name_ip` = '%s');",hkcs_tab,fun_name[id],NetAddr)
                                SQL_Execute(query)
                                SQL_FreeHandle(hkcs_sql)
                        }
                        else
                        {
                                new NetAddr[32]
                                get_user_ip(id, NetAddr, 31, 1)
                                new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
                                new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
                                new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s',`name_ip` = '%s' WHERE ( `steam_id` = '%s');",hkcs_tab,fun_name[id],NetAddr,steam_id[id])
                                SQL_Execute(query)
                                SQL_FreeHandle(hkcs_sql)
                        }
                }
                return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
}


Sylwester 11-15-2010 07:40

Re: Can anyone change this sql plugin to non sql.
 
You can save stuff in amxmodx\data and still use sql. Enable sqlite module in your modules.ini instead of mysql and set sql host to "127.0.0.1".

GarbageBox 11-15-2010 08:18

Re: Can anyone change this sql plugin to non sql.
 
But my server is work without use mysql

Sylwester 11-15-2010 10:33

Re: Can anyone change this sql plugin to non sql.
 
You don't need mysql server, just do what I said and it should work.

YamiKaitou 11-15-2010 11:32

Re: Can anyone change this sql plugin to non sql.
 
Don't forget to also set the affinity to sqlite if you want to use it.

K.K.Lv 11-15-2010 11:41

Re: Can anyone change this sql plugin to non sql.
 
Quote:

Originally Posted by Sylwester (Post 1349970)
You don't need mysql server, just do what I said and it should work.

without mysql server and just enable the sqlite in module.ini ?

lucas_7_94 11-15-2010 11:45

Re: Can anyone change this sql plugin to non sql.
 
To work in sqlite , you only need modify / add a line . (SQL_SetAffinity)

K.K.Lv 11-15-2010 11:54

Re: Can anyone change this sql plugin to non sql.
 
and where i can edit the data file ?

Sylwester 11-15-2010 12:18

Re: Can anyone change this sql plugin to non sql.
 
You don't need to set affinity if you enable only sqlite module. Since you are not using mysql server then you can disable mysql module. The only thing you need to do is to set sql host in your plugin to "127.0.0.1" (database user and database password don't matter).
Data is saved in: addons\amxmodx\data\sqlite3\<database_name>.s q3
You can edit it using sqlite database editor. For example this one: http://sqlitebrowser.sourceforge.net/

K.K.Lv 11-15-2010 21:09

Re: Can anyone change this sql plugin to non sql.
 
Thx Sylwester,
work fine !


All times are GMT -4. The time now is 11:19.

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