SA-MP Forums Archive
[FIXED] cache_get_data issue - 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: [FIXED] cache_get_data issue (/showthread.php?tid=575990)



[FIXED] cache_get_data issue - MotherDucker - 31.05.2015

Hello everyone, I was wondering if someone could tell me what is wrong with this code.. when I connect to the server, it runs the query and checks if there is an account under my username, which there is; however it doesn't return any rows.

Код:
public OnPlayerConnect(playerid)
{
	MasterData[playerid][uName] = GetPlayerName(playerid, str, sizeof(str));
	mysql_format(sql, query, sizeof(query), "SELECT * FROM masterdata WHERE uName = '%s'", MasterData[playerid][uName]);
	mysql_tquery(sql, query, "ExistingAccount", "i", playerid);
	return 1;
}
Код:
public ExistingAccount(playerid)
{
	cache_get_data(rows, fields);
	printf("There are %i rows and %i fields", rows, fields);
	if(rows > 0)
	{
		format(str, sizeof(str), "Welcome back, %s!\nPlease enter your account password below:", MasterData[playerid][uName]);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Duck's Roleplay - Login", str, "Login", "Quit");
	}
	else
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Duck's Roleplay - Registration", "Welcome to Duck's Roleplay!\nPlease enter a password for your account below:", "Create", "Quit");
	}
	return 1;
}
When you connect to the server, it is supposed to get your data, i.e. check if there is an account by checking if there is an ID with the your username, and if there is; then it is supposed to show the dialog "Welcome back, %s!" however because it isn't returning the rows, it just sends you to the "Welcome to Duck's Roleplay!". Please help, Thank you.


Re: cache_get_data issue - Konstantinos - 31.05.2015

It doesn't return the name:
pawn Код:
GetPlayerName(playerid, MasterData[playerid][uName], MAX_PLAYER_NAME);



Re: cache_get_data issue - MotherDucker - 31.05.2015

Oh yeah, Thanks; I didn't think I left that in, It's working now.