CheckAccountConnection(playerid){
new pName[MAX_PLAYER_NAME], query[512];
GetPlayerName(playerid, pName, sizeof(pName));
mysql_format(MHandle, query, sizeof(query), "SELECT * FROM `character` WHERE `Username` = '%e' LIMIT 1", pName);
mysql_tquery(MHandle, query, "OnCharacterCheck", "i", playerid);
return 1;
}
forward OnCharacterCheck(playerid);
public OnCharacterCheck(playerid){
new rows, szFieldName[MAX_PLAYER_NAME];
cache_get_row_count(rows);
for(new row = 0; row < rows; row++){
cache_get_value(row, "Username", szFieldName);
if(!strcmp(szFieldName, GetPlayerNameEx(playerid))){
cache_get_value(row, "Password", Character[playerid][Password]);
cache_get_value(row, "Username", Character[playerid][Username]);
System_Scm(playerid, COLOR_YELLOW, "LOGIN", "This account was registered.");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Fill your password into the box below.", "Ok", "Cancel");
break;
}
else{
if(row == rows-1){
System_Scm(playerid, COLOR_YELLOW, "REGISTER", "You can register.");
PlayerRegistrationShow(playerid); // This is my registration textdraw.
break;
}
}
}
return 1;
}
CheckAccountConnection(playerid){ new pName[MAX_PLAYER_NAME], query[512]; GetPlayerName(playerid, pName, sizeof(pName)); mysql_format(MHandle, query, sizeof(query), "SELECT * FROM `character` WHERE `Username` = '%e' LIMIT 1", pName); print(query); mysql_tquery(MHandle, query, "OnCharacterCheck", "i", playerid); print(query); return 1; }
[11:56:09] [connection] 127.0.0.1:3087 requests connection cookie. [11:56:10] [connection] incoming connection: 127.0.0.1:3087 id: 0 [11:56:10] [join] Daniel_DAD has joined the server (0:127.0.0.1) [11:56:12] - Created Player Textdraw Sucessfully. [11:56:12] SELECT * FROM `character` WHERE `Username` = 'Daniel_DAD' LIMIT 1 [11:56:23] sscanf warning: Format specifier does not match parameter count. |
forward OnCharacterCheck(playerid);
public OnCharacterCheck(playerid){
new rows, szFieldName[MAX_PLAYER_NAME];
cache_get_row_count(rows); // I get all of the rows that is available now.
for(new row = 0; row < rows; row++){ // Let the variable 'row' run from 0 to the maximum rows.
cache_get_value_name(row, "Username", szFieldName); // I get the Username from each row.
if(!strcmp(szFieldName, GetPlayerNameEx(playerid))){ // I check if the Username of the row is the same with the player, then the player is registered.
cache_get_value_name(row, "Password", Character[playerid][Password]);
cache_get_value_name(row, "Username", Character[playerid][Username]);
System_Scm(playerid, COLOR_YELLOW, "LOGIN", "This account has been registered.");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "Fill your password into the box below", "Ok", "Cancel");
return 1; // Return 1 to end the program.
}
}
// if it can't check any row which is the same with the player username, means the player is not registered.
System_Scm(playerid, COLOR_YELLOW, "REGISTER", "You can register.");
PlayerRegistrationShow(playerid);
return 1;
}