diff --git a/.editorconfig b/.editorconfig index a9c0ece..09d2f4c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,10 +12,9 @@ charset = utf-8 # Set default charset [*.{sma,inc,sh}] indent_style = space -indent_size = 2 +indent_size = 4 trim_trailing_whitespace = true - [{.vscode/*,.github/*}] indent_style = space -indent_size = 2 +indent_size = 4 diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma index 06fff73..e9f72aa 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma @@ -4,235 +4,234 @@ #include -#pragma ctrlchar '\' -#pragma tabsize 2 +#pragma tabsize 4 new Float: ca_deathmute_time, - bool: ca_deathmute_dead_hear_alive, - NotifyType_s: ca_deathmute_notify_type, - bool: ca_deathmute_notify_show_progressbar, - Float: ca_deathmute_notify_hud_x, - Float: ca_deathmute_notify_hud_y, - ca_deathmute_notify_hud_r, - ca_deathmute_notify_hud_g, - ca_deathmute_notify_hud_b, - ca_deathmute_immunity_flags[16] + bool: ca_deathmute_dead_hear_alive, + NotifyType_s: ca_deathmute_notify_type, + bool: ca_deathmute_notify_show_progressbar, + Float: ca_deathmute_notify_hud_x, + Float: ca_deathmute_notify_hud_y, + ca_deathmute_notify_hud_r, + ca_deathmute_notify_hud_g, + ca_deathmute_notify_hud_b, + ca_deathmute_immunity_flags[16] enum NotifyType_s: { - notify_Disabled, - notify_Chat, - notify_HUD + notify_Disabled, + notify_Chat, + notify_HUD } new bool: g_canSpeakWithAlive[MAX_PLAYERS + 1] new g_syncHudOj -public stock const PluginName[] = "CA Addon: Death mute" -public stock const PluginVersion[] = CA_VERSION -public stock const PluginAuthor[] = "Sergey Shorokhov" -public stock const PluginURL[] = "https://github.com/ChatAdditions/" -public stock const PluginDescription[] = "Alive players don't hear dead players after 5 secs" +public stock const PluginName[] = "CA Addon: Death mute" +public stock const PluginVersion[] = CA_VERSION +public stock const PluginAuthor[] = "Sergey Shorokhov" +public stock const PluginURL[] = "https://github.com/ChatAdditions/" +public stock const PluginDescription[] = "Alive players don't hear dead players after 5 secs" public plugin_init() { - register_plugin(PluginName, PluginVersion, PluginAuthor) + register_plugin(PluginName, PluginVersion, PluginAuthor) - register_dictionary("CA_Addon_DeathMute.txt") + register_dictionary("CA_Addon_DeathMute.txt") - Create_CVars() + Create_CVars() - AutoExecConfig(true, "CA_Addon_DeathMute", "ChatAdditions") + AutoExecConfig(true, "CA_Addon_DeathMute", "ChatAdditions") - // RegisterHam(Ham_TFC_Killed, "player", "CBasePlayer_Killed", .Post = true) // Does it need ?! - RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed", .Post = true) - RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn", .Post = true) + // RegisterHam(Ham_TFC_Killed, "player", "CBasePlayer_Killed", .Post = true) // Does it need ?! + RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed", .Post = true) + RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn", .Post = true) - g_syncHudOj = CreateHudSyncObj() + g_syncHudOj = CreateHudSyncObj() } Create_CVars() { - bind_pcvar_float(create_cvar("ca_deathmute_time", "5.0", - .description = "Time (in seconds) for killed players, during which they can report information to living players.\n\ - 0 - disabled functionality", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 240.0 - ), ca_deathmute_time - ) - - bind_pcvar_num(create_cvar("ca_deathmute_dead_hear_alive", "1", - .description = "Death mute mode\n\ - 0 - alive hear only alive, dead hear all\n\ - 1 - alive hear only alive, dead hear only dead", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 1.0 - ), ca_deathmute_dead_hear_alive - ) - - bind_pcvar_num(create_cvar("ca_deathmute_notify_type", "1", - .description = "Notification type for dead players \n\ - 0 - disabled functionality\n\ - 1 - chat message\n\ - 2 - HUD message" - ), ca_deathmute_notify_type - ) - - bind_pcvar_num(create_cvar("ca_deathmute_notify_show_progressbar", "1", - .description = "Show progressbar \n\ - 0 - disabled functionality" - ), ca_deathmute_notify_show_progressbar - ) - - bind_pcvar_float(create_cvar("ca_deathmute_notify_hud_x", "-1.0", - .description = "X position for HUD message\n\ - -1.0 - center", - .has_min = true, .min_val = -1.0, - .has_max = true, .max_val = 1.0 - ), ca_deathmute_notify_hud_x - ) - - bind_pcvar_float(create_cvar("ca_deathmute_notify_hud_y", "0.15", - .description = "Y position for HUD message\n\ - -1.0 - center", - .has_min = true, .min_val = -1.0, - .has_max = true, .max_val = 1.0 - ), ca_deathmute_notify_hud_y - ) - - bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_r", "200", - .description = "Red color value (in RGB) [0...255]", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 255.0 - ), ca_deathmute_notify_hud_r - ) - - bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_g", "50", - .description = "Green color value (in RGB) [0...255]", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 255.0 - ), ca_deathmute_notify_hud_g - ) - - bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_b", "0", - .description = "Blue color value (in RGB) [0...255]", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 255.0 - ), ca_deathmute_notify_hud_b - ) - - bind_pcvar_string(create_cvar("ca_deathmute_immunity_flags", "a", - .description = "User immunity flag" - ), - ca_deathmute_immunity_flags, charsmax(ca_deathmute_immunity_flags) - ) + bind_pcvar_float(create_cvar("ca_deathmute_time", "5.0", + .description = "Time (in seconds) for killed players, during which they can report information to living players.^n\ + 0 - disabled functionality", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 240.0 + ), ca_deathmute_time + ) + + bind_pcvar_num(create_cvar("ca_deathmute_dead_hear_alive", "1", + .description = "Death mute mode^n\ + 0 - alive hear only alive, dead hear all^n\ + 1 - alive hear only alive, dead hear only dead", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0 + ), ca_deathmute_dead_hear_alive + ) + + bind_pcvar_num(create_cvar("ca_deathmute_notify_type", "1", + .description = "Notification type for dead players ^n\ + 0 - disabled functionality^n\ + 1 - chat message^n\ + 2 - HUD message" + ), ca_deathmute_notify_type + ) + + bind_pcvar_num(create_cvar("ca_deathmute_notify_show_progressbar", "1", + .description = "Show progressbar ^n\ + 0 - disabled functionality" + ), ca_deathmute_notify_show_progressbar + ) + + bind_pcvar_float(create_cvar("ca_deathmute_notify_hud_x", "-1.0", + .description = "X position for HUD message^n\ + -1.0 - center", + .has_min = true, .min_val = -1.0, + .has_max = true, .max_val = 1.0 + ), ca_deathmute_notify_hud_x + ) + + bind_pcvar_float(create_cvar("ca_deathmute_notify_hud_y", "0.15", + .description = "Y position for HUD message^n\ + -1.0 - center", + .has_min = true, .min_val = -1.0, + .has_max = true, .max_val = 1.0 + ), ca_deathmute_notify_hud_y + ) + + bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_r", "200", + .description = "Red color value (in RGB) [0...255]", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 255.0 + ), ca_deathmute_notify_hud_r + ) + + bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_g", "50", + .description = "Green color value (in RGB) [0...255]", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 255.0 + ), ca_deathmute_notify_hud_g + ) + + bind_pcvar_num(create_cvar("ca_deathmute_notify_hud_b", "0", + .description = "Blue color value (in RGB) [0...255]", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 255.0 + ), ca_deathmute_notify_hud_b + ) + + bind_pcvar_string(create_cvar("ca_deathmute_immunity_flags", "a", + .description = "User immunity flag" + ), + ca_deathmute_immunity_flags, charsmax(ca_deathmute_immunity_flags) + ) } public client_disconnected(id) { - g_canSpeakWithAlive[id] = false + g_canSpeakWithAlive[id] = false - remove_task(id) + remove_task(id) } public CBasePlayer_Spawn(const id) { - if(!is_user_alive(id)) - return + if (!is_user_alive(id)) + return - g_canSpeakWithAlive[id] = true + g_canSpeakWithAlive[id] = true - remove_task(id) + remove_task(id) } public CBasePlayer_Killed(const id, const attacker) { - if(ca_deathmute_time <= 0.0) { - return - } + if (ca_deathmute_time <= 0.0) { + return + } - set_task_ex(ca_deathmute_time, "DisableSpeakWithAlive", .id = id) + set_task_ex(ca_deathmute_time, "DisableSpeakWithAlive", .id = id) - switch(ca_deathmute_notify_type) { - case notify_Disabled: return + switch (ca_deathmute_notify_type) { + case notify_Disabled: return - case notify_Chat: client_print_color(id, print_team_red, "%L %L", id, "DeathMute_prefix", id, "DeathMute_ChatMessage", ca_deathmute_time) + case notify_Chat: client_print_color(id, print_team_red, "%L %L", id, "DeathMute_prefix", id, "DeathMute_ChatMessage", ca_deathmute_time) - case notify_HUD: { - set_hudmessage( - ca_deathmute_notify_hud_r, - ca_deathmute_notify_hud_g, - ca_deathmute_notify_hud_b, - ca_deathmute_notify_hud_x, - ca_deathmute_notify_hud_y, - .fadeouttime = 0.0, - .holdtime = ca_deathmute_time - 1.0 - ) + case notify_HUD: { + set_hudmessage( + ca_deathmute_notify_hud_r, + ca_deathmute_notify_hud_g, + ca_deathmute_notify_hud_b, + ca_deathmute_notify_hud_x, + ca_deathmute_notify_hud_y, + .fadeouttime = 0.0, + .holdtime = ca_deathmute_time - 1.0 + ) - static clearedMessage[256] + static clearedMessage[256] - formatex(clearedMessage, charsmax(clearedMessage), "%L", id, "DeathMute_ChatMessage", ca_deathmute_time) - ReplaceColors(clearedMessage, charsmax(clearedMessage)) + formatex(clearedMessage, charsmax(clearedMessage), "%L", id, "DeathMute_ChatMessage", ca_deathmute_time) + ReplaceColors(clearedMessage, charsmax(clearedMessage)) - ShowSyncHudMsg(id, g_syncHudOj, clearedMessage) + ShowSyncHudMsg(id, g_syncHudOj, clearedMessage) + } } - } - if(ca_deathmute_notify_show_progressbar) { - UTIL_BarTime(id, floatround(ca_deathmute_time)) - } + if (ca_deathmute_notify_show_progressbar) { + UTIL_BarTime(id, floatround(ca_deathmute_time)) + } } public DisableSpeakWithAlive(const id) { - g_canSpeakWithAlive[id] = false + g_canSpeakWithAlive[id] = false - switch(ca_deathmute_notify_type) { - case notify_Chat: client_print_color(id, print_team_red, "%L %L", id, "DeathMute_prefix", id, "DeathMute_YouMuted") + switch (ca_deathmute_notify_type) { + case notify_Chat: client_print_color(id, print_team_red, "%L %L", id, "DeathMute_prefix", id, "DeathMute_YouMuted") - case notify_HUD: { - set_hudmessage( - ca_deathmute_notify_hud_r, - ca_deathmute_notify_hud_g, - ca_deathmute_notify_hud_b, - ca_deathmute_notify_hud_x, - ca_deathmute_notify_hud_y, - .fadeouttime = 0.0, - .holdtime = ca_deathmute_time - 1.0 - ) + case notify_HUD: { + set_hudmessage( + ca_deathmute_notify_hud_r, + ca_deathmute_notify_hud_g, + ca_deathmute_notify_hud_b, + ca_deathmute_notify_hud_x, + ca_deathmute_notify_hud_y, + .fadeouttime = 0.0, + .holdtime = ca_deathmute_time - 1.0 + ) - static clearedMessage[256] + static clearedMessage[256] - formatex(clearedMessage, charsmax(clearedMessage), "%L", id, "DeathMute_YouMuted", ca_deathmute_time) - ReplaceColors(clearedMessage, charsmax(clearedMessage)) + formatex(clearedMessage, charsmax(clearedMessage), "%L", id, "DeathMute_YouMuted", ca_deathmute_time) + ReplaceColors(clearedMessage, charsmax(clearedMessage)) - ShowSyncHudMsg(id, g_syncHudOj, clearedMessage) + ShowSyncHudMsg(id, g_syncHudOj, clearedMessage) + } } - } } public CA_Client_Voice(const listener, const sender) { - if(ca_deathmute_time <= 0.0) { - return CA_CONTINUE - } - - new bool: listenerHasImmunity = bool: (get_user_flags(listener) & read_flags(ca_deathmute_immunity_flags)) + if (ca_deathmute_time <= 0.0) { + return CA_CONTINUE + } + + new bool: listenerHasImmunity = bool: (get_user_flags(listener) & read_flags(ca_deathmute_immunity_flags)) - if(listenerHasImmunity) { - return CA_CONTINUE - } + if (listenerHasImmunity) { + return CA_CONTINUE + } - new bool: listenerAlive = bool: is_user_alive(listener) - new bool: senderAlive = bool: is_user_alive(sender) + new bool: listenerAlive = bool: is_user_alive(listener) + new bool: senderAlive = bool: is_user_alive(sender) - if(!g_canSpeakWithAlive[sender] && !senderAlive && listenerAlive) { - return CA_SUPERCEDE - } + if (!g_canSpeakWithAlive[sender] && !senderAlive && listenerAlive) { + return CA_SUPERCEDE + } - if(!ca_deathmute_dead_hear_alive && !listenerAlive && senderAlive) { - return CA_SUPERCEDE - } + if (!ca_deathmute_dead_hear_alive && !listenerAlive && senderAlive) { + return CA_SUPERCEDE + } - return CA_CONTINUE + return CA_CONTINUE } stock ReplaceColors(text[], len) { - replace_string(text, len, "\1", "") - replace_string(text, len, "\3", "") - replace_string(text, len, "\4", "") + replace_string(text, len, "^1", "") + replace_string(text, len, "^3", "") + replace_string(text, len, "^4", "") } diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma index a3bf274..2626f76 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma @@ -3,307 +3,306 @@ #include -#pragma ctrlchar '\' -#pragma tabsize 2 +#pragma tabsize 4 // Natives -native aes_get_player_level(const player); -native ar_get_user_level(const player, rankName[] = "", len = 0); -native crxranks_get_user_level(const player); -native cmsranks_get_user_level(player, level[] = "", len = 0); -native csstats_get_user_stats(const player, const stats[22]); -native Float:cmsstats_get_user_skill(player, skillname[] = "", namelen = 0, &skill_level = 0); -native get_user_skill(player, &Float: skill); -native get_user_stats(player, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]); +native aes_get_player_level(const player) +native ar_get_user_level(const player, rankName[] = "", len = 0) +native crxranks_get_user_level(const player) +native cmsranks_get_user_level(player, level[] = "", len = 0) +native csstats_get_user_stats(const player, const stats[22]) +native Float:cmsstats_get_user_skill(player, skillname[] = "", namelen = 0, &skill_level = 0) +native get_user_skill(player, &Float: skill) +native get_user_stats(player, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]) // enum any: eChatType { - voice_chat, - text_chat + voice_chat, + text_chat } enum any: eRankRestrictionsType { - rr_type_none, - rr_type_level, - rr_type_frags + rr_type_none, + rr_type_level, + rr_type_frags } new ca_rankrestrictions_type, - ca_rankrestrictions_type_kills, - ca_rankrestrictions_min_kills_voice_chat, - ca_rankrestrictions_min_kills_text_chat, - ca_rankrestrictions_type_level, - ca_rankrestrictions_min_level_voice_chat, - ca_rankrestrictions_min_level_text_chat, - ca_rankrestrictions_immunity_flag[16], - ca_rankrestrictions_steam_immunity - -public stock const PluginName[] = "CA Addon: Rank restrictions" -public stock const PluginVersion[] = CA_VERSION -public stock const PluginAuthor[] = "steelzzz" -public stock const PluginURL[] = "https://github.com/ChatAdditions/" -public stock const PluginDescription[] = "Restrict chat until you reach the rank of a statistic" + ca_rankrestrictions_type_kills, + ca_rankrestrictions_min_kills_voice_chat, + ca_rankrestrictions_min_kills_text_chat, + ca_rankrestrictions_type_level, + ca_rankrestrictions_min_level_voice_chat, + ca_rankrestrictions_min_level_text_chat, + ca_rankrestrictions_immunity_flag[16], + ca_rankrestrictions_steam_immunity + +public stock const PluginName[] = "CA Addon: Rank restrictions" +public stock const PluginVersion[] = CA_VERSION +public stock const PluginAuthor[] = "steelzzz" +public stock const PluginURL[] = "https://github.com/ChatAdditions/" +public stock const PluginDescription[] = "Restrict chat until you reach the rank of a statistic" public plugin_init() { - register_plugin(PluginName, PluginVersion, PluginAuthor) - register_dictionary("CA_Addon_RankRestrictions.txt") + register_plugin(PluginName, PluginVersion, PluginAuthor) + register_dictionary("CA_Addon_RankRestrictions.txt") - Create_CVars() + Create_CVars() - AutoExecConfig(true, "CA_Addon_RankRestrictions", "ChatAdditions") + AutoExecConfig(true, "CA_Addon_RankRestrictions", "ChatAdditions") } public plugin_natives() { - set_native_filter("native_filter") + set_native_filter("native_filter") } public native_filter(const name[], index, trap) { - if(strcmp(name, "aes_get_player_level")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "aes_get_player_level")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "ar_get_user_level")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "ar_get_user_level")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "crxranks_get_user_level")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "crxranks_get_user_level")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "csstats_get_user_stats")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "csstats_get_user_stats")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "cmsranks_get_user_level")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "cmsranks_get_user_level")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "cmsstats_get_user_skill")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "cmsstats_get_user_skill")) { + return PLUGIN_HANDLED + } - if(strcmp(name, "get_user_stats")) { - return PLUGIN_HANDLED - } + if (strcmp(name, "get_user_stats")) { + return PLUGIN_HANDLED + } - return PLUGIN_CONTINUE + return PLUGIN_CONTINUE } Create_CVars() { - bind_pcvar_num(create_cvar("ca_rankrestrictions_type", "1", - .description = "Restrictions Type\n\ - 0 - Disable restrictions\n\ - 1 - Level restrictions\n\ - 2 - Kills count restrictions", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 2.0 - ), ca_rankrestrictions_type - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_type_kills", "1", - .description = "Kill System Types\n\ - 0 - CSStats MySQL\n\ - 1 - CSX Module", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 1.0 - ), ca_rankrestrictions_type_kills - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_min_kills_voice_chat", "10", - .description = "Min kills count to access VOICE chat", - .has_min = true, .min_val = 0.0 - ), ca_rankrestrictions_min_kills_voice_chat - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_min_kills_text_chat", "10", - .description = "Min kills count to access TEXT chat", - .has_min = true, .min_val = 0.0 - ), ca_rankrestrictions_min_kills_text_chat - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_type_level", "1", - .description = "Level System Types\n\ - 0 - Advanced Experience System\n\ - 1 - Army Ranks Ultimate\n\ - 2 - OciXCrom's Rank System\n\ - 3 - CMSStats Ranks\n\ - 4 - CMSStats MySQL\n\ - 5 - CSstatsX SQL\n\ - 6 - CSX Module", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 6.0 - ), ca_rankrestrictions_type_level - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_min_level_voice_chat", "2", - .description = "Min Level to access VOICE chat", - .has_min = true, .min_val = 0.0 - ), ca_rankrestrictions_min_level_voice_chat - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_min_level_text_chat", "2", - .description = "Min Level to access TEXT chat", - .has_min = true, .min_val = 0.0 - ), ca_rankrestrictions_min_level_text_chat - ) - - bind_pcvar_string(create_cvar("ca_rankrestrictions_immunity_flag", "a", - .description = "User immunity flag" - ), - ca_rankrestrictions_immunity_flag, charsmax(ca_rankrestrictions_immunity_flag) - ) - - bind_pcvar_num(create_cvar("ca_rankrestrictions_steam_immunity", "0", - .description = "Enable immunity for steam players", - .has_min = true, .min_val = 0.0, - .has_max = true, .max_val = 1.0 - ), ca_rankrestrictions_steam_immunity - ) + bind_pcvar_num(create_cvar("ca_rankrestrictions_type", "1", + .description = "Restrictions Type^n\ + 0 - Disable restrictions^n\ + 1 - Level restrictions^n\ + 2 - Kills count restrictions", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 2.0 + ), ca_rankrestrictions_type + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_type_kills", "1", + .description = "Kill System Types^n\ + 0 - CSStats MySQL^n\ + 1 - CSX Module", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0 + ), ca_rankrestrictions_type_kills + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_min_kills_voice_chat", "10", + .description = "Min kills count to access VOICE chat", + .has_min = true, .min_val = 0.0 + ), ca_rankrestrictions_min_kills_voice_chat + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_min_kills_text_chat", "10", + .description = "Min kills count to access TEXT chat", + .has_min = true, .min_val = 0.0 + ), ca_rankrestrictions_min_kills_text_chat + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_type_level", "1", + .description = "Level System Types^n\ + 0 - Advanced Experience System^n\ + 1 - Army Ranks Ultimate^n\ + 2 - OciXCrom's Rank System^n\ + 3 - CMSStats Ranks^n\ + 4 - CMSStats MySQL^n\ + 5 - CSstatsX SQL^n\ + 6 - CSX Module", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 6.0 + ), ca_rankrestrictions_type_level + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_min_level_voice_chat", "2", + .description = "Min Level to access VOICE chat", + .has_min = true, .min_val = 0.0 + ), ca_rankrestrictions_min_level_voice_chat + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_min_level_text_chat", "2", + .description = "Min Level to access TEXT chat", + .has_min = true, .min_val = 0.0 + ), ca_rankrestrictions_min_level_text_chat + ) + + bind_pcvar_string(create_cvar("ca_rankrestrictions_immunity_flag", "a", + .description = "User immunity flag" + ), + ca_rankrestrictions_immunity_flag, charsmax(ca_rankrestrictions_immunity_flag) + ) + + bind_pcvar_num(create_cvar("ca_rankrestrictions_steam_immunity", "0", + .description = "Enable immunity for steam players", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0 + ), ca_rankrestrictions_steam_immunity + ) } public CA_Client_Say(player, const bool: isTeamMessage, const message[]) { - if(!CanCommunicate(player, true, text_chat)) { - return CA_SUPERCEDE - } + if (!CanCommunicate(player, true, text_chat)) { + return CA_SUPERCEDE + } - return CA_CONTINUE + return CA_CONTINUE } public CA_Client_Voice(const listener, const sender) { - if(!CanCommunicate(sender, false, voice_chat)) { - // need chat notification? - return CA_SUPERCEDE - } - - return CA_CONTINUE + if (!CanCommunicate(sender, false, voice_chat)) { + // need chat notification? + return CA_SUPERCEDE + } + + return CA_CONTINUE } bool: CanCommunicate(const player, const bool: print, chatType) { - if(ca_rankrestrictions_type <= rr_type_none) { - return true - } - - // check is gagged? - if(get_user_flags(player) & read_flags(ca_rankrestrictions_immunity_flag)) { - return true - } - - if(ca_rankrestrictions_steam_immunity && _is_user_steam(player)) { - return true - } - - switch(chatType) { - case voice_chat: { - if(ca_rankrestrictions_type == rr_type_level && GetUserLevel(player) < ca_rankrestrictions_min_level_voice_chat) { - if(print) { - client_print_color(player, print_team_red, "%L", - player, "RankRestrictions_Warning_MinLevel", ca_rankrestrictions_min_level_voice_chat - ) - } - - return false - } + if (ca_rankrestrictions_type <= rr_type_none) { + return true + } - if(ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats(player) < ca_rankrestrictions_min_kills_voice_chat) { - if(print) { - client_print_color(player, print_team_red, "%L", - player, "RankRestrictions_Warning_MinKills", ca_rankrestrictions_min_kills_voice_chat - ) - } + // check is gagged? + if (get_user_flags(player) & read_flags(ca_rankrestrictions_immunity_flag)) { + return true + } - return false - } + if (ca_rankrestrictions_steam_immunity && _is_user_steam(player)) { + return true } - case text_chat: { - if(ca_rankrestrictions_type == rr_type_level && GetUserLevel(player) < ca_rankrestrictions_min_level_text_chat) { - if(print) { - client_print_color(player, print_team_red, "%L", - player, "RankRestrictions_Warning_MinLevel", ca_rankrestrictions_min_level_text_chat - ) + switch (chatType) { + case voice_chat: { + if (ca_rankrestrictions_type == rr_type_level && GetUserLevel(player) < ca_rankrestrictions_min_level_voice_chat) { + if (print) { + client_print_color(player, print_team_red, "%L", + player, "RankRestrictions_Warning_MinLevel", ca_rankrestrictions_min_level_voice_chat + ) + } + + return false + } + + if (ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats(player) < ca_rankrestrictions_min_kills_voice_chat) { + if (print) { + client_print_color(player, print_team_red, "%L", + player, "RankRestrictions_Warning_MinKills", ca_rankrestrictions_min_kills_voice_chat + ) + } + + return false + } } - return false - } - - if(ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats(player) < ca_rankrestrictions_min_kills_text_chat) { - if(print) { - client_print_color(player, print_team_red, "%L", - player, "RankRestrictions_Warning_MinKills", ca_rankrestrictions_min_kills_text_chat - ) + case text_chat: { + if (ca_rankrestrictions_type == rr_type_level && GetUserLevel(player) < ca_rankrestrictions_min_level_text_chat) { + if (print) { + client_print_color(player, print_team_red, "%L", + player, "RankRestrictions_Warning_MinLevel", ca_rankrestrictions_min_level_text_chat + ) + } + + return false + } + + if (ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats(player) < ca_rankrestrictions_min_kills_text_chat) { + if (print) { + client_print_color(player, print_team_red, "%L", + player, "RankRestrictions_Warning_MinKills", ca_rankrestrictions_min_kills_text_chat + ) + } + + return false + } } - - return false - } } - } - return true + return true } GetUserLevel(const player) { - switch(ca_rankrestrictions_type_level) { - case 0: return aes_get_player_level(player) - case 1: return ar_get_user_level(player) - case 2: return crxranks_get_user_level(player) - case 3: return cmsranks_get_user_level(player) - case 4: { - new iSkill - cmsstats_get_user_skill(player, .skill_level = iSkill) - return iSkill - } - case 5: { - new Float:iSkill - get_user_skill(player, iSkill) - return floatround(iSkill) - } - case 6: { - new stats[STATSX_MAX_STATS], hits[MAX_BODYHITS] - get_user_stats(player, stats, hits) - return stats[STATSX_RANK] + switch (ca_rankrestrictions_type_level) { + case 0: return aes_get_player_level(player) + case 1: return ar_get_user_level(player) + case 2: return crxranks_get_user_level(player) + case 3: return cmsranks_get_user_level(player) + case 4: { + new iSkill + cmsstats_get_user_skill(player, .skill_level = iSkill) + return iSkill + } + case 5: { + new Float:iSkill + get_user_skill(player, iSkill) + return floatround(iSkill) + } + case 6: { + new stats[STATSX_MAX_STATS], hits[MAX_BODYHITS] + get_user_stats(player, stats, hits) + return stats[STATSX_RANK] + } } - } - return 0 + return 0 } GetUserFragsFromStats(const player) { - enum { stats_Frags/* , stats_Deaths, stats_Rounds = 16 */ } - - switch(ca_rankrestrictions_type_kills) { - case 0: { - new stats[22] - csstats_get_user_stats(player, stats) - return stats[stats_Frags] - } - case 1: { - new stats[STATSX_MAX_STATS], hits[MAX_BODYHITS] - get_user_stats(player, stats, hits) - return stats[STATSX_KILLS] - } - } - - return 0 + enum { stats_Frags/* , stats_Deaths, stats_Rounds = 16 */ } + + switch (ca_rankrestrictions_type_kills) { + case 0: { + new stats[22] + csstats_get_user_stats(player, stats) + return stats[stats_Frags] + } + case 1: { + new stats[STATSX_MAX_STATS], hits[MAX_BODYHITS] + get_user_stats(player, stats, hits) + return stats[STATSX_KILLS] + } + } + + return 0 } static stock bool: _is_user_steam(const player) { - #if (defined _reapi_reunion_included) - if(has_reunion()) - return (REU_GetAuthtype(player) == CA_TYPE_STEAM) - #endif + #if (defined _reapi_reunion_included) + if (has_reunion()) + return (REU_GetAuthtype(player) == CA_TYPE_STEAM) + #endif - static dp_r_id_provider - if (dp_r_id_provider || (dp_r_id_provider = get_cvar_pointer("dp_r_id_provider"))) { - server_cmd("dp_clientinfo %i", player) - server_exec() + static dp_r_id_provider + if (dp_r_id_provider || (dp_r_id_provider = get_cvar_pointer("dp_r_id_provider"))) { + server_cmd("dp_clientinfo %i", player) + server_exec() - #define DP_AUTH_STEAM 2 - if(get_pcvar_num(dp_r_id_provider) == DP_AUTH_STEAM) - return true + #define DP_AUTH_STEAM 2 + if (get_pcvar_num(dp_r_id_provider) == DP_AUTH_STEAM) + return true - return false - } + return false + } - return false + return false } diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_RequestUnGag.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_RequestUnGag.sma index d17c2f9..16cf8b5 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_RequestUnGag.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_RequestUnGag.sma @@ -4,96 +4,95 @@ #include #include -#pragma ctrlchar '\' -#pragma tabsize 2 +#pragma tabsize 4 new Float: g_userNextRequestTime[MAX_PLAYERS + 1] new ca_requestungag_cmd[32], - Float: ca_requestungag_delay, - ca_gag_access_flags_high[32], - ca_gag_access_flags[32] + Float: ca_requestungag_delay, + ca_gag_access_flags_high[32], + ca_gag_access_flags[32] -public stock const PluginName[] = "CA Addon: Request UnGAG" -public stock const PluginVersion[] = CA_VERSION -public stock const PluginAuthor[] = "steelzzz" -public stock const PluginURL[] = "https://github.com/ChatAdditions/" -public stock const PluginDescription[] = "A player can apologize to the administration" +public stock const PluginName[] = "CA Addon: Request UnGAG" +public stock const PluginVersion[] = CA_VERSION +public stock const PluginAuthor[] = "steelzzz" +public stock const PluginURL[] = "https://github.com/ChatAdditions/" +public stock const PluginDescription[] = "A player can apologize to the administration" public plugin_init() { - register_plugin(PluginName, PluginVersion, PluginAuthor) - register_dictionary("CA_Addon_RequestUngag.txt") + register_plugin(PluginName, PluginVersion, PluginAuthor) + register_dictionary("CA_Addon_RequestUngag.txt") - Create_CVars() + Create_CVars() - AutoExecConfig(true, "CA_Addon_RequestUnGag", "ChatAdditions") + AutoExecConfig(true, "CA_Addon_RequestUnGag", "ChatAdditions") } public Create_CVars() { - bind_pcvar_string(create_cvar("ca_requestungag_cmd", "/sorry", - .description = "Request ungag command"), - ca_requestungag_cmd, charsmax(ca_requestungag_cmd) - ) - - bind_pcvar_float(create_cvar("ca_requestungag_delay", "40.0", - .description = "delay time request ungag", - .has_min = true, .min_val = 1.0), - ca_requestungag_delay - ) - - bind_pcvar_string(get_cvar_pointer("ca_gag_access_flags_high"), - ca_gag_access_flags_high, charsmax(ca_gag_access_flags_high) - ) - - bind_pcvar_string(get_cvar_pointer("ca_gag_access_flags"), - ca_gag_access_flags, charsmax(ca_gag_access_flags) - ) + bind_pcvar_string(create_cvar("ca_requestungag_cmd", "/sorry", + .description = "Request ungag command"), + ca_requestungag_cmd, charsmax(ca_requestungag_cmd) + ) + + bind_pcvar_float(create_cvar("ca_requestungag_delay", "40.0", + .description = "delay time request ungag", + .has_min = true, .min_val = 1.0), + ca_requestungag_delay + ) + + bind_pcvar_string(get_cvar_pointer("ca_gag_access_flags_high"), + ca_gag_access_flags_high, charsmax(ca_gag_access_flags_high) + ) + + bind_pcvar_string(get_cvar_pointer("ca_gag_access_flags"), + ca_gag_access_flags, charsmax(ca_gag_access_flags) + ) } // TODO: Create `_PRE` hook forward instead this. public CA_Client_Say(player, const bool: isTeamMessage, const message[]) { - if(strcmp(message, ca_requestungag_cmd) != 0) - return CA_CONTINUE + if (strcmp(message, ca_requestungag_cmd) != 0) + return CA_CONTINUE - if(!ca_has_user_gag(player)) { - client_print_color(player, print_team_default, "%L", player, "RequestUnGag_NoAccess") + if (!ca_has_user_gag(player)) { + client_print_color(player, print_team_default, "%L", player, "RequestUnGag_NoAccess") - return CA_SUPERCEDE - } + return CA_SUPERCEDE + } - new Float: gametime = get_gametime() - if(g_userNextRequestTime[player] > gametime) { - new timeLeft = floatround(g_userNextRequestTime[player] - gametime, floatround_ceil) - client_print_color(player, print_team_default, "%L", player, "RequestUnGag_TimeOut", timeLeft) + new Float: gametime = get_gametime() + if (g_userNextRequestTime[player] > gametime) { + new timeLeft = floatround(g_userNextRequestTime[player] - gametime, floatround_ceil) + client_print_color(player, print_team_default, "%L", player, "RequestUnGag_TimeOut", timeLeft) - return CA_SUPERCEDE - } + return CA_SUPERCEDE + } - new userID = get_user_userid(player) + new userID = get_user_userid(player) - new players[MAX_PLAYERS], count - get_players_ex(players, count, (GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV)) + new players[MAX_PLAYERS], count + get_players_ex(players, count, (GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV)) - new accessFlagsHigh = read_flags(ca_gag_access_flags_high) - new accessFlags = read_flags(ca_gag_access_flags) + new accessFlagsHigh = read_flags(ca_gag_access_flags_high) + new accessFlags = read_flags(ca_gag_access_flags) - for(new i; i < count; i++) { - new receiver = players[i] + for(new i; i < count; i++) { + new receiver = players[i] - if(receiver == player) - continue + if (receiver == player) + continue - if(!(get_user_flags(receiver) & (accessFlags | accessFlagsHigh))) - continue + if (!(get_user_flags(receiver) & (accessFlags | accessFlagsHigh))) + continue - client_print_color(receiver, print_team_default, "%L", - receiver, "RequestUnGag_Requested", - player, userID - ) - } + client_print_color(receiver, print_team_default, "%L", + receiver, "RequestUnGag_Requested", + player, userID + ) + } - g_userNextRequestTime[player] = gametime + ca_requestungag_delay + g_userNextRequestTime[player] = gametime + ca_requestungag_delay - client_print_color(player, print_team_default, "%L", player, "RequestUnGag_YouRequested") - return CA_SUPERCEDE + client_print_color(player, print_team_default, "%L", player, "RequestUnGag_YouRequested") + return CA_SUPERCEDE } diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_VoteGag.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_VoteGag.sma index 056c592..12144d4 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_VoteGag.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_VoteGag.sma @@ -33,195 +33,195 @@ const IMMUNITY_FLAGS = ADMIN_IMMUNITY; // Иммунитет к функция #if !defined MAX_PLAYERS - const MAX_PLAYERS = 32; + const MAX_PLAYERS = 32 #endif -new g_VotingMenu; -new g_iVotingIndex, g_iVotingLasttime; -new g_arrPlayers[MAX_PLAYERS], g_iPnum; -new bool:g_bPlayerVoted[MAX_PLAYERS + 1], g_iPlayersVotedCount; +new g_VotingMenu +new g_iVotingIndex, g_iVotingLasttime +new g_arrPlayers[MAX_PLAYERS], g_iPnum +new bool:g_bPlayerVoted[MAX_PLAYERS + 1], g_iPlayersVotedCount public plugin_init() { - register_plugin("CA: VoteGAG", "1.0.1-alpha", "Sergey Shorokhov"); + register_plugin("CA: VoteGAG", "1.0.1-alpha", "Sergey Shorokhov") - register_clcmd("say /votegag", "clcmd_VoteGag"); - register_clcmd("say_team /votegag", "clcmd_VoteGag"); - register_clcmd("votegag", "clcmd_VoteGag") + register_clcmd("say /votegag", "clcmd_VoteGag") + register_clcmd("say_team /votegag", "clcmd_VoteGag") + register_clcmd("votegag", "clcmd_VoteGag") } public plugin_cfg() { - g_VotingMenu = menu_create("Title", "voting_handler"); - menu_setprop(g_VotingMenu, MPROP_EXIT, MEXIT_NEVER); - menu_additem(g_VotingMenu, MSG_MENU_YES, "1"); - menu_additem(g_VotingMenu, MSG_MENU_NO, "0"); + g_VotingMenu = menu_create("Title", "voting_handler") + menu_setprop(g_VotingMenu, MPROP_EXIT, MEXIT_NEVER) + menu_additem(g_VotingMenu, MSG_MENU_YES, "1") + menu_additem(g_VotingMenu, MSG_MENU_NO, "0") } public client_disconnected(id) { - if(g_bPlayerVoted[id]) - { - g_bPlayerVoted[id] = false; - g_iPlayersVotedCount--; - } + if (g_bPlayerVoted[id]) + { + g_bPlayerVoted[id] = false + g_iPlayersVotedCount-- + } } public clcmd_VoteGag(id) { - if(g_iVotingIndex) - { - ChatColor(id, 0, MSG_VOTE_EXISTS, PREFIX); - return PLUGIN_HANDLED; - } - new time = g_iVotingLasttime + REPEAT_VOTE_MIN * 60 - get_systime(); - if(time > 0) - { - ChatColor(id, 0, MSG_VOTE_BLOCK, PREFIX, time % 60); - return PLUGIN_HANDLED; - } - - new szName[32], num[3], menu, callback; - menu = menu_create(MSG_PLMENU_TITLE, "players_handler"); - callback = menu_makecallback("players_callback"); - - menu_setprop(menu, MPROP_NEXTNAME, MSG_MENU_NEXT); - menu_setprop(menu, MPROP_BACKNAME, MSG_MENU_BACK); - menu_setprop(menu, MPROP_EXITNAME, MSG_MENU_EXIT); - - get_players(g_arrPlayers, g_iPnum, "h"); - - for(new i; i < g_iPnum; i++) - { - if(g_arrPlayers[i] == id) - continue; - - get_user_name(g_arrPlayers[i], szName, charsmax(szName)); - num_to_str(g_arrPlayers[i], num, charsmax(num)); - menu_additem(menu, szName, num, .callback = callback); - } - - menu_display(id, menu); - return PLUGIN_HANDLED; + if (g_iVotingIndex) + { + ChatColor(id, 0, MSG_VOTE_EXISTS, PREFIX) + return PLUGIN_HANDLED + } + new time = g_iVotingLasttime + REPEAT_VOTE_MIN * 60 - get_systime() + if (time > 0) + { + ChatColor(id, 0, MSG_VOTE_BLOCK, PREFIX, time % 60) + return PLUGIN_HANDLED + } + + new szName[32], num[3], menu, callback + menu = menu_create(MSG_PLMENU_TITLE, "players_handler") + callback = menu_makecallback("players_callback") + + menu_setprop(menu, MPROP_NEXTNAME, MSG_MENU_NEXT) + menu_setprop(menu, MPROP_BACKNAME, MSG_MENU_BACK) + menu_setprop(menu, MPROP_EXITNAME, MSG_MENU_EXIT) + + get_players(g_arrPlayers, g_iPnum, "h") + + for(new i; i < g_iPnum; i++) + { + if (g_arrPlayers[i] == id) + continue + + get_user_name(g_arrPlayers[i], szName, charsmax(szName)) + num_to_str(g_arrPlayers[i], num, charsmax(num)) + menu_additem(menu, szName, num, .callback = callback) + } + + menu_display(id, menu) + return PLUGIN_HANDLED } public players_callback(id, menu, item) { - new _access, item_data[3], callback; - menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback); - - new index = str_to_num(item_data); - if(!is_user_connected(index)) - return ITEM_DISABLED; - if(ca_has_user_gag(index)) - return ITEM_DISABLED; - if(get_user_flags(index) & IMMUNITY_FLAGS) - return ITEM_DISABLED; - - return ITEM_ENABLED; + new _access, item_data[3], callback + menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback) + + new index = str_to_num(item_data) + if (!is_user_connected(index)) + return ITEM_DISABLED + if (ca_has_user_gag(index)) + return ITEM_DISABLED + if (get_user_flags(index) & IMMUNITY_FLAGS) + return ITEM_DISABLED + + return ITEM_ENABLED } public players_handler(id, menu, item) { - if(item == MENU_EXIT) - { - menu_destroy(menu); - return PLUGIN_HANDLED; - } + if (item == MENU_EXIT) + { + menu_destroy(menu) + return PLUGIN_HANDLED + } - new _access, item_data[3], callback; - menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback); - g_iVotingIndex = str_to_num(item_data); - menu_destroy(menu); + new _access, item_data[3], callback + menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback) + g_iVotingIndex = str_to_num(item_data) + menu_destroy(menu) - new szTitle[128], szName[32]; - get_user_name(g_iVotingIndex, szName, charsmax(szName)); + new szTitle[128], szName[32] + get_user_name(g_iVotingIndex, szName, charsmax(szName)) - formatex(szTitle, charsmax(szTitle), MSG_VMENU_TITLE, szName); - menu_setprop(g_VotingMenu, MPROP_TITLE, szTitle); + formatex(szTitle, charsmax(szTitle), MSG_VMENU_TITLE, szName) + menu_setprop(g_VotingMenu, MPROP_TITLE, szTitle) - ChatColor(0, g_iVotingIndex, MSG_VOTE_START, PREFIX, id, g_iVotingIndex); + ChatColor(0, g_iVotingIndex, MSG_VOTE_START, PREFIX, id, g_iVotingIndex) - for(new i; i < g_iPnum; i++) - { - if(g_arrPlayers[i] == g_iVotingIndex) - continue; + for(new i; i < g_iPnum; i++) + { + if (g_arrPlayers[i] == g_iVotingIndex) + continue - if(is_user_connected(g_arrPlayers[i])) - menu_display(g_arrPlayers[i], g_VotingMenu); - } + if (is_user_connected(g_arrPlayers[i])) + menu_display(g_arrPlayers[i], g_VotingMenu) + } - set_task(CHECK_VOTE_TIME, "task__CheckVotes", id); - return PLUGIN_HANDLED; + set_task(CHECK_VOTE_TIME, "task__CheckVotes", id) + return PLUGIN_HANDLED } public voting_handler(id, menu, item) { - if(item == MENU_EXIT) - return PLUGIN_HANDLED; - - new _access, item_data[3], callback; - menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback); - - if(str_to_num(item_data)) - { - g_iPlayersVotedCount++; - g_bPlayerVoted[id] = true; - } - return PLUGIN_HANDLED; + if (item == MENU_EXIT) + return PLUGIN_HANDLED + + new _access, item_data[3], callback + menu_item_getinfo(menu, item, _access, item_data, charsmax(item_data), .callback = callback) + + if (str_to_num(item_data)) + { + g_iPlayersVotedCount++ + g_bPlayerVoted[id] = true + } + return PLUGIN_HANDLED } public task__CheckVotes(id) { - for(new i; i < g_iPnum; i++) - { - if(is_user_connected(g_arrPlayers[i])) - show_menu(g_arrPlayers[i], 0, "^n"); - } - - new iVoteCount = floatround(g_iPnum * PERCENT_VOTE_OK / 100.0); - - if(g_iPlayersVotedCount >= iVoteCount) - { - if(is_user_connected(g_iVotingIndex)) - { - ca_set_user_gag(g_iVotingIndex, PREFIX, BLOCK_TIME_MIN, (gagFlag_Say | gagFlag_SayTeam | gagFlag_Voice)); - - new szName[32]; - get_user_name(g_iVotingIndex, szName, charsmax(szName)); - ChatColor(0, g_iVotingIndex, MSG_VOTING_OK_ALL, PREFIX, szName, BLOCK_TIME_MIN); - ChatColor(g_iVotingIndex, 0, MSG_VOTING_OK_PL, PREFIX, BLOCK_TIME_MIN); - } - else ChatColor(id, 0, MSG_VOTING_DISC, PREFIX); - } - else ChatColor(0, g_iVotingIndex, MSG_VOTING_FAIL, PREFIX, g_iPlayersVotedCount, iVoteCount); - - arrayset(g_bPlayerVoted, false, sizeof g_bPlayerVoted); - g_iPlayersVotedCount = 0; - g_iVotingIndex = 0; - g_iVotingLasttime = get_systime(); + for(new i; i < g_iPnum; i++) + { + if (is_user_connected(g_arrPlayers[i])) + show_menu(g_arrPlayers[i], 0, "^n") + } + + new iVoteCount = floatround(g_iPnum * PERCENT_VOTE_OK / 100.0) + + if (g_iPlayersVotedCount >= iVoteCount) + { + if (is_user_connected(g_iVotingIndex)) + { + ca_set_user_gag(g_iVotingIndex, PREFIX, BLOCK_TIME_MIN, (gagFlag_Say | gagFlag_SayTeam | gagFlag_Voice)) + + new szName[32] + get_user_name(g_iVotingIndex, szName, charsmax(szName)) + ChatColor(0, g_iVotingIndex, MSG_VOTING_OK_ALL, PREFIX, szName, BLOCK_TIME_MIN) + ChatColor(g_iVotingIndex, 0, MSG_VOTING_OK_PL, PREFIX, BLOCK_TIME_MIN) + } + else ChatColor(id, 0, MSG_VOTING_DISC, PREFIX) + } + else ChatColor(0, g_iVotingIndex, MSG_VOTING_FAIL, PREFIX, g_iPlayersVotedCount, iVoteCount) + + arrayset(g_bPlayerVoted, false, sizeof g_bPlayerVoted) + g_iPlayersVotedCount = 0 + g_iVotingIndex = 0 + g_iVotingLasttime = get_systime() } stock ChatColor(id, id2, const szMessage[], any:...) { - new szMsg[190]; - vformat(szMsg, charsmax(szMsg), szMessage, 4); - - if(id) - { - client_print_color(id, print_team_default, szMsg); - } - else - { - new players[32], pnum; - get_players(players, pnum, "c"); - for(new i; i < pnum; ++i) - { - if(players[i] != id2) - { - client_print_color(players[i], print_team_default, szMsg); - } - } - } + new szMsg[190] + vformat(szMsg, charsmax(szMsg), szMessage, 4) + + if (id) + { + client_print_color(id, print_team_default, szMsg) + } + else + { + new players[32], pnum + get_players(players, pnum, "c") + for(new i; i < pnum; ++i) + { + if (players[i] != id2) + { + client_print_color(players[i], print_team_default, szMsg) + } + } + } } diff --git a/cstrike/addons/amxmodx/scripting/CA_AntiFlood.sma b/cstrike/addons/amxmodx/scripting/CA_AntiFlood.sma index 21347e4..f65a9ef 100644 --- a/cstrike/addons/amxmodx/scripting/CA_AntiFlood.sma +++ b/cstrike/addons/amxmodx/scripting/CA_AntiFlood.sma @@ -1,102 +1,100 @@ #include #include -#pragma ctrlchar '\' -#pragma tabsize 2 +#pragma tabsize 4 new g_OldMessage[MAX_PLAYERS + 1][CA_MAX_MESSAGE_SIZE] new Float: ca_anti_flood_time, - ca_equal_messages + ca_equal_messages -public stock const PluginName[] = "CA: Anti Flood" -public stock const PluginVersion[] = CA_VERSION -public stock const PluginAuthor[] = "Nordic Warrior" -public stock const PluginURL[] = "https://github.com/ChatAdditions/" -public stock const PluginDescription[] = "Antiflood for text chat" +public stock const PluginName[] = "CA: Anti Flood" +public stock const PluginVersion[] = CA_VERSION +public stock const PluginAuthor[] = "Nordic Warrior" +public stock const PluginURL[] = "https://github.com/ChatAdditions/" +public stock const PluginDescription[] = "Antiflood for text chat" public plugin_init() { - register_plugin(PluginName, PluginVersion, PluginAuthor) + register_plugin(PluginName, PluginVersion, PluginAuthor) - register_dictionary("CA_AntiFlood.txt") + register_dictionary("CA_AntiFlood.txt") - Create_CVars() + Create_CVars() - AutoExecConfig(true, "CA_AntiFlood", "ChatAdditions") + AutoExecConfig(true, "CA_AntiFlood", "ChatAdditions") } public plugin_cfg() { - if(find_plugin_byfile("antiflood.amxx") != INVALID_PLUGIN_ID) { - log_amx("Default plugin was found. It has been stopped.") - pause("acd", "antiflood.amxx") - } + if (find_plugin_byfile("antiflood.amxx") != INVALID_PLUGIN_ID) { + log_amx("Default plugin was found. It has been stopped.") + pause("acd", "antiflood.amxx") + } } public CA_Client_Say(id, const bool: isTeamMessage, const message[]) { - return CheckMessage(id, message) + return CheckMessage(id, message) } CheckMessage(id, const message[]) { - if(message[0] == '/') { - return CA_CONTINUE - } + if (message[0] == '/') { + return CA_CONTINUE + } - static Float:nextMessage[MAX_PLAYERS + 1] - static equalMessage[MAX_PLAYERS + 1] + static Float:nextMessage[MAX_PLAYERS + 1] + static equalMessage[MAX_PLAYERS + 1] - new Float:nextSay = get_gametime() + new Float:nextSay = get_gametime() - if(nextMessage[id] > nextSay) { - client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_STOP_FLOODING") - nextMessage[id] = nextSay + ca_anti_flood_time + if (nextMessage[id] > nextSay) { + client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_STOP_FLOODING") + nextMessage[id] = nextSay + ca_anti_flood_time - return CA_SUPERCEDE - } + return CA_SUPERCEDE + } - if(strcmp(message, g_OldMessage[id], true) == 0) { - if(++equalMessage[id] >= ca_equal_messages) { - client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE") + if (strcmp(message, g_OldMessage[id], true) == 0) { + if (++equalMessage[id] >= ca_equal_messages) { + client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE") - return CA_SUPERCEDE + return CA_SUPERCEDE + } + } else { + equalMessage[id] = 0 } - } - else { - equalMessage[id] = 0 - } - nextMessage[id] = nextSay + ca_anti_flood_time - copy(g_OldMessage[id], charsmax(g_OldMessage[]), message) + nextMessage[id] = nextSay + ca_anti_flood_time + copy(g_OldMessage[id], charsmax(g_OldMessage[]), message) - return CA_CONTINUE + return CA_CONTINUE } public client_disconnected(id) { - g_OldMessage[id][0] = EOS + g_OldMessage[id][0] = EOS } Create_CVars() { - bind_pcvar_float( - create_cvar( - .name = "ca_anti_flood_time", - .string = "0.75", - .description = "Time between messages\n 0.0 - no limit", - .has_min = true, - .min_val = 0.0 - ), - - ca_anti_flood_time - ) - - bind_pcvar_num( - create_cvar( - .name = "ca_equal_messages", - .string = "2", - .description = "How many identical messages can be written in a row\n 0 - no limit", - .has_min = true, - .min_val = 0.0 - ), - - ca_equal_messages - ) + bind_pcvar_float( + create_cvar( + .name = "ca_anti_flood_time", + .string = "0.75", + .description = "Time between messages^n 0.0 - no limit", + .has_min = true, + .min_val = 0.0 + ), + + ca_anti_flood_time + ) + + bind_pcvar_num( + create_cvar( + .name = "ca_equal_messages", + .string = "2", + .description = "How many identical messages can be written in a row^n 0 - no limit", + .has_min = true, + .min_val = 0.0 + ), + + ca_equal_messages + ) } diff --git a/cstrike/addons/amxmodx/scripting/CA_Gag.sma b/cstrike/addons/amxmodx/scripting/CA_Gag.sma index 668602d..1709cbb 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Gag.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Gag.sma @@ -6,14 +6,13 @@ #include #include -#pragma ctrlchar '\' #pragma dynamic 524288 -#pragma tabsize 2 +#pragma tabsize 4 - /* ----- START SETTINGS ----- */ + /* ----- START SETTINGS ----- */ const Float: GAG_THINKER_FREQ = 3.0 - /* ----- END OF SETTINGS ----- */ + /* ----- END OF SETTINGS ----- */ static g_currentGags[MAX_PLAYERS + 1][gagData_s] static g_adminTempData[MAX_PLAYERS + 1][gagData_s] @@ -24,245 +23,245 @@ static Array: g_gagTimeTemplates, g_gagTimeTemplates_size static Array: g_chatWhitelistCmds, g_chatWhitelistCmds_size new ca_gag_times[64], - ca_gag_immunity_flags[16], - ca_gag_access_flags[16], - ca_gag_access_flags_own_reason[16], - ca_gag_access_flags_own_time[16], - ca_gag_access_flags_high[16], - ca_gag_remove_only_own_gag, - ca_gag_sound_ok[128], - ca_gag_sound_error[128], - bool: ca_gag_block_nickname_change, - bool: ca_gag_block_admin_chat, - bool: ca_gag_common_chat_block, - ca_gag_own_reason_enabled + ca_gag_immunity_flags[16], + ca_gag_access_flags[16], + ca_gag_access_flags_own_reason[16], + ca_gag_access_flags_own_time[16], + ca_gag_access_flags_high[16], + ca_gag_remove_only_own_gag, + ca_gag_sound_ok[128], + ca_gag_sound_error[128], + bool: ca_gag_block_nickname_change, + bool: ca_gag_block_admin_chat, + bool: ca_gag_common_chat_block, + ca_gag_own_reason_enabled new g_dummy, g_itemInfo[64], g_itemName[128] enum { - ITEM_ENTER_GAG_REASON = -1, - ITEM_ENTER_GAG_TIME = -2, - ITEM_CONFIRM = -3, - ITEM_REASON = -4, + ITEM_ENTER_GAG_REASON = -1, + ITEM_ENTER_GAG_TIME = -2, + ITEM_CONFIRM = -3, + ITEM_REASON = -4, } new g_fwd_gag_setted, - g_fwd_gag_removed, - g_ret + g_fwd_gag_removed, + g_ret new const g_adminChatCmds[][] = { - "amx_say", "amx_asay", "amx_chat", "amx_psay", - "amx_teamsay", "amx_bsay", "amx_bsay2", "amx_csay", - "amx_csay2", "amx_rsay", "amx_rsay2", "amx_tsay", - "amx_tsay2" + "amx_say", "amx_asay", "amx_chat", "amx_psay", + "amx_teamsay", "amx_bsay", "amx_bsay2", "amx_csay", + "amx_csay2", "amx_rsay", "amx_rsay2", "amx_tsay", + "amx_tsay2" } new const g_gagCmd[] = "gag" new const g_unGagCmd[] = "ungag" -public stock const PluginName[] = "CA: Gag" -public stock const PluginVersion[] = CA_VERSION -public stock const PluginAuthor[] = "Sergey Shorokhov" -public stock const PluginURL[] = "https://github.com/ChatAdditions/" -public stock const PluginDescription[] = "Manage player chats for the admin." +public stock const PluginName[] = "CA: Gag" +public stock const PluginVersion[] = CA_VERSION +public stock const PluginAuthor[] = "Sergey Shorokhov" +public stock const PluginURL[] = "https://github.com/ChatAdditions/" +public stock const PluginDescription[] = "Manage player chats for the admin." public plugin_precache() { - register_plugin(PluginName, PluginVersion, PluginAuthor) + register_plugin(PluginName, PluginVersion, PluginAuthor) - register_dictionary("CA_Gag.txt") - register_dictionary("common.txt") - register_dictionary("time.txt") + register_dictionary("CA_Gag.txt") + register_dictionary("common.txt") + register_dictionary("time.txt") - register_srvcmd("ca_gag_add_reason", "SrvCmd_AddReason") - register_srvcmd("ca_gag_show_templates", "SrvCmd_ShowTemplates") - register_srvcmd("ca_gag_add_chat_whitelist_cmd", "SrvCmd_AddWhitelistCmd") - register_srvcmd("ca_gag_reload_config", "SrvCmd_ReloadConfig") + register_srvcmd("ca_gag_add_reason", "SrvCmd_AddReason") + register_srvcmd("ca_gag_show_templates", "SrvCmd_ShowTemplates") + register_srvcmd("ca_gag_add_chat_whitelist_cmd", "SrvCmd_AddWhitelistCmd") + register_srvcmd("ca_gag_reload_config", "SrvCmd_ReloadConfig") - Create_CVars() + Create_CVars() - g_gagReasonsTemplates = ArrayCreate(reason_s) - g_gagTimeTemplates = ArrayCreate() - g_chatWhitelistCmds = ArrayCreate(MAX_WHITELIST_CMD_LEN) + g_gagReasonsTemplates = ArrayCreate(reason_s) + g_gagTimeTemplates = ArrayCreate() + g_chatWhitelistCmds = ArrayCreate(MAX_WHITELIST_CMD_LEN) - LoadConfig() + LoadConfig() - if(ca_gag_sound_ok[0] != EOS && file_exists(fmt("sounds/%s", ca_gag_sound_ok))) { - precache_sound(ca_gag_sound_ok) - } + if (ca_gag_sound_ok[0] != EOS && file_exists(fmt("sounds/%s", ca_gag_sound_ok))) { + precache_sound(ca_gag_sound_ok) + } - if(ca_gag_sound_error[0] != EOS && file_exists(fmt("sounds/%s", ca_gag_sound_error))) { - precache_sound(ca_gag_sound_error) - } + if (ca_gag_sound_error[0] != EOS && file_exists(fmt("sounds/%s", ca_gag_sound_error))) { + precache_sound(ca_gag_sound_error) + } } public plugin_init() { - set_task_ex(GAG_THINKER_FREQ, "Gags_Thinker", .flags = SetTask_Repeat) + set_task_ex(GAG_THINKER_FREQ, "Gags_Thinker", .flags = SetTask_Repeat) - new accessFlagsHigh = read_flags(ca_gag_access_flags_high) - new accessFlags = read_flags(ca_gag_access_flags) - new accessFlagsOwnReason = read_flags(ca_gag_access_flags_own_reason) - new accessFlagsOwnTime = read_flags(ca_gag_access_flags_own_time) + new accessFlagsHigh = read_flags(ca_gag_access_flags_high) + new accessFlags = read_flags(ca_gag_access_flags) + new accessFlagsOwnReason = read_flags(ca_gag_access_flags_own_reason) + new accessFlagsOwnTime = read_flags(ca_gag_access_flags_own_time) - register_clcmd("enter_GagReason", "ClCmd_EnterGagReason", (accessFlagsHigh | accessFlagsOwnReason), .FlagManager = false) - register_clcmd("enter_GagTime", "ClCmd_EnterGagTime", (accessFlagsHigh | accessFlagsOwnTime), .FlagManager = false) + register_clcmd("enter_GagReason", "ClCmd_EnterGagReason", (accessFlagsHigh | accessFlagsOwnReason), .FlagManager = false) + register_clcmd("enter_GagTime", "ClCmd_EnterGagTime", (accessFlagsHigh | accessFlagsOwnTime), .FlagManager = false) - register_concmd("amx_gag", "ConCmd_amx_gag", accessFlagsHigh, "Usage: amx_gag [nickname | STEAM_ID | userID | IP]