19.06.2016, 03:59
BlueG's recommended
Alright I will fix up the first phase for you:
Note that I used // where I had to fix something
About LoginPlayer,
Select all from the table and store it in a Cached variable
and then simply use cache_get_field_content for strings, cache_get_field_content_int for integers and cache_get_field_content_float for floats
See more here:
https://sampwiki.blast.hk/wiki/MySQL/R33#Cache_functions
Note: You HAVE to use cache_delete(cache id); after EVERY cache usage, unless you spend memory for nothing.
Alright I will fix up the first phase for you:
Note that I used // where I had to fix something
PHP код:
public OnPlayerConnect(playerid)
{
new query[126], pName[MAX_PLAYER_NAME], Cache:result; // added a cached variable instead of a threaded query, threaded queries are faster for me but you need to start from the basic
GetPlayerName(playerid, pName, sizeof(pName));
mysql_format(mysql, query, sizeof(query), "SELECT `admin` FROM `accounts` WHERE `name` = '%e'", pName); // Added `` between table name and column name
// The chosen column is Admin, use any column that exist in your table just to verify
//%e sepcifier to ignore escape string, You also have to turn it to mysql_format and add the connection handler to use the %e specifier
result = mysql_query(mysql, query); // You must identify the connection handle, store the cache in the variable
if(cache_get_row_count()) // if there were any rows found
{
SCM(pid, -1, "That username is registered!");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Please login with your password.", "Login", "Cancel");
}
else // No rows were found
{
SCM(pid, -1, "That username is not registered. You may use it.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Register", "Please enter a password to register.", "Register", "Cancel");
}
return 1;
}
Select all from the table and store it in a Cached variable
and then simply use cache_get_field_content for strings, cache_get_field_content_int for integers and cache_get_field_content_float for floats
See more here:
https://sampwiki.blast.hk/wiki/MySQL/R33#Cache_functions
Note: You HAVE to use cache_delete(cache id); after EVERY cache usage, unless you spend memory for nothing.