diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index 6c2bfeeb..1bf2e671 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -16,7 +16,18 @@ #include #endif -static bool:activity_color, activity_sender, activity_ph_name[32], activity_ph_prefix[32]; +/** + * Used in replace_activity_data() to specify if and where a whitespace should + * be removed from the admin's name when the client isn't supposed to see it + */ +enum ActivityTrim +{ + ActivityTrim_None = 0, + ActivityTrim_Before, + ActivityTrim_After +} + +static ActivityTrim:activity_trim, bool:activity_color, activity_sender, activity_ph_name[32], activity_ph_prefix[32]; /** * Returns if the client has any admin flags set @@ -454,10 +465,20 @@ stock replace_activity_data(id, const name[], buffer[], len) replace_all(buffer, len, activity_ph_prefix, prefix); } - new cansee = can_see_admin_name(id); + if(can_see_admin_name(id)) + replace_string(buffer, len, activity_ph_name, name); + else + { + new ph[32]; - if(cansee != -1) - replace_all(buffer, len, activity_ph_name, cansee ? name : ""); + switch(activity_trim) + { + case ActivityTrim_Before: formatex(ph, charsmax(ph), " %s", activity_ph_name); + case ActivityTrim_After: formatex(ph, charsmax(ph), "%s ", activity_ph_name); + } + + replace_string(buffer, len, ph, ""); + } } /** @@ -473,17 +494,23 @@ stock replace_activity_data(id, const name[], buffer[], len) * * @param color Set this to true if you want to use colored chat messages * @param sender Sender id or print_team_* constant for colored messages + * @param trim_ws Specifies if and where a whitespace should be removed from the + * admin name if the client isn't supposed to see it: + * ActivityTrim_None - don't remove any whitespace + * ActivityTrim_Before - remove the whitespace before the name + * ActivityTrim_After - remove the whitespace after the name * @param ph_name Placeholder for the admin name used in show_activity_custom() * @param ph_prefix Placeholder for the user prefix used in show_activity_custom() * * @noreturn */ -stock set_activity_rules(bool:color, sender = print_team_default, ph_name[] = "$an", ph_prefix[] = "$pr") +stock set_activity_rules(bool:color, sender = print_team_default, ActivityTrim:trim_ws = ActivityTrim_After, ph_name[] = "$an", ph_prefix[] = "$pr") { activity_color = color; activity_sender = sender; - activity_ph_name = ph_name; - activity_ph_prefix = ph_prefix; + activity_trim = trim_ws; + copy(activity_ph_name, charsmax(activity_ph_name), ph_name); + copy(activity_ph_prefix, charsmax(activity_ph_prefix), ph_prefix); } /** @@ -503,6 +530,7 @@ stock activity_init() activity_sender = print_team_default; activity_ph_name = "$an"; activity_ph_prefix = "$pr"; + activity_trim = ActivityTrim_After; activity_pointer = get_cvar_pointer("amx_show_activity"); if(!activity_pointer)