Skip to content

Commit

Permalink
New ConVar: ca_mute_use_storage (#320)
Browse files Browse the repository at this point in the history
Save the player's individual preferences in the vault.
  • Loading branch information
SergeyShorokhov authored Dec 18, 2023
1 parent c43d94a commit a860589
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
// Minimum: "0.000000"
// Maximum: "120.000000"
ca_mute_use_delay "3"

// Save the player's individual preferences in the vault.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
ca_mute_use_storage "1"
34 changes: 26 additions & 8 deletions cstrike/addons/amxmodx/scripting/CA_Mute.sma
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ new bool: g_globalMute[MAX_PLAYERS + 1]

new Float: g_nextUse[MAX_PLAYERS + 1]

new Float: ca_mute_use_delay
new Float: ca_mute_use_delay,
bool: ca_mute_use_storage

new g_dummy, g_itemInfo[64], g_itemName[128]

Expand All @@ -41,13 +42,7 @@ public plugin_init() {
register_dictionary("CA_Mute.txt")
register_dictionary("common.txt")

bind_pcvar_float(create_cvar("ca_mute_use_delay", "3",
.description = "How often players can use menu. (in seconds)",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 120.0
),
ca_mute_use_delay
)
Create_CVars()

new const CMDS_Mute[][] = { "mute" }

Expand All @@ -62,6 +57,23 @@ public plugin_init() {
CA_Log(logLevel_Debug, "[CA]: Mute initialized!")
}

Create_CVars() {
bind_pcvar_float(create_cvar("ca_mute_use_delay", "3",
.description = "How often players can use menu. (in seconds)",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 120.0
),
ca_mute_use_delay
)

bind_pcvar_num(create_cvar("ca_mute_use_storage", "1",
.description = "Save the player's individual preferences in the vault.",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0
),
ca_mute_use_storage
)
}

public ClCmd_Mute(const id) {
if (!is_user_connected(id)) {
Expand Down Expand Up @@ -275,6 +287,9 @@ public client_putinserver(player) {
}

Storage_Update(const player, const target) {
if (!ca_mute_use_storage)
return

new query[QUERY_LENGTH / 2]

new authId[MAX_AUTHID_LENGTH]
Expand Down Expand Up @@ -314,6 +329,9 @@ public handle_Saved(failstate, Handle: query, error[], errnum, data[], size, Flo
}

Storage_Load(const player) {
if (!ca_mute_use_storage)
return

new authId[MAX_AUTHID_LENGTH]
get_user_authid(player, authId, charsmax(authId))

Expand Down

0 comments on commit a860589

Please sign in to comment.