forked from VANCOLD/fm_drive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FM_ADMIN_CHAT.sma
46 lines (34 loc) · 1.6 KB
/
FM_ADMIN_CHAT.sma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "feckinmad/fm_global"
#include "feckinmad/fm_admin_access"
new g_iMaxPlayers
public plugin_init()
{
fm_RegisterPlugin()
register_concmd("admin_chat", "Admin_Chat", ADMIN_HIGHER, "<message>")
g_iMaxPlayers = get_maxplayers()
}
public Admin_Chat(id, iLevel, iCommand)
{
if (!fm_CommandAccess(id, iLevel, false) || !fm_CommandUsage(id, iCommand, 2))
return PLUGIN_HANDLED
new sArgs[192]; read_args(sArgs, charsmax(sArgs))
remove_quotes(sArgs) // Remove the quotes associated with "messagemode" binds
trim(sArgs)
if (!sArgs[0]) // Avoid printing blank lines
return PLUGIN_HANDLED
// Replace % characters with an actual % to avoid formatting errors
replace_all(sArgs, charsmax(sArgs), "%", "%%%%")
new sAdminName[MAX_NAME_LEN]; get_user_name(id, sAdminName, charsmax(sAdminName))
new sAdminAuthid[MAX_AUTHID_LEN]; get_user_authid(id, sAdminAuthid, charsmax(sAdminAuthid))
new sAdminRealName[MAX_NAME_LEN]; fm_GetUserRealname(id, sAdminRealName, charsmax(sAdminRealName))
new sMessage[MAX_CHAT_LEN]
if (equali(sAdminName, sAdminRealName))
formatex(sMessage, charsmax(sMessage), "(ADMIN) #%d %s: %s", fm_GetUserIdent(id), sAdminName, sArgs)
else
formatex(sMessage, charsmax(sMessage), "(ADMIN) #%d %s (%s): %s", fm_GetUserIdent(id), sAdminName, sAdminRealName, sArgs)
for (new i = 1; i <= g_iMaxPlayers; i++)
if (is_user_connected(i) && (fm_GetUserAccess(i) & iLevel)) // Display the message to players that have access to this command
client_print(i, print_chat, sMessage)
log_amx("\"%s<%s>(%s)\" admin_chat \"%s\"", sAdminName, sAdminAuthid, sAdminRealName, sArgs)
return PLUGIN_HANDLED
}