Signature
stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...){// The variable gets used via vformat, but the compiler doesn't know that, so it still cries.#pragma unused ___AdminName static __amx_show_activity; if(__amx_show_activity == 0) { __amx_show_activity = get_cvar_pointer("amx_show_activity"); // if still not found, then register the cvar as a dummy if(__amx_show_activity == 0) { __amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED); } } new buffer[512]; new keyfmt[256]; new i; switch(get_pcvar_num(__amx_show_activity)) { case 5: // hide name to admins, display nothing to normal players { while(i++ < MaxClients) { if(is_user_connected(i)) { if(is_user_admin(i)) { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); // skip the "adminname" argument if not showing name vformat(buffer, charsmax(buffer), keyfmt, 4); client_print(i, print_chat, "%s", buffer); } } } } case 4: // show name only to admins, display nothing to normal players { while(i++ < MaxClients) { if(is_user_connected(i)) { if(is_user_admin(i)) { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); vformat(buffer, charsmax(buffer), keyfmt, 3); client_print(i, print_chat, "%s", buffer); } } } } case 3: // show name only to admins, hide name from normal users { while(i++ < MaxClients) { if(is_user_connected(i)) { if(is_user_admin(i)) { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); vformat(buffer, charsmax(buffer), keyfmt, 3); } else { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); // skip the "adminname" argument if not showing name vformat(buffer, charsmax(buffer), keyfmt, 4); } client_print(i, print_chat, "%s", buffer); } } } case 2: // show name to all users { while(i++ < MaxClients) { if(is_user_connected(i)) { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); vformat(buffer, charsmax(buffer), keyfmt, 3); client_print(i, print_chat, "%s", buffer); } } } case 1: // hide name from all users { while(i++ < MaxClients) { if(is_user_connected(i)) { LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); // skip the "adminname" argument if not showing name vformat(buffer, charsmax(buffer), keyfmt, 4); client_print(i, print_chat, "%s", buffer); } } } }}
Description
Standard method to show activity to one single client with normal language keys.
These keys need to be in the format of standard AMXX keys:
eg: ADMIN_KICK_1 = ADMIN: kick %s
ADMIN_KICK_2 = ADMIN %s: kick %s
This depends on the amx_show_activity cvar. See documentation for more details.
Parameters
- KeyWithoutName — The language key that does not have the name field.
- KeyWithName — The language key that does have the name field.
- __AdminName — The name of the person doing the action.
- ... — Pass any extra format arguments for the language key in the variable arguments list.
No return value