22.12.2012, 16:26
I'm having issue with getting if there's any player name in row with connected player name.
OnPlayerConnect i have
in custon public OnAccountCheckExists i have:
All this code should select name with player name that is connected and onAccountCheck it should set hasAccount[playerid] to 0 if there's no on with that name in table or if there is someone with that name then hasAccount[playerid] should be set to 1.
Problem is that hasAccount returns all the time 0...
Here's second thing i tried:
OnPlayerAccount:
Still same issue, hasAccount returned 0 every time tho i have account registered. It can't find my account from my row so it returns it 0.
OnPlayerConnect i have
pawn Код:
format(query, sizeof(query), "SELECT `Name` FROM `accounts` WHERE `Name` = '%s' LIMIT 1", returnName(playerid));
mysql_function_query(dbHandle, query, true, "OnAccountCheckExists", "d", playerid);
pawn Код:
public OnAccountCheckExists(playerid)
{
new rows, fields;
cache_get_data(rows,fields);
if(!rows) {
hasAccount[playerid] = 0;
} else {
hasAccount[playerid] = 1;
}
}
Problem is that hasAccount returns all the time 0...
Here's second thing i tried:
OnPlayerAccount:
pawn Код:
if(CheckAccount(UserStats[playerid][ID])) hasAccount[playerid] = 1;
pawn Код:
stock CheckAccount(playerid)
{
new query[82];
format(query, sizeof(query), "SELECT ID,Password FROM `accounts` WHERE `Name` = '%s' LIMIT 1", returnName(playerid));
mysql_function_query(dbHandle, query, true, "OnAccountCheck", "d", playerid);
return 1;
}
pawn Код:
public OnAccountCheck(playerid)
{
if(playerid != INVALID_PLAYER_ID) {
new rows, fields;
cache_get_data(rows, fields, dbHandle);
if(rows) {
new id[30];
cache_get_row(0, 0, id, dbHandle); UserStats[playerid][ID] = strval(id);
cache_get_row(0, 1, UserStats[playerid][pPass], dbHandle);
hasAccount[playerid] = 1;
}
else {
hasAccount[playerid] = 0;
}
}
return 1;
}