AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [help] bad player list (https://forums.alliedmods.net/showthread.php?t=291891)

ghostz0r 12-25-2016 06:11

[help] bad player list
 
hello guys, i tried to make blacklist with bad players with sql database, i don't know how to make sql request to check players, help pls to :crab: :P

this code have black_list.ini file in configs dir, all players writed inside this file like a
;nickname
STEAMID

Code:

#include <amxmodx>
#include <amxmisc>
#include <sqlx>

#define PLUGIN "Black List SQLx"
#define VERSION "0.000"
#define AUTHOR "zerz0r"

new const user_file[] = "black_list.ini"
new Array:BlackList

new Handle:SQL_Tuple
new Handle:SQL_Connection

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
    SQL_Tuple = SQL_MakeDbTuple("host","user","password","database")
    new err, error[256]
    SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
   
    if(SQL_Connection != Empty_Handle)
        {
        log_amx("[SQLx connect ok]")
        }else{
        log_amx("[SQLX sql error] %s ",error)
        pause("a")
    }
   
}

public plugin_precache()
{
        BlackList = ArrayCreate(32, 1)
        read_user_from_file()
}

public read_user_from_file()
{
        static user_file_url[64], config_dir[32]
       
        get_configsdir(config_dir, sizeof(config_dir))
        format(user_file_url, sizeof(user_file_url), "%s/%s", config_dir, user_file)
       
        if(!file_exists(user_file_url))
                return
       
        static file_handle, line_data[64], line_count
        file_handle = fopen(user_file_url, "rt")
       
        while(!feof(file_handle))
        {
                fgets(file_handle, line_data, sizeof(line_data))
               
                replace(line_data, charsmax(line_data), "^n", "")
               
                if(!line_data[0] || line_data[0] == ';')
                        continue
                       
                ArrayPushString(BlackList, line_data)
                line_count++
        }
       
        fclose(file_handle)
}

public client_connect(id)
{
        check_and_handle(id)
}

public client_infochanged(id)
{
        check_and_handle(id)
}

public check_and_handle(id)
{
        static name[64], steamid[32], Data[32]
       
        get_user_name(id, name, sizeof(name))
        get_user_steamid(id, steamid, sizeof(steamid))
       
        for(new i = 0; i < ArraySize(BlackList); i++)
        {
                ArrayGetString(BlackList, i, Data, sizeof(Data))
               
                if(equal(name, Data) || equal(steamid, Data))
                {
                server_cmd("amx_kick %s kappa^n", name)
                client_printcolor(0, "!g[BL]!y !t%s!y bad PLAYER. Kick !t%s!y !!!", name, name)
                }
        }
}
stock client_printcolor(const id, const input[], any:...)
{
        new iCount = 1, iPlayers[32]
        static szMsg[191]
       
        vformat(szMsg, charsmax(szMsg), input, 3)
        replace_all(szMsg, 190, "!g", "^4")
        replace_all(szMsg, 190, "!y", "^1")
        replace_all(szMsg, 190, "!t", "^3")
       
        if(id) iPlayers[0] = id
        else get_players(iPlayers, iCount, "ch")
       
        for (new i = 0; i < iCount; i++)
        {
                if(is_user_connected(iPlayers[i]))
                {
                        message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i])
                        write_byte(iPlayers[i])
                        write_string(szMsg)
                        message_end()
                }
        }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1066\\ f0\\ fs16 \n\\ par }
*/


Craxor 12-25-2016 12:11

Re: [help] bad player list
 
I don't know with sql but i can help you with nvault if you want

ghostz0r 12-25-2016 12:23

Re: [help] bad player list
 
i need sql coz i have 2-3 server's

fysiks 12-25-2016 12:45

Re: [help] bad player list
 
I'd recommend reading some tutorials that talk about using SQL with AMX Mod X. Also, you can look at other ban plugins that use SQL since that is exactly what you are doing. And, in that light, you should maybe consider just using an SQL-based ban plugin.

SomewhereLost 12-26-2016 01:27

Re: [help] bad player list
 
Is there any similar plugin but without SQL ?

Craxor 12-26-2016 02:59

Re: [help] bad player list
 
Quote:

Originally Posted by SomewhereLost (Post 2480559)
Is there any similar plugin but without SQL ?

https://forums.alliedmods.net/showthread.php?t=176663


All times are GMT -4. The time now is 08:36.

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