SA-MP Forums Archive
[MySQL] Check Account not quite working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MySQL] Check Account not quite working (/showthread.php?tid=407927)



[MySQL] Check Account not quite working - Kontrol - 16.01.2013

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

http://pastebin.com/E7B4HtC5

But its not working, any ideas?


Re: [MySQL] Check Account not quite working - Treyvan - 16.01.2013

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.


Re: [MySQL] Check Account not quite working - coakiddo - 16.01.2013

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
      {
      }
}



Re: [MySQL] Check Account not quite working - Kontrol - 16.01.2013

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


Re: [MySQL] Check Account not quite working - coakiddo - 16.01.2013

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


Re: [MySQL] Check Account not quite working - Kontrol - 16.01.2013

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;
}



Re: [MySQL] Check Account not quite working - Kontrol - 17.01.2013

Bump, anyone know why its not quite working?


Re: [MySQL] Check Account not quite working - Kontrol - 17.01.2013

sorry to double bump, but its pretty urgunt now