28.05.2015, 16:53
Hey all,
I wanna make when my mysql database colud not connect tor try again.
this is my code but when I am trying to connect to unknown database the server crashes.
this is the output from crashdetect:
what i'm doing wrong can anyone help me, please? +rep
I wanna make when my mysql database colud not connect tor try again.
this is my code but when I am trying to connect to unknown database the server crashes.
Код:
//BG-Edition Test Gamemode by MichaelGoodman! #include <a_samp> #include <a_mysql> #include <sscanf> #include <zcmd> #include <streamer> #include <bgedition> //- mysql connection #define mysql_host "localhost" #define mysql_user "root" #define mysql_password "bg3diti0n" #define mysql_database "bgedsitiontestsamp" //- news new mysql_handle[50], mysql_conatt = 5, bool:mysql_connected[50] = false; main() { } public OnGameModeInit() { mysql_conatt = 5; mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); mysql_handle[0] = mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password); if(mysql_errno(mysql_handle[0]) == 0) { print("[DEBUG]: Connected to the MySQL database!"); mysql_connected[0] = true; } else { mysql_conatt--; mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password); print("[DEBUG]: Could not connect to the MySQL database. Reconecting..."); if(mysql_conatt == 0) { mysql_connected[0] = false; //there i'm doing something } } return 1; } public OnGameModeExit() { mysql_close(mysql_handle[0]), mysql_connected = false; return 1; }
Код:
[28/05/2015 19:56:21] [debug] Server crashed while executing BulgEdition.amx [28/05/2015 19:56:21] [debug] AMX backtrace: [28/05/2015 19:56:21] [debug] #0 native mysql_connect () from mysql.DLL [28/05/2015 19:56:21] [debug] #1 000069e8 in public zcmd_OnGameModeInit () from BulgEdition.amx [28/05/2015 19:56:21] [debug] #2 native CallLocalFunction () from samp-server.exe [28/05/2015 19:56:21] [debug] #3 00005d5c in public SSCANF_OnGameModeInit () from BulgEdition.amx [28/05/2015 19:56:21] [debug] #4 00000104 in public OnGameModeInit () from BulgEdition.amx [28/05/2015 19:56:22] [debug] Native backtrace: [28/05/2015 19:56:22] [debug] #0 5c98a017 in ?? () from libmysql.dll