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;
}
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));
}
As the thread suggests, if you don't know the difference between a threaded and a non-threaded query, you shouldn't be using R7. Also, you may want to note that R7 is NOT the latest version. There are plenty more on the ****** Code download page (there's a link at the top of the plugin release thread).
Furthermore, there's a tutorial about using threaded queries (or, more accurately, the cache functions provided by the threaded queries part of the system) by AndreT. I'll suggest you check it out for yourself. https://sampforum.blast.hk/showthread.php?tid=337810 |
Obviously the version under R7. However, it would be utterly stupid of you to use non-threaded queries.
|