03.04.2015, 15:03
@will yes, i have the compatible version ( mysql R39-2)
@Chlorine yes check
Query :
Dialog response :
@Chlorine yes check
PHP код:
public OnAccountCheck(playerid)
{
new rows, fields, string[240], plrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
cache_get_data(rows, fields, g_iHandle);
if(rows) //if there is row
{
cache_get_field_content(0, "Password", APlayerData[playerid][PlayerPassword], g_iHandle, 129);
APlayerData[playerid][CompteID] = cache_get_field_content_int(0, "ID");
printf("MDP CHARGE : %s", APlayerData[playerid][PlayerPassword]);
format(string, 2000, TXT_DialogLoginMsg, GetPlayerNameEx(playerid), plrIP);
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, TXT_DialogLoginTitle, string, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
}
else
{
new strStartRules[2000];
// RULES TEXT
ShowPlayerDialog(playerid, DialogStartRules, DIALOG_STYLE_MSGBOX, "Rиglement du serveur", strStartRules, "Refuser", "Accepter");
}
printf("ETAT DU SERVEUR : CHECK D'UN COMPTE");
return 1;
}
PHP код:
mysql_format(g_iHandle, query, sizeof(query),"SELECT `Password`, `ID` FROM `users` WHERE `PlayerName` = '%e' LIMIT 1", GetPlayerNameEx(playerid));
mysql_tquery(g_iHandle, query, "OnAccountCheck", "i", playerid);
PHP код:
// Process the login-dialog
Dialog_Login(playerid, response, inputtext[])
{
switch (response) // Check which button was clicked
{
case 1: // Player clicked "Login"
{
// Check if the player entered a password
if (strlen(inputtext) > 0)
{
new query[100]; // for formatting our query.
if(!strcmp(inputtext, APlayerData[playerid][PlayerPassword]))
{
mysql_format(g_iHandle, query, sizeof(query), "SELECT * FROM `users` WHERE `ID` = '%d' LIMIT 1", APlayerData[playerid][CompteID]);
mysql_tquery(g_iHandle, query, "PlayerFile_Load", "i", playerid);
mysql_format(g_iHandle, query, sizeof(query), "SELECT * FROM `bank` WHERE `ID` = '%d' LIMIT 1", APlayerData[playerid][CompteID]);
mysql_tquery(g_iHandle, query, "BankFile_Load", "i", playerid);
format(query, sizeof(query), "UPDATE `users` SET `LoggedIN` = '1' WHERE `ID` = %d", APlayerData[playerid][CompteID]);
mysql_format(g_iHandle, query, sizeof(query), "%s", query);
mysql_tquery(g_iHandle, query);
APlayerData[playerid][LoggedIn] = true;
}
else
{
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, TXT_DialogLoginTitle, TXT_LoginEnterPasswordWrong, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
}
return 1;
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
KickEx(playerid);
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be logged in to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
// Kick the player
KickEx(playerid);
}
}
return 1;
}