Банк с подключением в бд

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
76
Реакции
3
Помог
1 раз(а)
Ошибка
L 04/18/2022 - 19:10:23: [MySQL] Invalid info tuple handle: 0
L 04/18/2022 - 19:10:23: [AMXX] Displaying debug trace (plugin "test.amxx", version "1.2")
L 04/18/2022 - 19:10:23: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 04/18/2022 - 19:10:23: [AMXX] [0] test.sma::Save_Money (line 165)
L 04/18/2022 - 19:10:23: [AMXX] [1] test.sma::client_disconnected (line 35)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5249
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.6.0.675-dev
ReGamedll
ReGameDLL version: 5.20.0.492-dev
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Список метамодулей
description stat pend file vers src load unload
[ 1] Reunion RUN - reunion_mm_i386.so v0.1.0.92 ini Start Never
[ 2] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 3] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 4] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5249 ini Start ANY
[ 5] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 6] MySQL RUN - mysql_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[ 7] SQLite RUN - sqlite_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[ 8] Fun RUN - fun_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[ 9] Engine RUN - engine_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[11] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[12] CSX RUN - csx_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[13] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5249 pl4 ANY ANY
[14] ReAPI RUN - reapi_amxx_i386.so v5.19.0.211-dev pl4 ANY Never
[15] CSSB RUN - cssb_amxx_i386.so v6-12.12.2020 pl4 ANY ANY
[16] ReCSDM RUN - csdm_amxx_i386.so v3.6 pl4 ANY ANY
16 plugins, 16 running
Список плагинов
name version author file status
[ 1] [190] Ultimate Models 21.08.23BE SKAJIbnEJIb ultimate_models running
[ 2] FreshBans 1.4.6b kanagava fresh_bans_146- running
[ 3] GameCMS_API 5.5.5 zhorzh78 gamecms_api.amx debug
[ 4] GameCMS_GagManager 2.2.3 ReAP zhorzh78 gagmanager_reap debug
[ 5] From Rock to Ban 1.02 Safety1st++ rock2gag.amxx running
[ 6] [190] Radio RBS 20.06.06 SKAJIbnEJIb radio_rbs.amxx running
[ 7] CS Bank 1.2 neygomon test.amxx debug
[ 8] [190] CsStats MySQL 21.08.22BE SKAJIbnEJIb csstats_mysql.a running
[ 9] [190] CsStats Editor 20.06.06 SKAJIbnEJIb csstats_editor. running
[ 10] [190] Skill ELO 21.08.22BE SKAJIbnEJIb skill_elo.amxx running
[ 11] [190] Top Award RBS 20.06.06 SKAJIbnEJIb topaward_rbs.am running
[ 12] [190] Army Ranks Ultim 20.06.06 SKAJIbnEJIb army_ranks_ulti running
[ 13] Stats Configuration 20.06.06 SKAJIbnEJIb & AM statscfg_rbs.am running
[ 14] [190] StatsX RBS 21.03.23 SKAJIbnEJIb & AM statsx_rbs.amxx running
[ 15] [190] Chat RBS 20.06.06 SKAJIbnEJIb chat_rbs.amxx running
[ 16] [190] Chat Addons 20.06.06 SKAJIbnEJIb chat_addons.amx running
[ 17] [190] Ultimate Flags 20.06.06 SKAJIbnEJIb ultimate_flags. running
[ 18] [190] BonusMenu RBS 21.08.23BE SKAJIbnEJIb bonusmenu_rbs.a running
[ 19] [190] Stuck RBS 20.06.06 SKAJIbnEJIb & NL stuck_rbs.amxx running
[ 20] [190] Ultimate Informe 21.03.23 SKAJIbnEJIb ultimate_inform running
[ 21] [190] Ad From Server 20.06.06 SKAJIbnEJIb ad_from_server. running
[ 22] Players Menu 20.06.06 SKAJIbnEJIb & AM admincmd_rbs.am running
[ 23] [190] AfkKicker RBS 20.08.02 SKAJIbnEJIb afkkicker_rbs.a running
[ 24] Commands Menu 20.06.06 SKAJIbnEJIb & AM cmdmenu_rbs.amx running
[ 25] Maps Menu 20.06.06 SKAJIbnEJIb & AM mapsmenu_rbs.am running
[ 26] [190] DemoRecorder RBS 20.06.06 SKAJIbnEJIb demorecorder_rb running
[ 27] [190] High Ping Kicker 20.06.06 SKAJIbnEJIb hpk_rbs.amxx running
[ 28] [190] Map Spawns Edito 20.06.06 SKAJIbnEJIb & iG MapSpawnsEditor running
[ 29] [190] Nick FIX RBS 20.06.06 SKAJIbnEJIb nickfix_rbs.amx running
[ 30] Restrict Weapons 20.06.06 SKAJIbnEJIb & AM restmenu_rbs.am running
[ 31] [190] VIP RBS 20.07.20 SKAJIbnEJIb vip_rbs.amxx running
[ 32] [190] MapChooser RBS 20.08.02 SKAJIbnEJIb & UF mapchooser_rbs. running
[ 33] NextMap 1.9.0.5249 AMXX Dev Team nextmap.amxx running
[ 34] [190] Damager RBS 20.06.06 SKAJIbnEJIb damager_rbs.amx running
[ 35] [190] Chat Controller 20.06.06 SKAJIbnEJIb chat_controller running
[ 36] [190] VoteBan RBS 20.06.06 SKAJIbnEJIb voteban_rbs.amx running
[ 37] Language Menu 1.0 F@nt0M langmenu.amxx running
[ 38] AmxModMenu v 1.1 Bitter menufront.amxx running
[ 39] Plugin Menu 1.9.0.5249 AMXX Dev Team pluginmenu.amxx running
[ 40] Admin Chat 1.9.0.5249 AMXX Dev Team adminchat.amxx running
[ 41] CSSB Shop Menu CSDM 15.10.2018 SMaster cssbShopMenuCSD debug
[ 42] CSSB Open Menu Cmd 01.03.2016 SMaster cssbOpenMenuCmd running
[ 43] CSSB Goliath Sentry Gu 24.05.2020 SMaster cssbGoliathSent debug
[ 44] CSSB Menu Laser 19.03.2018 SMaster cssbMenuLaser.a running
[ 45] CSSB Dispenser 15.10.2018 SMaster cssbDispenser.a debug
[ 46] CSSB Tesla Coil 15.10.2018 SMaster cssbTeslaCoil.a debug
[ 47] CSSB Menu M4A1 10.03.2018 SMaster cssbMenuM4A1.am running
[ 48] CSSB Menu Awp 10.03.2018 SMaster cssbMenuAwp.amx running
[ 49] CSSB Menu Deagle 10.03.2018 SMaster cssbMenuDeagle. running
[ 50] CSSB Menu Ak47 10.03.2018 SMaster cssbMenuAk47.am running
[ 51] CSSB Menu M249 10.03.2018 SMaster cssbMenuM249.am running
[ 52] CSSB Menu Galil 10.03.2018 SMaster cssbMenuGalil.a running
[ 53] CSSB Menu Sg550 10.03.2018 SMaster cssbMenuSg550.a running
[ 54] CSSB Menu Bazooka 17.12.2017 SMaster cssbMenuBazooka running
[ 55] CSSB AWP Gold 10.03.2018 SMaster cssbAwpGold.amx debug
[ 56] CSSB AWP Asiimov 10.03.2018 SMaster cssbAwpAsiimov. debug
[ 57] CSSB AWP Golden Dragon 10.03.2018 SMaster cssbAwpGoldenDr debug
[ 58] CSSB Deagle Gold 10.03.2018 SMaster cssbDeagleGold. debug
[ 59] CSSB Deagle Asiimov 10.03.2018 SMaster cssbDeagleAsiim debug
[ 60] CSSB Deagle Ice Dragon 10.03.2018 SMaster cssbDeagleIceDr debug
[ 61] CSSB Deagle Golden Dra 10.03.2018 SMaster cssbDeagleGolde debug
[ 62] CSSB Ak47 Gold 10.03.2018 SMaster cssbAk47Gold.am debug
[ 63] CSSB Ak47 Gold 2 10.03.2018 SMaster cssbAk47Gold2.a debug
[ 64] CSSB Ak47 Ice 10.03.2018 SMaster cssbAk47Ice.amx debug
[ 65] CSSB Ak47 Paladin 10.03.2018 SMaster cssbAk47Paladin debug
[ 66] CSSB M4A1 Gold 10.03.2018 SMaster cssbM4A1Gold.am debug
[ 67] CSSB M4A1 Gold 2 10.03.2018 SMaster cssbM4A1Gold2.a debug
[ 68] CSSB M4A1 Beast 10.03.2018 SMaster cssbM4A1Beast.a debug
[ 69] CSSB M4A1 Golden Drago 10.03.2018 SMaster cssbM4A1GoldenD debug
[ 70] CSSB Galil Coup 10.03.2018 SMaster cssbGalilCoup.a debug
[ 71] CSSB Galil Dark Knight 10.03.2018 SMaster cssbGalilDarkKn debug
[ 72] CSSB Sg550 VSK-94 10.03.2018 SMaster cssbSg550-VSK-9 debug
[ 73] CSSB Destroyer 04.01.2018 SMaster cssbDestroyer.a debug
[ 74] CSSB Bazooka 15.10.2018 SMaster cssbBazooka.amx debug
[ 75] CSSB Mini Gun 10.03.2018 SMaster cssbMiniGun.amx debug
[ 76] CSSB Mini Gun Winter 10.03.2018 SMaster cssbMiniGunWint debug
[ 77] CSSB Mini Gun Gold 10.03.2018 SMaster cssbMiniGunGold debug
[ 78] CSSB Laser Mines 15.10.2018 SMaster cssbLaserMines. debug
[ 79] CSSB Laser Mines Verti 15.10.2018 SMaster cssbLaserMinesV debug
[ 80] CSSB Laser Mines Horiz 15.10.2018 SMaster cssbLaserMinesH debug
[ 81] CSSB Laser Scanner 15.10.2018 SMaster cssbLaserMinesS debug
[ 82] CSSB Laser Fence 15.10.2018 SMaster cssbLaserFence. debug
[ 83] ReCSDM Main 3.6 ReCSDM Team csdm_main.amxx running
[ 84] ReCSDM Equip 3.6 ReCSDM Team csdm_equip.amxx running
[ 85] ReCSDM Spawns 3.6 ReCSDM Team csdm_spawn_pres running
[ 86] ReCSDM Misc 3.6 ReCSDM Team csdm_misc.amxx running
[ 87] ReCSDM Stripper 3.6 KWo csdm_stripper.a running
[ 88] ReCSDM Protection 3.6 BAILOPAN csdm_protection running
[ 89] CSSB Skills Pump Syste 15.10.2018 SMaster cssbSkillsPumpS running
[ 90] CSSB Skills Pump Healt 05.05.2016 SMaster cssbSkillsPumpH running
[ 91] CSSB Skills Pump Armor 05.05.2016 SMaster cssbSkillsPumpA running
[ 92] CSSB Skills Pump Invis 04.12.2016 SMaster cssbSkillsPumpI running
[ 93] CSSB Skills Pump Speed 04.12.2016 SMaster cssbSkillsPumpS running
[ 94] CSSB Skills Pump Gravi 04.12.2016 SMaster cssbSkillsPumpG running
[ 95] CSSB Skills Pump Show 04.06.2016 SMaster cssbSkillsPumpS running
[ 96] Bn_zp_knife 2.5 NEO myknifemenu.amx running
[ 97] Unlimited Clip Ammo 1.0 -Acid- ammo_menu.amxx running
[ 98] ReCSDM Team Balance 1.0.3 the_hunter recsdm_team_bal running
[ 99] bot ping as real playe 1.0 bionext bot_ping_as_rea running
[100] [AMXX] GiveMoney 1.0 HAPKOMAH GiveMoney.amxx running
[101] GameName Changer 1.0 neugomon gamename_change running
[102] Donate money 0.1 Sanlerus \ di.al donate_money.am running
[103] Grab 1.0 Nickron mg_grab.amxx running
[104] Camera Changer 1.3 Bl0ck Camera_Changer. running
[105] ADMIN GUN v 1.0 Bitter menu.amxx running
[106] ServerMenu CSDM v 1.0 Bitter menu_servera.am running
[107] ResetScore 1.0 Leo_[BH] resetscore_reap running
[108] ADMIN MENU v 1.0 Bitter adminmenu.amxx running
[109] Recoil Control 1.5 OT recoil_control_ running
[110] Spec Switch 0.0.3 many Spec_Switch_rus running
[111] WalkGuard 1.3.2 mogel walkguard.amxx running
[112] VIP/ADMIN GUN v 1.0 Bitter menupriv.amxx debug
[113] New Jetpack 0.0.2 Bad_Bud, ZmOutSt zp_king_jetpack running
113 plugins, 113 running
Автор плагина
neygomon
Версия плагина
1.2
Исходный код
дал файл
Помогите решить в чем проблема почему такое иногда бывает!


