16.08.2013, 07:12
Код:
stock MySQL_NameExists(const account[]) { new szQuery[128], iRows = 0; format(szQuery, sizeof(szQuery), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", account); mysql_query(szQuery); mysql_store_result(); if (mysql_num_rows()) { iRows = 1; } else iRows = 0; mysql_free_result(); return iRows; } stock MySQL_UpdateFieldInt(const account[], const fieldname[], iValue) { new query[512]; format(query, sizeof(query), "UPDATE `accounts` SET `%s` = '%d' WHERE `Username` = '%s'", fieldname, iValue, account); mysql_query(query); return 1; } stock MySQL_UpdateFieldFloat(const account[], const fieldname[], Float:iValue) { new query[512]; format(query, sizeof(query), "UPDATE `accounts` SET `%s` = '%f' WHERE `Username` = '%s'", fieldname, iValue, account); mysql_query(query); return 1; } stock MySQL_UpdateFieldString(const account[], const fieldname[], szValue[]) { new query[512]; format(query, sizeof(query), "UPDATE `accounts` SET `%s` = '%s' WHERE `Username` = '%s'", fieldname, szValue, account); mysql_query(query); return 1; } stock MySQL_GetAccountField(const account[], const fieldname[], destination[]) { new query[128]; format(query, sizeof(query), "SELECT `%s` FROM `accounts` WHERE `Username` = '%s'", fieldname, account); mysql_query(query); mysql_store_result(); mysql_retrieve_row(); mysql_fetch_field_row(destination, fieldname); mysql_free_result(); return 1; } stock MySQL_GetAccountInt(const account[], const fieldname[]) { new destination[128]; MySQL_GetAccountField(account, fieldname, destination); return strval(destination); } stock Float:MySQL_GetAccountFloat(const account[], const fieldname[]) { new destination[128]; MySQL_GetAccountField(account, fieldname, destination); return floatstr(destination); }