RSSy MYGO.pl Opublikowano Kwiecień 23, 2022 o 06:21 RSSy Udostępnij Opublikowano Kwiecień 23, 2022 o 06:21 Hello everyone. I got a problem - I want to connect to sql and check if player has acccess flags. Here's my example code: PHP Code: #include <amxmodx>#include <amxmisc>#include <sqlx>#define PLUGIN "sqlVIPloader"#define VERSION "1.0"#define AUTHOR "Sebxx"new c_db_host, c_db_user, c_db_pass, c_db_name, c_serv_ipnew db_host[33], db_user[33], db_pass[33], db_name[33], serv_ip[23]new Handle:g_SqlTuplepublic plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) c_db_host = register_cvar("shop_sql_host", "127.0.0.0") c_db_user = register_cvar("shop_sql_user", "root") c_db_pass = register_cvar("shop_sql_pass", "") c_db_name = register_cvar("shop_sql_db", "shop") c_serv_ip = register_cvar("this_serv_ip", "127.127.127.127:27015") new cfg_loc[33] get_configsdir( cfg_loc, charsmax(cfg_loc) ) server_cmd( "exec %s/st_shop_sql.cfg", cfg_loc )}public client_authorized( id, const authid[] ){ if ( !is_user_bot(id) && !is_user_hltv(id) ) { get_pcvar_string( c_db_host, db_host, 32 ) get_pcvar_string( c_db_user, db_user, 32 ) get_pcvar_string( c_db_pass, db_pass, 32 ) get_pcvar_string( c_db_name, db_name, 32 ) get_pcvar_string( c_serv_ip, serv_ip, 22 ) g_SqlTuple = SQL_MakeDbTuple( db_host, db_user, db_pass, db_name ) new query[512], user_ip[32], name[32], steamid[35], pw_info[32], pw_hash[34] get_user_ip( id, user_ip, charsmax(user_ip), 1 ) get_user_name( id, name, charsmax(name) ) get_user_authid( id, steamid, charsmax(steamid) ) get_user_info( id, "_pw", pw_info, 31 ) hash_string( pw_info, Hash_Md5, pw_hash, charsmax(pw_hash) ) formatex(query, 511, "SELECT sc.access \ FROM shop_services AS sc, shop_servers AS sv \ WHERE sv.serv_ip = '%s' \ AND sc.server_id = sv.serv_id \ AND ( ( sc.auth_id = '%s' AND sc.auth = 1 ) OR ( sc.auth_id = '%s' AND sc.password = '%s' AND sc.auth = 2 ) OR ( sc.auth_id = '%s' AND sc.password = '%s' AND sc.auth = 3 ) ) \ AND sc.expire > %d", serv_ip, steamid, name, pw_hash, user_ip, pw_hash, get_systime() ) new Data[1] Data[0] = id SQL_ThreadQuery(g_SqlTuple, "do_query", query, Data, 1) }}public do_query( FailState, Handle:Query, Error[], Errcode, Data[], DataSize ){ if ( FailState == TQUERY_CONNECT_FAILED ) { log_amx("Could not connect to SQL database.") if ( Errcode ) { log_amx("Error: %s", Error) } return PLUGIN_CONTINUE } else if ( FailState == TQUERY_QUERY_FAILED ) { log_amx("Query failed.") if ( Errcode ) { log_amx("Error: %s", Error) } return PLUGIN_CONTINUE } new id = Data[0] if ( SQL_NumResults(Query) ) { new flags[32] while( SQL_MoreResults( Query ) ) { new qcolAccess = SQL_FieldNameToNum( Query, "access" ) SQL_ReadResult( Query, qcolAccess, flags, 31 ) //log_amx( "Flag: %s", flags ) set_user_flags( id, read_flags( flags ) ) SQL_NextRow(Query) } } SQL_FreeHandle(g_SqlTuple) return PLUGIN_CONTINUE} The problem is, set_user_flags don't set it. SQL query works well (I see in the console flags get from sql server) but player don't have permissions. What's wrong? Przeczytaj cały wpis Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi