text
stringlengths
0
692
/* Handles command amx_msglog */
public cmd_msglog(id, level, cid) {
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new argCmd[6]
read_argv(1, argCmd, 5)
remove_quotes(argCmd)
if (equali(argCmd, "start") || equali(argCmd, "stop")) // start or stop commands
{
new argMsg[32]
read_argv(2, argMsg, 31)
remove_quotes(argMsg)
new msgid = str_to_msgid(argMsg)
if (is_msg_valid(msgid))
{
new status = get_msglog_status(msgid)
if (argCmd[2] == 'a') // start <message>
{
if (status == MSGLOG_STOPPED)
{
set_msglog_status(msgid, MSGLOG_STARTED)
log_msgf("Logging started for message (%s ^"%d^")", g_msgCache[msgid], msgid)
}
else
console_print(id, "Logging has already been started for message (%s ^"%d^")", g_msgCache[msgid], msgid)
}
else // stop <message>
{
if (status == MSGLOG_STARTED)
{
set_msglog_status(msgid, MSGLOG_STOPPED)
log_msgf("Logging stopped for message (%s ^"%d^")", g_msgCache[msgid], msgid)
}
else
console_print(id, "Logging has already been stopped for message (%s ^"%d^")", g_msgCache[msgid], msgid)
}
}
else
{
// If msg name or ID isn't blank, then at this point we have an invalid msg
if (argMsg[0])
{
console_print(id, "%s is not a valid message name or ID", argMsg)
return PLUGIN_HANDLED
}
if (argCmd[2] == 'a') // start
{
set_msglog_status(0, MSGLOG_STARTED)
log_msgf("Logging started for all messages")
}
else // stop
{
set_msglog_status(0, MSGLOG_STOPPED)
log_msgf("Logging stopped for all messages")
}
}
}
else if (equali(argCmd, "list")) // list command
{
new argStart[4]
new start = read_argv(2, argStart, 3) ? str_to_num(argStart) : 1
if (start < 1)
start = 1
else if (start > g_maxMessages)
start = g_maxMessages
new end = start + 9
if (end > g_maxMessages)
end = g_maxMessages
new logstatus[8], msgname[32]
console_print(id, "^n------------ Message Logging Statuses -------------")
console_print(id, " %-31s %s", "Message Name", "Status")
for (new i = start; i <= end; i++)
{
copy(msgname, 31, g_msgCache[i])
if (!msgname[0])
copy(msgname, 31, "<Unknown>")
copy(logstatus, 7, g_msgLogging[i] ? "LOGGING" : "IDLE")
console_print(id, "%3d: %-31s %s", i, msgname, logstatus)
}
console_print(id, "Entries %d - %d of %d", start, end, g_maxMessages)
if (end < g_maxMessages)
console_print(id, "-------- Use 'amx_msglog list %d' for more --------", end + 1)
else
console_print(id,"-------- Use 'amx_msglog list 1' for beginning --------")