17.01.2014, 20:57
PHP код:
stock SaveAccount(playerid) {
if(gPlayerLogged[playerid] == 1) {
CheckMySQLConnection();
new query[300];
format(query, sizeof(query), "UPDATE `Accounts` SET `Nickname` = '%s', `Password` = '%s', `AdminLevel` = '%d', `Vip` = '%d', `Banned` = '%d', `Muted` = '%d', `MutedTime` = '%d', `Skin` = '%d', `Score` = '%d', `Level` = '%d', `EXP` = '%d', `Money` = '%d' WHERE `ID` = '%i'",
playerVariable[playerid][Name],
playerVariable[playerid][Password],
playerVariable[playerid][AdminLevel],
playerVariable[playerid][Vip],
playerVariable[playerid][Banned],
playerVariable[playerid][Muted],
playerVariable[playerid][MutedTime],
playerVariable[playerid][Skin],
playerVariable[playerid][Score],
playerVariable[playerid][Level],
playerVariable[playerid][Exp],
playerVariable[playerid][Money],
playerVariable[playerid][ID]);
printf("%s",query);
mysql_query(query);
}
return 1;
}
Quote:
UPDATE `Accounts` SET `Nickname` = '23', `Password` = '', `AdminLevel` = '1', `Vip` = '0', `Banned` = '0', `Muted` = '0', `MutedTime` = '0', `Skin` = '0', `Score` = '0', `Level` = '0', `EXP` = '50', `Money` = '100' WHERE `ID` = '123456' |
Maybe something wrong with my LoadAcc?
PHP код:
stock LoadAccount(playerid, password[]) {
new query[128],
sqlpass[32],
result[5+24+64],
dialog[128];
mysql_real_escape_string(password, sqlpass);
// format(query, sizeof(query), "SELECT ID, Name, Password FROM `Accounts` WHERE `Password` = '%s' AND `ID` = '%i'", sqlpass, playerVariable[playerid][ID]);
format(query, sizeof(query), "SELECT Password,ID FROM `Accounts` WHERE `Password` = '%s' AND `ID` = '%i'", sqlpass, playerVariable[playerid][ID], playerVariable[playerid][Name] );
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 1) {
mysql_fetch_row_format(result, "|");
sscanf(result, "p<|>is[24]s[32]", //
playerVariable[playerid][Name],
playerVariable[playerid][Password],
playerVariable[playerid][ID]);
gPlayerLogged[playerid] = 1;
mysql_free_result();
return 1;
}
else { // Мы ввели неверный пароль.
if(playerVariable[playerid][WrongPassword] == 3) {
SendClientMessage(playerid, COLOR_LIGHTRED, "Вы 3 раза ввели неверный пароль и были отключены от сервера.");
Kick(playerid);
return 1;
}
playerVariable[playerid][WrongPassword] ++;
format(dialog, sizeof(dialog),
"Вы ввели неверный пароль.\n\
У Вас осталось %d/3 попыток ввода.", 3 - playerVariable[playerid][WrongPassword]);
ShowPlayerDialog(playerid, DIALOG_WRONGPAS, DIALOG_STYLE_MSGBOX, "Ошибка.", dialog, "Повтор", "Отмена");
}
return 1;
}