02.04.2016, 17:39
I have this function, when I try to register it doesn't insert.... in to the database.
PHP код:
stock Construct_PlayerConnected(playerid) {
inline OnCheckPlayerAccount() {
new rows, fields, content[129];
cache_get_data(rows, fields, SQLConnection);
if(rows) {
new loadedPassword[129];
cache_get_field_content(0, "ID", content, SQLConnection);
PlayerInfo[playerid][SQLID] = strval(content);
cache_get_field_content(0, "Password", loadedPassword, SQLConnection);
inline LoginResponse(pid, response, listitem, string:inputtext[]) {
#pragma unused pid, listitem
switch(response) {
case 0: {
// SetTimerEx("ToKick", 500, false, "dsd", playerid, "Quit on Login!", ADMIN_ANNOUCE);
}
default: {
new passWordLogged[129];
WP_Hash(passWordLogged, 129, inputtext);
if(!strcmp(passWordLogged, loadedPassword)) {
inline LoadPlayerAccount() {
new iGet[256];
cache_get_field_content(0, "Money", iGet, SQLConnection); PlayerInfo[playerid][Money] = strval(iGet); ResetPlayerMoney(playerid), GivePlayerMoney(playerid, strval(iGet));
cache_get_field_content(0, "Bank", iGet, SQLConnection); PlayerInfo[playerid][Bank] = strval(iGet);
cache_get_field_content(0, "Score", iGet, SQLConnection); PlayerInfo[playerid][Score] = strval(iGet); SetPlayerScore(playerid, strval(iGet));
cache_get_field_content(0, "Points", iGet, SQLConnection); PlayerInfo[playerid][Points] = strval(iGet);
cache_get_field_content(0, "TotalPlayTime", iGet, SQLConnection); PlayerInfo[playerid][TotalPlayTime] = strval(iGet);
SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 );
SpawnPlayer(playerid);
return 1;
}
new iQuery[128];
mysql_format(SQLConnection, iQuery, sizeof(iQuery), "SELECT * FROM `PlayerInfo` WHERE `ID` = %d LIMIT 1", PlayerInfo[playerid][SQLID]);
mysql_tquery_inline(SQLConnection, iQuery, using inline LoadPlayerAccount, "");
} else {
PlayerTemp[playerid][loginAttempts]++;
if(PlayerTemp[playerid][loginAttempts] >= 3) {
// SetTimerEx("ToKick", 500, false, "dsd", playerid, "Login limit exceeded!", ADMIN_ANNOUCE);
return 1;
} else {
return Construct_PlayerConnected(playerid), 0;
}
}
}
}
}
Dialog_ShowCallback(playerid, using inline LoginResponse, DIALOG_STYLE_PASSWORD, "{3196ef} - "SERVER_GM"{adc7e7}", " {FFFFFF}Please enter your password to Login", "Login", " ");
} else {
inline RegisterResponse(pid, response, listitem, string:inputtext[]) {
#pragma unused pid, listitem
switch(response) {
case 0: {
// SetTimerEx("ToKick", 500, false, "dsd", playerid, "Quit on Register!", ADMIN_ANNOUCE);
}
default: {
if(strlen(inputtext) > 40 || strlen(inputtext) < 5 || !strlen(inputtext)) {
//SendClientWarning(playerid, "Invalid Password, please try again!");
return Construct_PlayerConnected(playerid), 1;
} else {
new iQuery[256], passwordHashed[129];
WP_Hash(passwordHashed, 129, inputtext);
mysql_format(SQLConnection, iQuery, sizeof(iQuery), "INSERT INTO `PlayerInfo` (`PlayerName`, `Password`) VALUES ('%e', '%s')", ReturnPlayerName(playerid), passwordHashed);
mysql_tquery(SQLConnection, iQuery);
Construct_PlayerConnected(playerid);
return 1;
}
}
}
}
Dialog_ShowCallback(playerid, using inline RegisterResponse, DIALOG_STYLE_PASSWORD, "{3196ef} - "SERVER_GM"{adc7e7}", " {FFFFFF}Please enter your password to Register", "Register", "");
}
}
new iQuery[128];
mysql_format(SQLConnection, iQuery, sizeof(iQuery), "SELECT `ID`, `Password` FROM `PlayerInfo` WHERE `PlayerName` = '%e' LIMIT 1", ReturnPlayerName(playerid));
mysql_tquery_inline(SQLConnection, iQuery, using inline OnCheckPlayerAccount, "");
return 1;
}