16.01.2013, 03:00
Hello simple function t check to see if the account is created,
http://pastebin.com/E7B4HtC5
But its not working, any ideas?
http://pastebin.com/E7B4HtC5
But its not working, any ideas?
stock CheckAccountExists(account[]) { new string[128]; format(string, sizeof(string), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", account); mysql_function_query(mCon, string, true, "CheckAccount", "",""); return 1; }
forward CheckAccount(); public CheckAccount() { new rows, fields; cache_get_data(rows, fields); if(rows) // registered { } else // Not registered { } }
You are not using threaded queries correctly.
https://sampforum.blast.hk/showthread.php?tid=337810 Код:
stock CheckAccountExists(account[]) { new string[128]; format(string, sizeof(string), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", account); mysql_function_query(mCon, string, true, "CheckAccount", "",""); return 1; } Код:
forward CheckAccount(); public CheckAccount() { new rows, fields; cache_get_data(rows, fields); if(rows) // registered { } else // Not registered { } } |
public OnPlayerConnect(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); if(CheckAccountExists(name)) { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/ } else { ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit"); return 1; }
public OnPlayerConnect(playerid)
{
new string[128],account[MAX_PLAYER_NAME];
GetPlayerName(playerid,account,sizeof(account));
format(string, sizeof(string), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", account);
mysql_function_query(mCon, string, true, "CheckAccount", "i",playerid);
return 1;
}
forward CheckAccount(playerid);
public CheckAccount(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows) // Login code here
{
}
else // Register code here
{
}
return 1;
}
new string[128],account[MAX_PLAYER_NAME]; GetPlayerName(playerid,account,sizeof(account)); format(string, sizeof(string), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1", account); mysql_function_query(mCon, string, true, "CheckAccount", "i",playerid); forward CheckAccount(playerid,account[]); public CheckAccount(playerid,account[]) { new rows, fields; cache_get_data(rows, fields); if(rows) // registered { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit"); } else // Not registered { ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit"); } return 1; }