18.03.2016, 13:15
As I am new to this mysql thingy, I can't answer your question, if I would I'd lie anyways.
Anyways, this my onplayerconnect and OnAccountCheck
Anyways, this my onplayerconnect and OnAccountCheck
PHP Code:
public OnPlayerConnect(playerid)
{
new query[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
TogglePlayerSpectating(playerid, 1);
mysql_format(mysql, query, sizeof query, "SELECT 'Password', 'ID' FROM 'accounts' WHERE 'Name' = '%e' LIMIT 1", pName);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
SendClientMessage(playerid, COLOR_GREEN, "Awoo welcome back homie!");
return 1;
}
PHP Code:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "Password", PlayerInfo[playerid][pPassword], mysql, 129);
PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Welcome Enter your password to login", "Test Server", "Login", "Cancel");
}
else
{
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Welcome Create a password to register", "Test Server","Register", "Cancel");
}
return 1;
}