- Автор темы
- #1
Код:
enum playerinfo
{
name[MAX_PLAYER_NAME],
pass[65],
hash[11],
}
new player_info[MAX_PLAYERS][playerinfo];
enum
{
DLG_NONE,
DLG_REGISTER
}
#define SPD ShowPlayerDialog
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
#define DSL DIALOG_STYLE_LIST
#define DSI DIALOG_STYLE_INPUT
#define DSM DIALOG_STYLE_MSGBOX
#define DSP DIALOG_STYLE_PASSWORD
#define DST DIALOG_STYLE_TABLIST
#define DSTH DIALOG_STYLE_TABLIST_HEADERS
new MySQL:dbHandle;
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASSWORD ""
#define MYSQL_DATABASE "spacerp"
#define SERVER_NAME "Space"
public OnPlayerConnect(playerid)
{
new query[256];
GetPlayerName(playerid, player_info[playerid][name], MAX_PLAYER_NAME);
mysql_format(dbHandle, query, sizeof(query), "SELECT `pass`, `hash` FROM `accounts` WHERE `name` = '%e'", player_info[playerid][name]);
mysql_tquery(dbHandle, query, "CheckAccountInMysql", "i", playerid);
return 1;
}
forward CheckAccountInMysql(playerid);
public CheckAccountInMysql(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows)
{
//авторизация
}
else //регистрация
{
new string[256];
format(string, sizeof(string), "Добро пожаловать на наш сервер\n\
Ваш логин: %s. Данный аккаунт не зарегестрирован.\n\
Для того, чтобы зарегестрироваться, установите пароль для вашего аккаунта.\n\
~ Используйте латинские символы и цифры.", player_info[playerid][name])
SPD(playerid, DLG_REGISTER, DSP, "Регистрация | Ввод пароля", string, "Ввод", "Отмена")
}
return 1;
}
public OnDialogResponse(playerid)
{
switch(dialogid)
{
case DLG_REGISTER:
{
new gHash[11];
for(new i; i < 10; i++)
{
gHash[i] = random(79) + 47;
}
gHash[10] = 0;
SHA256_PassHash(inputtext, gHash, player_info[playerid][pass], 65);
new query[128];
mysql_format(dbHandle, query, sizeof(query), "INSERT INTO `accounts` (`name`, `pass`, `hash`) VALUES (`%e`, `%e`, `%e`)", player_info[playerid][name], player_info[playerid][pass], gHash);
mysql_tquery(dbHandle, query);
}
}
}
public OnGameModeInit()
{
dbHandle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
if(mysql_errno() != 0)
{
print("[MySQL] Подключение к базе данных не удалось!");
return SendRconCommand("exit");
}
print("[MySQL] Подключение к базе данных успешно!");
SetGameModeText("Space GM v0.1");
AddPlayerClass(0, 1958.3743,1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
У меня проблема в том, что когда я включаю сервер, подключаюсь к нему, по факту диалог открывается, но резко закрывается.
В mysql логе пишет вот что:
[11:14:26] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:07:52] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:09:17] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:10:33] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:13:51] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:14:04] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:23:26] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:23:38] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:25:41] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:25:55] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:26:42] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:26:59] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:44:40] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:45:07] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:47:30] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:47:54] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:48:41] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Testfghfgh'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Testfghfgh'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:07:52] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:09:17] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:10:33] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:13:51] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:14:04] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:23:26] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:23:38] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:25:41] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:25:55] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:26:42] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:26:59] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:44:40] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:45:07] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:47:30] [WARNING] mysql_connect: no password specified (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onGameModeInit.pwn:2)
[12:47:54] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Test'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Test'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
[12:48:41] [ERROR] error #1064 while executing query "SELECT `pass`, `hash` WHERE `name` = 'Test_Testfghfgh'": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `name` = 'Test_Testfghfgh'' at line 1 (C:\Users\vsadn\Desktop\Space RP\pawno\include\serverfunc/onPlayerConnect.pwn:4)
Последнее редактирование: