Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Plugin generated by AMXX-Studio */
- #include <amxmodx>
- #include <amxmisc>
- #include <sqlx>
- #define PLUGIN "Active Key"
- #define VERSION "1.0"
- #define AUTHOR "Seroff"
- // key
- new sKey[]="228FRZPG228FRZPG228FRZPGdsdfsSD23REFCVBDFFRTGT1324RTERWTHY2345HRTRTGH2435YH4TGHFR"
- new const gsz_SLINFO[][] = {
- { "127.0.0.1" }, // HOST
- { "seroff" }, // USER
- { "seroff" }, // User's password
- { "seroff" } // Database Name
- }
- new Handle:SQL_Tuple
- new Handle:SQL_Connection
- new g_ServerPort, g_ServerIP[32], gServerIP[32]
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- get_user_ip(0, g_ServerIP, 32,g_ServerPort)
- // only ip
- copyc(gServerIP,charsmax(gServerIP),g_ServerIP,':')
- //register_concmd("select_sql_result","sqlx_select_result")
- // bad ip
- if(equal(gServerIP, "0.0.0.0", 7) || equal(gServerIP, "127.0.0.1", 9) || equal(gServerIP, "", 0)){
- set_fail_state("Error! Incorrect server IP!");
- }
- set_task(1.0,"sqlx_select_result"); // getinfo active
- }
- public plugin_cfg(){
- // connect base
- SQL_Tuple = SQL_MakeDbTuple(gsz_SLINFO[0],gsz_SLINFO[1],gsz_SLINFO[2],gsz_SLINFO[3]) // Создание картежа данных для соединения с БД
- 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 sqlx_select_result(){
- // Подготовка Запроса
- new Handle:query = SQL_PrepareQuery(SQL_Connection,"SELECT * FROM `act_id` WHERE skey = '%s'",sKey)
- // Выполняем запрос к базе даанных
- SQL_Execute (query)
- //new id = SQL_ReadResult(query, 0)
- new str[512]
- SQL_ReadResult(query, 1, str, 511)
- new ip[32]
- SQL_ReadResult(query, 2, ip, 31)
- //server_print("SQL Select Result: str [%s] ip [%s]",str,ip)
- if(!equali(gServerIP, ip)){
- server_print("ip [%s] [%s]",gServerIP, ip)
- server_print("sKey [%s] [%s]",sKey, str)
- set_fail_state("You use LicensedBad!");
- }else{
- server_print("Licensed is good!")
- }
- server_print("server %s",g_ServerIP)
- }
- public plugin_end(){
- // off
- SQL_FreeHandle(SQL_Connection)
- }
Advertisement
Add Comment
Please, Sign In to add comment