-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,151 additions
and
3,001 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#if defined _settings_api_included | ||
#endinput | ||
#endif | ||
|
||
#define _settings_api_included | ||
|
||
// Comment this to disable debug messages | ||
// #define PRINT_DEBUG_MESSAGES | ||
|
||
#include <settings_util> | ||
|
||
#define MAX_OPTION_LENGTH 32 | ||
#define MAX_STR_VALUE_LENGTH 64 | ||
|
||
#define RESERVER_OPTION_END "#reserved_option_end" | ||
|
||
enum OptionFieldType { | ||
FIELD_TYPE_INT, | ||
FIELD_TYPE_FLOAT, | ||
FIELD_TYPE_BOOL, | ||
FIELD_TYPE_STRING, | ||
}; | ||
|
||
/** | ||
* Register option for players (int/float/bool value) | ||
* note: should be called in plugin_precache | ||
* | ||
* @param optionName option name | ||
* @param fieldType see `OptionFieldType` constants | ||
* @param defaultValue default value | ||
* | ||
* @noreturn | ||
*/ | ||
native register_players_option_cell(optionName[MAX_OPTION_LENGTH], OptionFieldType:fieldType, any:defaultValue = 0); | ||
|
||
/** | ||
* Register option for players (string value) | ||
* note: should be called in plugin_precache | ||
* | ||
* @param optionName option name | ||
* @param defaultValue default value | ||
* | ||
* @noreturn | ||
*/ | ||
native register_players_option_str(optionName[MAX_OPTION_LENGTH], defaultValue[MAX_STR_VALUE_LENGTH]); | ||
|
||
/** | ||
* Get option id by its name | ||
* note: should not be called in plugin_precache | ||
* | ||
* @param optionName option name | ||
* | ||
* @return -1 if option does not exist, id >= 0 otherwise | ||
*/ | ||
native find_option_by_name(optionName[MAX_OPTION_LENGTH]); | ||
|
||
native get_option_cell(id, optionId); | ||
|
||
native set_option_cell(id, optionId, newValue, bool:notifyMysql = true); | ||
|
||
native get_option_string(id, optionId, buffer[MAX_STR_VALUE_LENGTH]); | ||
|
||
native set_option_string(id, optionId, buffer[MAX_STR_VALUE_LENGTH], bool:notifyMysql = true); | ||
|
||
/** | ||
* Calls from `settings_mysql` when connection is ready | ||
* | ||
* @noreturn | ||
*/ | ||
forward OnConnectionIsReady(); | ||
|
||
/** | ||
* Calls after all options were created in database | ||
* | ||
* @noreturn | ||
*/ | ||
forward OnOptionsInitialized(); | ||
|
||
/** | ||
* Calls when option is ready to be initialized (after `OnConnectionIsReady`) | ||
* | ||
* @param optionName option name | ||
* @param fieldType see `OptionFieldType` constants | ||
* @param defaultValue default value | ||
*/ | ||
forward OnRegisterOption(optionName[MAX_OPTION_LENGTH], OptionFieldType:fieldType, defaultValue[MAX_STR_VALUE_LENGTH]); | ||
|
||
forward OnCellValueChanged(id, optionId, newValue); | ||
|
||
forward OnStringValueChanged(id, optionId, newValue[MAX_STR_VALUE_LENGTH]); | ||
|
||
forward OnNotifyMysqlCellValue(id, optionId, newValue); | ||
|
||
forward OnNotifyMysqlStringValue(id, optionId, newValue[MAX_STR_VALUE_LENGTH]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#if defined _settings_util_included | ||
#endinput | ||
#endif | ||
|
||
#define _settings_util_included | ||
|
||
stock UTIL_DebugMessage(const szMsg[], any:...) { | ||
// disable warning | ||
#pragma unused szMsg | ||
|
||
#if defined PRINT_DEBUG_MESSAGES | ||
new szFormatted[256]; | ||
|
||
vformat(szFormatted, 255, szMsg, 2); | ||
format(szFormatted, 255, "[SETTINGS_DEBUG] %s", szFormatted); | ||
|
||
server_print(szFormatted); | ||
#endif | ||
} | ||
|
||
#if !defined UTIL_LogToFile | ||
stock UTIL_LogToFile(const szPath[], const szLevel[], const szFunction[], const szMessage[], any:...) { | ||
new szMsg[512]; | ||
vformat(szMsg, charsmax(szMsg), szMessage, 5); | ||
|
||
log_to_file(szPath, "[%s][%s] %s", szLevel, szFunction, szMsg); | ||
} | ||
#endif |
Oops, something went wrong.