Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Theggv committed May 13, 2022
2 parents 6240cd8 + da28f4a commit 017e8d1
Show file tree
Hide file tree
Showing 34 changed files with 2,151 additions and 3,001 deletions.
56 changes: 51 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
# Kreedz mod

### Roadmap:
- Implement settings system
## Features
- Auto savepos on disconnect
- Settings system with auto save
- Practice in pause with checkpoints

### Special Thanks:
- [Credits](./CREDITS.md)
## Commands
### Basic
| Command | Description |
| --- | --- |
| `cp` | Make checkpoint |
| `tp` \| `gc` | Teleport to last checkpoint |
| `stuck` | Teleport to previous checkpoint |
| `p` \| `pause` \| `unpause` | Pause / unpause current run |
| `start` \| `restart` | Teleport to the start |
| `stop` \| `reset` | Stop timer |
| `nightvision` | Change nightvision mode |
| `+hook` | Enable / disable hook |
| `nc` \| `noclip` | Enable / disable noclip |
| `weapons` | Get all weapons |
| `spec` \| `ct` | Move to spectators / cts |

### Top
| Command | Description |
| --- | --- |
| `top` \| `top15` | Top menu |
| `pro15` | Pro top |
| `nub15` \| `noob15` | Nub top |
| `cfr` | Show your personal best record |
| `rec` \| `record` | Show map best pro record |

### Menus
| Command | Description |
| --- | --- |
| `invis` | Hide players and water menu |
| `menu` | Main menu |
| `settings` | Settings menu |
| `ljsmenu` | Jump stats menu |
| `mute` | Mute menu |

### Deployment
### Addons
| Command | Description |
| --- | --- |
| `fog` | Enable / disable frames on ground feature |
| `sunglasses` | Fade screen for bright maps |
| `measure` | Measure distance from point A to B |
| `wr` | Show world record in hud |
| `goto` | Teleport to the player |
---

## Deployment
- Clone repository.
- Install dependencies `npm i`

Expand All @@ -27,3 +70,6 @@ npm run watch
```bash
npm run pack
```

### Special Thanks:
- [Credits](./CREDITS.md)
4 changes: 3 additions & 1 deletion assets/addons/amxmodx/configs/kreedz.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
kz_sql_hostname = "127.0.0.1"
kz_sql_username = "user"
kz_sql_password = "password"
kz_sql_database = "database"
kz_sql_database = "database"

kz_records_frontend_url = "http://127.0.0.1:3000"
8 changes: 6 additions & 2 deletions assets/addons/amxmodx/configs/plugins-kz.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ kz_spec.amxx debug
kz_weapons.amxx debug
kz_menu.amxx debug

; Settings
settings_core.amxx debug
settings_mysql.amxx debug
kz_settings.amxx debug

; Sql
kz_sql_core.amxx debug
kz_sql_savepos.amxx debug
kz_sql_settings.amxx debug
kz_sql_settings_timer.amxx debug
kz_sql_top.amxx debug
; kz_sql_top_web.amxx debug ; disable kz_sql_top.amxx to use web version

; Addons
kz_measure.amxx debug
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kreedz-amxx",
"version": "1.0.3",
"version": "1.0.4",
"author": "ggv",
"description": "Kreedz AMXX",
"scripts": {
Expand Down
13 changes: 0 additions & 13 deletions src/include/kreedz_api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ enum _:PosStruct {
Float:pos_z,
};

enum _:SettingsStruct {
bool:set_IsSaveAngles,
bool:set_IsRadioEnable
};

enum _:TimerStruct {
timer_RGB,
Float:timer_X,
Expand Down Expand Up @@ -98,14 +93,6 @@ native kz_set_last_cp(id, value[PosStruct]);
native Float:kz_get_actual_time(id);
native kz_set_start_time(id, Float:value);

native kz_get_settings(id, value[SettingsStruct]);
native kz_set_settings(id, value[SettingsStruct]);

native kz_get_timer_data(id, value[TimerStruct]);
native kz_set_timer_data(id, value[TimerStruct]);

native kz_is_radio_enable(id);

//
// Hook & noclip section
//
Expand Down
2 changes: 2 additions & 0 deletions src/include/kreedz_sql.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ forward kz_sql_data_recv(id);

forward kz_top_new_pro_rec(id, Float:fTime);

forward kz_top_new_nub_rec(id, Float:fTime, checkpointsCount, teleportsCount);

native kz_sql_get_user_uid(id);

native kz_sql_get_map_uid();
Expand Down
17 changes: 17 additions & 0 deletions src/include/kreedz_util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#define _kreedz_util_included

#include <reapi>

stock kz_register_cmd(szCmd[], szHandler[]) {
new szFormatedCmd[64];

Expand Down Expand Up @@ -113,4 +115,19 @@ stock UTIL_TimerRoundtime(id, time) {
message_begin(MSG_ONE_UNRELIABLE, msgRoundTime, .player = id);
write_short(time + 1);
message_end();
}

stock bool:is_user_spectating(iAlive, iSpec) {
if (!is_user_connected(iSpec) || is_user_alive(iSpec) || is_user_bot(iSpec))
return false;

if (get_entvar(iSpec, var_iuser1) != 1 &&
get_entvar(iSpec, var_iuser1) != 2 &&
get_entvar(iSpec, var_iuser1) != 4)
return false;

if (get_entvar(iSpec, var_iuser2) != iAlive)
return false;

return true;
}
94 changes: 94 additions & 0 deletions src/include/settings_api.inc
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]);
28 changes: 28 additions & 0 deletions src/include/settings_util.inc
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
Loading

0 comments on commit 017e8d1

Please sign in to comment.