Код:
L 04/18/2022 - 19:10:23: [MySQL] Invalid info tuple handle: 0
L 04/18/2022 - 19:10:23: [AMXX] Displaying debug trace (plugin "test.amxx", version "1.2")
L 04/18/2022 - 19:10:23: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 04/18/2022 - 19:10:23: [AMXX]    [0] test.sma::Save_Money (line 165)
L 04/18/2022 - 19:10:23: [AMXX]    [1] test.sma::client_disconnected (line 35)
 
В этой теме было размещено решение! Перейти к решению.

Вложения

Сообщения
3,579
Реакции
1,569
Помог
137 раз(а)
Скрытое содержимое для пользователей: SanSannech
 
Сообщения
3,579
Реакции
1,569
Помог
137 раз(а)
Предоставьте верный исходник.
L 04/18/2022 - 19:10:23: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 04/18/2022 - 19:10:23: [AMXX] [0] test.sma::Save_Money (line 165)
На этой строке в исходнике нет указанной функции.
 
Сообщения
76
Реакции
3
Помог
1 раз(а)
Nordic Warrior,Я вам дал тот что и сам использую
21 Апр 2022
Nordic Warrior,
Код:
#include <amxmodx>
#include <cstrike>
#include <sqlx>

enum _:ques { INSTALL_PLUGIN, LOAD_MONEY, SAVE_MONEY, INSERT_MONEY };
new Handle:g_sql, data[2], szQuery[512];

