Okey, now i have other problem. Query is good, but still nothing happens.
Код:
public OnPlayerRequestClass(playerid, classid)
{
new query[80];
if (IsPlayerNPC(playerid)) return SpawnPlayer(playerid);
TogglePlayerSpectating(playerid, 1);
mysql_reconnect();
mysql_real_escape_string(LoginName(playerid), LoginName(playerid));
format(query, sizeof(query), "SELECT gid,uid FROM `mybb_players` WHERE username='%s' LIMIT 1", LoginName(playerid));
mysql_query(query, 0, playerid);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "...", "Login", "Change nick");
return 1;
}
and second query in OnDialogResponse
Код:
case 1: // Login Input
{
if (response)
{
new query[180];
mysql_reconnect();
mysql_real_escape_string(inputtext, inputtext);
format(query, sizeof(query), "SELECT * FROM mybb_players WHERE uid=%d AND gid=(SELECT uid FROM mybb_users WHERE uid=%d AND password=MD5('%s')) LIMIT 1",
PlayerData[playerid][pUID], PlayerData[playerid][pGID], inputtext);
mysql_query(query, 1, playerid);
}
else
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Zmiana nicku postaci", "Aby zmienić nick, wprowadź nowy nick do pola i zatwierdź.\nPamiętaj, że nick nie może zawierać znakуw: !#^&*(){}|<>?, oraz procentu", "Zmień nick", "Anuluj");
}
}
And OnQueryFinish
Код:
case 0: // Getting Global ID
{
if (IsPlayerConnected(extraid))
{
new field[11];
mysql_store_result();
if (mysql_retrieve_row())
{
mysql_fetch_field_row(field, "uid"); PlayerData[extraid][pUID] = strval(field);
mysql_fetch_field_row(field, "gid"); PlayerData[extraid][pGID] = strval(field);
}
mysql_free_result();
}
else
{
mysql_store_result();
mysql_free_result();
}
return 1;
}
case 1: // Loading Player Data
{
if (IsPlayerConnected(extraid))
{
new string[128], field[11];
mysql_store_result();
if (mysql_retrieve_row())
{
mysql_fetch_field_row(field, "admin"); PlayerData[extraid][pAL] = strval(field);
mysql_fetch_field_row(field, "blocked"); PlayerData[extraid][pBlocked] = strval(field);
mysql_fetch_field_row(field, "muted"); PlayerData[extraid][pMute] = strval(field);
mysql_fetch_field_row(field, "aj"); PlayerData[extraid][pAJ] = strval(field);
mysql_fetch_field_row(field, "vi"); PlayerData[extraid][pVI] = strval(field);
mysql_fetch_field_row(field, "health"); PlayerData[extraid][pHealth] = floatstr(field);
mysql_fetch_field_row(field, "gender"); PlayerData[extraid][pGender] = strval(field);
mysql_fetch_field_row(field, "money"); PlayerData[extraid][pMoney] = strval(field);
mysql_fetch_field_row(field, "bank"); PlayerData[extraid][pBank] = strval(field);
mysql_fetch_field_row(field, "faction"); PlayerData[extraid][pFaction] = strval(field);
mysql_fetch_field_row(field, "rfaction"); PlayerData[extraid][pFactionRank] = strval(field);
mysql_fetch_field_row(field, "business"); PlayerData[extraid][pBusiness] = strval(field);
mysql_fetch_field_row(field, "rbusiness"); PlayerData[extraid][pBusinessRank] = strval(field);
mysql_fetch_field_row(field, "x"); PlayerData[extraid][pLastPos][0] = floatstr(field);
mysql_fetch_field_row(field, "y"); PlayerData[extraid][pLastPos][1] = floatstr(field);
mysql_fetch_field_row(field, "z"); PlayerData[extraid][pLastPos][2] = floatstr(field);
mysql_fetch_field_row(field, "angle"); PlayerData[extraid][pLastPos][3] = floatstr(field);
mysql_fetch_field_row(field, "vw"); PlayerData[extraid][pVW] = strval(field);
mysql_fetch_field_row(field, "interior"); PlayerData[extraid][pInterior] = strval(field);
mysql_fetch_field_row(field, "skin"); PlayerData[extraid][pSkin] = strval(field);
mysql_fetch_field_row(field, "online"); PlayerData[extraid][pOnline] = strval(field);
PlayerData[extraid][pMessages] = 1;
format(string, sizeof(string), "Zalogowałeś się jako %s (ID %d, UID %d, GID %d). Miłej gry!", PlayerName(extraid), extraid, PlayerData[extraid][pUID], PlayerData[extraid][pGID]);
SendClientMessage(extraid, COLOR_DARKRED, string);
}
mysql_free_result();
}
else
{
mysql_store_result();
mysql_free_result();
}
}