Skip to content

Commit

Permalink
Improve ConVar description
Browse files Browse the repository at this point in the history
- add `_FCVAR_INTEGER`
  • Loading branch information
SergeyShorokhov committed Mar 23, 2024
1 parent b2f22b2 commit c91f9b9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/ReDeathmatch.sma
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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
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
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
12 changes: 10 additions & 2 deletions cstrike/addons/amxmodx/scripting/include/redm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ enum _: ConVar_ExtendedFlags (<<= 1) {
_FCVAR_BOOLEAN = (FCVAR_NOEXTRAWHITEPACE << 1), /**< Can contain boolean value */
_FCVAR_STRING, /**< Can contain string value */
_FCVAR_FLOAT, /**< Can contain float value */
_FCVAR_INTEGER, /**< Can contain integer value */
}

stock GetCvarTypeStr(const /* ConVar_ExtendedFlags: */ flags) {
new buffer[32]
copy(buffer, charsmax(buffer), "number")

if (flags & _FCVAR_BOOLEAN)
copy(buffer, charsmax(buffer), "boolean")
Expand All @@ -613,5 +613,13 @@ stock GetCvarTypeStr(const /* ConVar_ExtendedFlags: */ flags) {
if (flags & _FCVAR_FLOAT)
copy(buffer, charsmax(buffer), "float")

if (flags & _FCVAR_INTEGER)
copy(buffer, charsmax(buffer), "integer")

return buffer
}
}

enum Bounds_s {
bool: b_hasBound,
Float: b_value
}
9 changes: 5 additions & 4 deletions cstrike/addons/amxmodx/scripting/redm_spawns.sma
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ public plugin_cfg() {
"redm_randomspawn", "1",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 3.0,
.description = "Enables the system of selecting spawns. \
`0` - disable, \
`1` - for all, \
`2` - only for T, \
.flags = _FCVAR_INTEGER,
.description = "Enables the system of selecting spawns. ^n\
`0` - disable, ^n\
`1` - for all, ^n\
`2` - only for T, ^n\
`3` - only for CT"
),
redm_randomspawn
Expand Down

0 comments on commit c91f9b9

Please sign in to comment.