mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
Add ActivityTrim to prevent double whitespace in messages
This commit is contained in:
parent
d2c71a4e10
commit
61ffeee016
@ -16,7 +16,18 @@
|
|||||||
#include <amxmodx>
|
#include <amxmodx>
|
||||||
#endif
|
#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
|
* 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);
|
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)
|
switch(activity_trim)
|
||||||
replace_all(buffer, len, activity_ph_name, cansee ? name : "");
|
{
|
||||||
|
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 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 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_name Placeholder for the admin name used in show_activity_custom()
|
||||||
* @param ph_prefix Placeholder for the user prefix used in show_activity_custom()
|
* @param ph_prefix Placeholder for the user prefix used in show_activity_custom()
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @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_color = color;
|
||||||
activity_sender = sender;
|
activity_sender = sender;
|
||||||
activity_ph_name = ph_name;
|
activity_trim = trim_ws;
|
||||||
activity_ph_prefix = ph_prefix;
|
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_sender = print_team_default;
|
||||||
activity_ph_name = "$an";
|
activity_ph_name = "$an";
|
||||||
activity_ph_prefix = "$pr";
|
activity_ph_prefix = "$pr";
|
||||||
|
activity_trim = ActivityTrim_After;
|
||||||
activity_pointer = get_cvar_pointer("amx_show_activity");
|
activity_pointer = get_cvar_pointer("amx_show_activity");
|
||||||
|
|
||||||
if(!activity_pointer)
|
if(!activity_pointer)
|
||||||
|
Loading…
Reference in New Issue
Block a user