enum DATA { STATUSLOAD, STEAMID[24], MONEY };
new g_iPlayerData[33][DATA];
new bool:g_bIgnoreClient[33];

new g_iRoundCount;

public plugin_init()
{
#define VERSION "1.2"
    register_plugin("CS Bank", VERSION, "neygomon");
    register_cvar("bk_neygomon", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
    
    register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w");
    register_event("HLTV", "eRoundStart", "a", "1=0", "2=0");
    
    set_task(3.0, "ShowMoney", .flags = "b");
    set_task(1.5, "SQL_Init");
}

public client_putinserver(id)
{
    if(is_user_bot(id) || is_user_hltv(id))
        return g_bIgnoreClient[id] = true;
    
    g_iPlayerData[id][MONEY] = 0;
    return Load_Money(id);
}

public client_disconnect(id)
{
    if(!g_bIgnoreClient[id])
        Save_Money(id);
}

public eRestart()
    g_iRoundCount = 0;

public eRoundStart()
    g_iRoundCount++;   

public ShowMoney()
{
    if(g_iRoundCount < 3)
        return;
    
    static id, iMoney[33], players[32], pnum;
    get_players(players, pnum, "ach");
    for(new i; i < pnum; i++)
    {
        id = players[i]; iMoney[id] = cs_get_user_money(id);
        if(iMoney[id] > 10000)
        {
            new InBank = iMoney[id] - 10000;
            g_iPlayerData[id][MONEY] += InBank;
            cs_set_user_money(id, 10000);
        }
        else
        {
            if(g_iPlayerData[id][MONEY] < 10000 - iMoney[id])
            {
                cs_set_user_money(id, iMoney[id] + g_iPlayerData[id][MONEY]);
                g_iPlayerData[id][MONEY] = 0;
            }
            else
            {
                g_iPlayerData[id][MONEY] -= 10000 - iMoney[id];
                cs_set_user_money(id, 10000);
            }
        }
        set_hudmessage(0, 255, 0, 0.7, 0.87, 0, 6.0, 3.1, 0.1, 0.2, -1)
        show_hudmessage(id, "В Вашем банке %d $", g_iPlayerData[id][MONEY])
    }
}

public SQL_Init()
{   
    new g_SqlHost[32], g_SqlUser[32], g_SqlPass[32], g_SqlDb[32];
    get_cvar_string("amx_sql_host", g_SqlHost, charsmax(g_SqlHost));
    get_cvar_string("amx_sql_user", g_SqlUser, charsmax(g_SqlUser));
    get_cvar_string("amx_sql_pass", g_SqlPass, charsmax(g_SqlPass));
    get_cvar_string("amx_sql_db", g_SqlDb, charsmax(g_SqlDb));
    
    g_sql = SQL_MakeDbTuple(g_SqlHost, g_SqlUser, g_SqlPass, g_SqlDb);
    
    if(g_sql == Empty_Handle)
        set_fail_state("unable to create SQL handler");
        
    new err, error[256];
    new Handle:g_checksql = SQL_Connect(g_sql, err, error, 255);
    
    if(g_checksql == Empty_Handle)
    {
        log_amx("failed to connect to MySQL database");
        log_amx("[ %d ] %s", err, error);
        
        set_fail_state("mysql connection failed");
    }
    SQL_FreeHandle(g_checksql);
    InstallPlugin();
}

public SQL_Handler(failstate, Handle:que, err[], errcode, data[], datasize)
{
    switch(failstate)
    {
        case TQUERY_CONNECT_FAILED:
        {
            log_amx("MySQL connection failed");
            log_amx("[ %d ] %s",errcode, err);
            log_amx("Query state: %d", data[0]);
            return PLUGIN_CONTINUE;
        }
        case TQUERY_QUERY_FAILED:
        {
            log_amx("MySQL query failed");
            log_amx("[ %d ] %s", errcode, err);
            log_amx("Query state: %d", data[0]);
            return PLUGIN_CONTINUE;
        }
    }
    new id = data[1];
    switch(data[0])
    {
        case INSTALL_PLUGIN: { }
        case LOAD_MONEY:
        {
            if(SQL_NumResults(que) <= 0)
            {
                g_iPlayerData[id][STATUSLOAD] = 2;
                return PLUGIN_CONTINUE;
            }
            g_iPlayerData[id][MONEY] = SQL_ReadResult(que, 0);
            g_iPlayerData[id][STATUSLOAD] = 1;
        }
        case INSERT_MONEY:
        {
            if(SQL_AffectedRows(que) > 0)
                g_iPlayerData[id][STATUSLOAD] = 1;
        }
        case SAVE_MONEY: { }
    }
    return PLUGIN_CONTINUE;
}

InstallPlugin()
{
    data[0] = INSTALL_PLUGIN;
    formatex(szQuery, 511, "CREATE TABLE IF NOT EXISTS `cs_bank` ( `steamid` varchar(24) DEFAULT NULL, `cash` int(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    SQL_ThreadQuery(g_sql, "SQL_Handler", szQuery, data, 2);
}   

Load_Money(id)
{
    data[0] = LOAD_MONEY; data[1] = id;
    get_user_authid(id, g_iPlayerData[id][STEAMID], charsmax(g_iPlayerData[][STEAMID]));
    
    formatex(szQuery, 511, "SELECT `cash` FROM `cs_bank` WHERE `steamid` = '%s'", g_iPlayerData[id][STEAMID]);
    return SQL_ThreadQuery(g_sql, "SQL_Handler", szQuery, data, 2);
}

Save_Money(id)
{
    switch(g_iPlayerData[id][STATUSLOAD])
    {
        case 1:
        {
            data[0] = SAVE_MONEY;
            formatex(szQuery, 511, "UPDATE `cs_bank` SET `cash` = '%d' WHERE `steamid` = '%s'", g_iPlayerData[id][MONEY], g_iPlayerData[id][STEAMID]);
        }
        case 2:
        {
            data[0] = INSERT_MONEY;
            formatex(szQuery, 511, "INSERT INTO `cs_bank` (`steamid`, `cash`) VALUES('%s', '%d')", g_iPlayerData[id][STEAMID], g_iPlayerData[id][MONEY]);
        }
    }
    data[1] = id; SQL_ThreadQuery(g_sql, "SQL_Handler", szQuery, data, 2);
}
 
Сообщения
20
Реакции
26
Всё там на месте, разве что смущает client_disconnect в коде, и client_disconnected в логе. Видимо компилятор сам подменяет, выругивая предупреждение.
Код:
Invalid info tuple handle: 0
вот тут проблема, которая говорит что соединение было, но запрос не прошел по какой-то причине. Можно попробовать к
Код:
SELECT `cash` FROM `cs_bank` WHERE `steamid` = '%s'
дописать LIMIT 1, чтобы исключить дубли, но нет гарантий что это поможет)
 
Сообщения
76
Реакции
3
Помог
1 раз(а)
@TehGaia,Я не совсем понял про LIMIT 1, как это?
 
Сообщения
892
Реакции
149
Помог
25 раз(а)
SanSannech, LIMIT выводит указанное кол-во строк, к примеру
SELECT * FROM Tabel.Name LIMIT 2, выводит из указанной таблицы 2 первых ячейки.
 
Сообщения
673
Реакции
242
Помог
11 раз(а)
покажите саму таблицу или задампите его сюда
 
Сообщения
76
Реакции
3
Помог
1 раз(а)
@Алексеич,Решение тут нет, нашел другой способ.
 
Сообщения
313
Реакции
21
Помог
7 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
SanSannech, Дак поделись решением то с другими, раз нашёл.
 
Сообщения
76
Реакции
3
Помог
1 раз(а)
kto-to,тема уже не актуальна, уже всё заменил на другое.
 
Сообщения
76
Реакции
3
Помог
1 раз(а)
@Алексеич,Решение было в
Код:
public SQL_Init()
{
    то что оставил.
    g_sql = SQL_MakeDbTuple("localhost", "bazame", "passme", "bazame", MaxClients);

ну и конечно ост код после g_sql
  
}
Я просто указал соединение к бд сразу, а не через amx sql которая
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу