[MySQL] Check Account not quite working
#1

Hello simple function t check to see if the account is created,

http://pastebin.com/E7B4HtC5

But its not working, any ideas?
Reply
#2

I'm assuming each and every player that registers an account on your server is saved in SQL. Why don't you pull the SQL ID instead?

On my server when a player connects OnPlayerConnect runs the query that pulls up basic player account information such as the SQLid, name and password and loads it into the PlayerInfo enum I have setup.

So then when it hits OnPlayerRequestClass it checks to see if PlayerInfo[playerid][pSQLId] exists, if it does it loads the regular username/password dialog. If it doesn't then it runs through the player registration system.
Reply
#3

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
      {
      }
}
Reply
#4

Quote:
Originally Posted by coakiddo
Посмотреть сообщение
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
      {
      }
}

Thanks i need to check the plauers account for OnPlayerConnect to show the correct dialog

Код:
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;
    }
I have no use for CheckAccount? new to MySQL and its confusing a little
Reply
#5

PHP код:
public OnPlayerConnect(playerid)
{
     new 
string[128],account[MAX_PLAYER_NAME];
     
GetPlayerName(playerid,account,sizeof(account));
     
format(stringsizeof(string), "SELECT * FROM `users` WHERE `Name` = '%s' LIMIT 1"account);
     
mysql_function_query(mConstringtrue"CheckAccount""i",playerid);
     return 
1;
}
forward CheckAccount(playerid);
public 
CheckAccount(playerid)
{
      new 
rowsfields;
      
cache_get_data(rowsfields);
      if(
rows// Login code here
      
{
      }
      else 
// Register code here
      
{
      }
      return 
1;

There, also read this: http://forum.sa-mp.com/showpost.php?...postcount=2141
Reply
#6

hey it works ok but its showing the Register Dialog for me even though my accunt is registered?

Код:
	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;
}
Reply
#7

Bump, anyone know why its not quite working?
Reply
#8

sorry to double bump, but its pretty urgunt now
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)