Closed semen7907 closed 10 years ago
I've been trying to reproduce this bug, but I failed. For me, it works fine.
I've used exactly the same plugin (version 2.6, MySQL only, statically linked) with the following Linux machine:
Linux vagrant-ubuntu-trusty-32 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC 2014 i686 i686 i686 GNU/Linux
This it the code, which is mostly yours.
#include <a_samp>
#include <sql>
#define COL_WHITE "{000000}"
#define DIALOG_REGISTER 1
#define GivePlayerCash GivePlayerMoney
enum ePlayer {
pLogged
}
new SQL:sqlconnection, CountREGISTRATION, PlayerData[MAX_PLAYERS][ePlayer];
stock playerName(playerid)
{
new ret[MAX_PLAYER_NAME];
GetPlayerName(playerid, ret, sizeof(ret));
return ret;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
printf("OnDialogResponse called");
// SNIPPET FROM THE ORIGINAL ISSUE (https://github.com/udan11/samp-plugin-sql/issues/10)
if(strlen(inputtext) < 5 || strlen(inputtext) > 16)
{
new dialogStr[500];
format(dialogStr, sizeof(dialogStr),
"Регистрация", playerName(playerid));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"{FF3300}Регистрация [ERROR]",dialogStr,"Далее","Выход");
return 1;
}
new
escapedpw[80],
Query[356];
sql_escape_string(sqlconnection, inputtext, escapedpw); // Строка 2593
format(Query, sizeof(Query), "INSERT INTO `players` (`Name`, `Password`, `Kills`, `Deaths`, `Cash`, `Scr`, `Admin`, `Spawn`, `SpawnX`, `SpawnY`, `SpawnZ`) VALUES ('%s', MD5('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0)", playerName(playerid), escapedpw);
sql_query(sqlconnection, Query, QUERY_THREADED);
GivePlayerCash(playerid, 50000);
PlayerData[playerid][pLogged] = true;
TogglePlayerSpectating(playerid, false);
PlayerPlaySound(playerid, 21002, 0.0, 0.0, 0.0);
CountREGISTRATION++;
// END OF SNIPPET
printf("inputtext = %s", inputtext);
printf("escapedpw = %s", escapedpw);
printf("Query = %s", Query);
return 1;
}
public OnGameModeInit()
{
sqlconnection = mysql_connect("127.0.0.1", "root", "root", "samp-gm-v1");
printf("sqlconnection = %d", _:sqlconnection);
CallLocalFunction("OnDialogResponse", "iiiis", 59, 126, 1, -1, "\\\\\\\\\\\\");
return 1;
}
main() {}
And my output is this (as expected):
[20:02:48] Loading plugin: sql.so
[20:02:48] >> SQL plugin v2.6 successfully loaded.
[20:02:48] + MySQL support is enabled.
[20:02:48] Loaded.
...
[20:02:48] sqlconnection = 1
[20:02:48] OnDialogResponse called
[20:02:48] inputtext = \\\\\\
[20:02:48] escapedpw = \\\\\\\\\\\\
[20:02:48] Query = INSERT INTO `players` (`Name`, `Password`, `Kills`, `Deaths`, `Cash`, `Scr`, `Admin`, `Spawn`, `SpawnX`, `SpawnY`, `SpawnZ`) VALUES ('', MD5('\\\\\\\\\\\\'), 0, 0, 0, 0, 0, 0, 0, 0, 0)
My sql_log.txt
:
[20:02:48][info] Natives::sql_connect: Connecting to database (type = 1) root:***@127.0.0.1:0/samp-gm-v1...
[20:02:48][info] Natives::sql_connect: Connection (conn->id = 1) was succesful!
[20:02:48][debug] Natives::sql_escape_string: Escaping (conn->id = 1) string '\\\\\\'...
[20:02:48][debug] Natives::sql_query: Scheduling statement (stmt->id = 1, stmt->query = INSERT INTO `players` (`Name`, `Password`, `Kills`, `Deaths`, `Cash`, `Scr`, `Admin`, `Spawn`, `SpawnX`, `SpawnY`, `SpawnZ`) VALUES ('', MD5('\\\\\\\\\\\\'), 0, 0, 0, 0, 0, 0, 0, 0, 0), stmt->callback = ) for execution...
[20:02:48][debug] SQL_Worker[1]: Executing query (stmt->id = 1, stmt->query = INSERT INTO `players` (`Name`, `Password`, `Kills`, `Deaths`, `Cash`, `Scr`, `Admin`, `Spawn`, `SpawnX`, `SpawnY`, `SpawnZ`) VALUES ('', MD5('\\\\\\\\\\\\'), 0, 0, 0, 0, 0, 0, 0, 0, 0))...
[20:02:48][debug] ProccessTick: Executing query callback (stmt->id = 1, stmt->error = 1146, stmt->callback = )...
[20:02:48][debug] ProccessTick: Erasing query (stmt->id = 1)...
Can you post the relevant parts of your sql_log.txt
file, please?
I reinstalled the plugin and include and it seems that errors are no more, may have been damaged plugin...
If you crash again, I will give log
sorry for the English :d
No problem! I'm glad to hear that you've fixed your issues.
Plugin ver: mysql-v2.6-static-linux