Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Feb 14, 2024
1 parent f33195e commit a33c8ab
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 25 deletions.
2 changes: 2 additions & 0 deletions cstrike/addons/amxmodx/data/lang/redm/redm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ NextGameMode = next game mode
Choose = Choose
Selecting = Selecting
Extend = extend
ReDeathmatchSettingsMenu = ReDeathmatch settings:


[ru]
Expand All @@ -40,6 +41,7 @@ NextGameMode = следующий игровой режим
Choose = Выберите
Selecting = Выбор
Extend = продлить
ReDeathmatchSettingsMenu = ReDeathmatch настройки:

[cn]
Currently = 当前
Expand Down
4 changes: 3 additions & 1 deletion cstrike/addons/amxmodx/scripting/ReDeathmatch.sma
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ReDeathmatch/ReDM_equip_manager.inc"
#include "ReDeathmatch/ReDM_features.inc"
#include "ReDeathmatch/ReDM_round_modes.inc"
#include "ReDeathmatch/ReDM_settings_menu.inc"
#include "ReDeathmatch/ReDM_api.inc"


Expand Down Expand Up @@ -50,7 +51,7 @@ public plugin_init() {
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0,
.flags = _FCVAR_BOOLEAN,
.description = "Controls the state of Re:DM. \
.description = "Controls the state of Re:DM.^n\
Don't use into ReDM configs!"
),
redm_active
Expand Down Expand Up @@ -81,6 +82,7 @@ public plugin_cfg() {
EquipManager_Init()
Config_Init()
RoundModes_Init()
SettingsMenu_Init()

SetActive(redm_active)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AimBarriers_Init() {
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0,
.flags = _FCVAR_BOOLEAN,
.description = "Enable a barrier in the middle of the map (`anti-rush' system). \
.description = "Enable a barrier in the middle of the map (`anti-rush' system).^n\
It does not work on `de_`, `cs_` `css_` maps."
),
redm_aim_barrier
Expand All @@ -35,10 +35,11 @@ AimBarriers_Init() {
"redm_aim_barrier_always_show", "2",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 2.0,
.description = "Barrier display mode. \
`0` - disable, \
`1` - display permanently (beta), \
`2` - display only when touched."
.flags = _FCVAR_INTEGER,
.description = "Barrier display mode. ^n\
^t`0` - disable, ^n\
^t`1` - display permanently (beta), ^n\
^t`2` - display only when touched."
),
redm_aim_barrier_always_show
)
Expand Down
2 changes: 2 additions & 0 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch/Modes/Vote.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ModeVote_Init() {
create_cvar(
"redm_mode_vote_time", "15",
.has_min = true, .min_val = 0.0,
.flags = _FCVAR_INTEGER,
.description = "Time to vote for the next mode (sec)."
),
redm_mode_vote_time
Expand All @@ -49,6 +50,7 @@ ModeVote_Init() {
create_cvar(
"redm_mode_vote_extend_times", "1",
.has_min = true, .min_val = 0.0,
.flags = _FCVAR_INTEGER,
.description = "How many times can the game mode be extended."
),
redm_mode_vote_extend_times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,18 @@ DumpAllSettings(const player = 0, const prefix[] = "redm_") {
formatex(valueStr, charsmax(valueStr), "%.2f", get_pcvar_float(cvarHandle))
else
get_pcvar_string(cvarHandle, valueStr, charsmax(valueStr))

enum Bounds_s {
bool: hasBound,
Float: value
}

new bounds[CvarBounds][Bounds_s]

for (new CvarBounds: boundType; boundType < CvarBounds; boundType++) {
bounds[boundType][hasBound] = get_pcvar_bounds(cvarHandle, boundType, bounds[boundType][value])
bounds[boundType][b_hasBound] = get_pcvar_bounds(cvarHandle, boundType, bounds[boundType][b_value])
}

new boundsBuffer[32]
if (bounds[CvarBound_Lower][hasBound] || bounds[CvarBound_Upper][hasBound]) {
if (bounds[CvarBound_Lower][b_hasBound] || bounds[CvarBound_Upper][b_hasBound]) {
formatex(boundsBuffer, charsmax(boundsBuffer), "%s .. %s",
bounds[CvarBound_Lower][hasBound] ? fmt("%.1f", bounds[CvarBound_Lower][value]) : " - ",
bounds[CvarBound_Upper][hasBound] ? fmt("%.1f", bounds[CvarBound_Upper][value]) : " - "
bounds[CvarBound_Lower][b_hasBound] ? fmt("%.1f", bounds[CvarBound_Lower][b_value]) : " - ",
bounds[CvarBound_Upper][b_hasBound] ? fmt("%.1f", bounds[CvarBound_Upper][b_value]) : " - "
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ RoundModes_Init() {
create_cvar(
"redm_modes_switch", "sequentially",
.flags = (_FCVAR_STRING | _FCVAR_BOOLEAN),
.description = "Game mode change mode. \
`0`, `disable` - disable modes, \
`random` - random change, \
.description = "Game mode change mode. ^n\
`0`, `disable` - disable modes, ^n\
`random` - random change, ^n\
`sequentially` - sequential mode change."
),
redm_modes_switch,
Expand Down
262 changes: 262 additions & 0 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_settings_menu.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
SettingsMenu_Init() {
register_concmd(
"redm_settings_menu",
"ConCmd_redm_settings_menu",
ADMIN_MAP,
"Open ReDM settings menu."
)

register_clcmd(
"enter_ChangeSettingValue",
"ClCmd_ChangeSettingValue",
ADMIN_MAP,
.FlagManager = false
)

register_clcmd("radio1", "ConCmd_redm_settings_menu")
}

public ConCmd_redm_settings_menu(const player, const level, const commandId) {
SetGlobalTransTarget(player)

if (!cmd_access(player, level, commandId, 1))
return PLUGIN_HANDLED

if (!IsActive())
return PLUGIN_HANDLED

Menu_Settings(player)
return PLUGIN_HANDLED
}

public ClCmd_ChangeSettingValue(const player, const level, const commandId) {
if (!cmd_access(player, level, commandId, 1))
return PLUGIN_HANDLED

static newValue[128]
read_argv(1, newValue, charsmax(newValue))

if (!newValue[0]) {
Menu_ChangeSettingsItem(player, .cvarIndex = strtol(cvarIndexStr))

return PLUGIN_HANDLED
}

// client_print_color(
// player,
// print_team_red,
// "%L %L (%s)",
// id,
// "Gag_prefix",
// id,
// "Gag_YouSetManual_Reason",
// g_adminTempData[id][gd_reason][r_name]
// )

Menu_ChangeSettingsItem(player, .cvarIndex = strtol(cvarIndexStr))
return PLUGIN_HANDLED
}
static bool: Menu_Settings(const player) {
if (!is_user_connected(player))
return false

SetGlobalTransTarget(player)

new menuTitle[128]
formatex(menuTitle, charsmax(menuTitle), "%l", "ReDeathmatchSettingsMenu")

new menu = menu_create(menuTitle, "MenuHandler_Settings")

for (new cvarIndex; cvarIndex < 100; cvarIndex++) {
new name[32]
new flags
new pluginId
new cvarHandle
new description[256]

new bool: found = get_plugins_cvar(
cvarIndex,
name, charsmax(name),
flags,
pluginId,
cvarHandle,
description, charsmax(description)
) != 0

if (!found)
continue

if (flags & FCVAR_PROTECTED)
continue

new const prefix[] = "redm_"
if (strncmp(name, prefix, strlen(prefix), .ignorecase = true) != 0)
continue

new valueStr[32]
if (flags & _FCVAR_FLOAT)
formatex(valueStr, charsmax(valueStr), "%.2f", get_pcvar_float(cvarHandle))
else
get_pcvar_string(cvarHandle, valueStr, charsmax(valueStr))

menu_additem(
menu,
fmt("%s: \y%s\w", name, valueStr),
.info = fmt("%i", cvarIndex)
)
}

menu_setprop(menu, MPROP_BACKNAME, fmt("%l", "BACK"))
menu_setprop(menu, MPROP_NEXTNAME, fmt("%l", "MORE"))
menu_setprop(menu, MPROP_EXITNAME, fmt("%l", "EXIT"))
menu_setprop(menu, MPROP_NUMBER_COLOR, "\y")

menu_display(player, menu)

return true
}

public MenuHandler_Settings(const player, const menu, const item) {
new info[3]
menu_item_getinfo(
menu, item,
.info = info,
.infolen = charsmax(info)
)

menu_destroy(menu)

if (!IsActive())
return PLUGIN_HANDLED

if (item < 0)
return PLUGIN_HANDLED

Menu_ChangeSettingsItem(player, .cvarIndex = strtol(info))

return PLUGIN_HANDLED
}

static bool: Menu_ChangeSettingsItem(const player, const cvarIndex) {
new name[32], flags, cvarHandle, description[328]

new bool: found = get_plugins_cvar(
cvarIndex,
name, charsmax(name),
flags,
.pcvar_handle = cvarHandle,
.description = description,
.desc_len = charsmax(description)
) != 0

if (!found)
return false

new valueStr[32]
if (flags & _FCVAR_FLOAT)
formatex(valueStr, charsmax(valueStr), "%.2f", get_pcvar_float(cvarHandle))
else
get_pcvar_string(cvarHandle, valueStr, charsmax(valueStr))

new bounds[CvarBounds][Bounds_s]
for (new CvarBounds: boundType; boundType < CvarBounds; boundType++) {
bounds[boundType][b_hasBound] = get_pcvar_bounds(cvarHandle, boundType, bounds[boundType][b_value])
}

SetGlobalTransTarget(player)

new menuTitle[128]
formatex(menuTitle, charsmax(menuTitle), "%l", "ReDeathmatchSettingsMenu")

new menu = menu_create(menuTitle, "MenuHandler_SettingsItem")
menu_additem(menu, fmt("Change value?"), .info = fmt("%i", cvarIndex))

new buffer[256]
formatex(buffer, charsmax(buffer), "^n\y%s\w: \r%s\w", name, valueStr)

strcat(buffer,
fmt("^n^nType: \r%s\w", GetCvarTypeStr(flags)),
charsmax(buffer)
)

new bool: hasBounds = (bounds[CvarBound_Lower][b_hasBound] || bounds[CvarBound_Upper][b_hasBound])
strcat(buffer,
hasBounds ?
fmt("^nBounds: \r%s\w - \r%s\w",
bounds[CvarBound_Lower][b_hasBound] ? GetBoundByType(flags, bounds[CvarBound_Lower][b_value]) : " - ",
bounds[CvarBound_Upper][b_hasBound] ? GetBoundByType(flags, bounds[CvarBound_Upper][b_value]) : " - "
)
:
"^nBounds: \dnone\w",
charsmax(buffer)
)

strcat(buffer,
fmt("^nDesc: ^n^t\d%s\w", description),
charsmax(buffer)
)

menu_addtext(menu, buffer, .slot = true)

menu_setprop(menu, MPROP_EXITNAME, fmt("%l", "EXIT"))
menu_setprop(menu, MPROP_NUMBER_COLOR, "\y")

menu_display(player, menu)
return true
}

GetBoundByType(const flags, const Float: bound) {
new buff[10]
if (flags & _FCVAR_FLOAT)
formatex(buff, charsmax(buff), "%.1f", bound)

if (flags & _FCVAR_BOOLEAN)
formatex(buff, charsmax(buff), "%s", floatround(bound) != 0 ? "true" : "false")

if (flags & _FCVAR_INTEGER)
formatex(buff, charsmax(buff), "%i", floatround(bound))

return buff
}

public MenuHandler_SettingsItem(const player, const menu, const item) {
new info[3]
menu_item_getinfo(
menu, item,
.info = info,
.infolen = charsmax(info)
)

menu_destroy(menu)

if (!IsActive())
return PLUGIN_HANDLED

if (item < 0) {
Menu_Settings(player)

return PLUGIN_HANDLED
}

new cvarIndex = strtol(info)

new name[32], flags, description[256]

new bool: found = get_plugins_cvar(
cvarIndex,
name, charsmax(name),
flags,
.description = description,
.desc_len = charsmax(description)
) != 0

if (!found)
return PLUGIN_HANDLED

server_print("CHANGE settings value: %i", cvarIndex)

client_cmd(player, "messagemode enter_ChangeSettingValue", cvarIndex)
Menu_ChangeSettingsItem(player, cvarIndex)

return PLUGIN_HANDLED
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SpawnManager_Init() {
create_cvar(
"redm_spawn_preset",
"preset",
.flags = _FCVAR_STRING
.flags = _FCVAR_STRING,
.description = "Method of work for the respawn manager."
),
redm_spawn_preset,
charsmax(redm_spawn_preset)
Expand Down
Loading

0 comments on commit a33c8ab

Please sign in to comment.