06.05.2013, 13:58
Hey There,
I started using Mysql for the first time today, I followed some tutorials but they turn out to be out-dated.
How do I change these things into a working BlueG mysql system?
I started using Mysql for the first time today, I followed some tutorials but they turn out to be out-dated.
How do I change these things into a working BlueG mysql system?
pawn Код:
public OnPlayerConnect(playerid)
{
new query[126];
format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s'", GetName(playerid));
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendClientMessage(playerid, RED, "This account is already registered");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Login", "Please login with your password", "Login", "Cancel");
}
else
{
SendClientMessage(playerid, GREEN, "This account does not exist yet");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Please Register by entering a password", "Register", "Cancel");
}
return 1;
}
pawn Код:
stock LoginPlayer(playerid)
{
new query[126];
format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s'", GetName(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(Player[playerid][Name], "Name");
mysql_fetch_field_row(Player[playerid][Password], "Password");
mysql_fetch_field_row(Player[playerid][Adminlevel], "Adminlevel");
}
SetSpawnInfo(playerid, 0, 240, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
stock SavePlayer(playerid)
{
new query[126];
format(query, sizeof(query), "UPDATE accounts SET name = '%s', password = '%s', Adminlevel = '%s' WHERE name = '%s'", GetName(playerid), Player[playerid][Password], Player[playerid][Adminlevel], GetName(playerid));
mysql_query(query);
printf("Player %d (%s) has been saved because of disconecting", playerid, GetName(playerid));
}