06.01.2019, 22:22
Hi, so I have decided to make a system where players can have their main accounts and register up to 3 characters in it. Everything is working fine except the characters won't show to the player when he successfully logins to his main account.. Here's the code:
It says I don't have any character registered on my account ID (which is UserID) but I do have 2 registered on that ID, so it's really weird..
pawn Code:
forward OnPasswordChecked(playerid);
public OnPasswordChecked(playerid)
{
new bool:match = bcrypt_is_equal();
if(match)
{
new userid = PlayerInfo[playerid][UserID];
new query[500];
mysql_format(Database, query, sizeof(query), "SELECT * FROM `characters` WHERE `AccountID` = '%i'", userid);
mysql_pquery(Database, query, "SelectCharForPlayer", "dd", playerid, userid);
}
else
{
new string[300];
format(string, sizeof(string), "Wrong Password!\nPlease type your correct password below.");
Dialog_Show(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Exit");
}
return 1;
}
pawn Code:
forward SelectCharForPlayer(playerid, userid);
public SelectCharForPlayer(playerid, userid)
{
new charactername[24], characterage, charactergender[50], string[500], charinfo[500];
if(cache_num_rows())
{
for(new i = 0; i < cache_num_rows(); i++)
{
cache_get_value_name(i, "CharacterName", charactername, 24);
cache_get_value_name(i, "CharacterGender", charactergender, 50);
cache_get_value_name_int(i, "CharacterAge", characterage);
format(charinfo, sizeof(charinfo), "{FFFFFF}Name: %s - Gender: %s - Age: %d\n", charactername, charactergender, characterage);
strcat(string, charinfo);
Dialog_Show(playerid, DIALOG_SELECTCHARACTER, DIALOG_STYLE_LIST, "{FFFFFF}Character Selection", string, "Continue", "Exit");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You don't have any character registered on your account ID.");
}
return 1;
}