2004-02-21 19:36:35 +00:00
|
|
|
/* AMX Mod X
|
|
|
|
* Pause Plugins Plugin
|
2004-02-01 18:42:26 +00:00
|
|
|
*
|
2004-02-21 19:36:35 +00:00
|
|
|
* by the AMX Mod X Development Team
|
|
|
|
* originally developed by OLO
|
2004-02-01 18:42:26 +00:00
|
|
|
*
|
2004-02-21 19:36:35 +00:00
|
|
|
* This file is part of AMX Mod X.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the author gives permission to
|
|
|
|
* link the code of this program with the Half-Life Game Engine ("HL
|
|
|
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
|
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
|
|
* respects for all of the code used other than the HL Engine and MODs
|
|
|
|
* from Valve. If you modify this file, you may extend this exception
|
|
|
|
* to your version of the file, but you are not obligated to do so. If
|
|
|
|
* you do not wish to do so, delete this exception statement from your
|
|
|
|
* version.
|
2004-02-01 18:42:26 +00:00
|
|
|
*/
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-03-05 19:35:38 +00:00
|
|
|
#include <amxmodx>
|
2004-03-07 14:30:53 +00:00
|
|
|
#include <amxmisc>
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
// Uncomment if you want to have two new commands
|
|
|
|
// amx_off - pause plugins not marked as unpauseable
|
|
|
|
// amx_on - enable plugins not marked as unpauseable
|
2004-02-01 18:42:26 +00:00
|
|
|
#define DIRECT_ONOFF
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
#define MAX_SYSTEM 32
|
|
|
|
|
2014-07-20 10:27:02 +00:00
|
|
|
new g_menuPos[MAX_PLAYERS]
|
2004-07-26 15:49:10 +00:00
|
|
|
new g_fileToSave[64]
|
|
|
|
new g_coloredMenus
|
2004-01-31 20:56:22 +00:00
|
|
|
new g_Modified
|
|
|
|
new g_addCmd[] = "amx_pausecfg add ^"%s^""
|
|
|
|
new g_system[MAX_SYSTEM]
|
|
|
|
new g_systemNum
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_init()
|
|
|
|
{
|
|
|
|
register_plugin("Pause Plugins", AMXX_VERSION_STR, "AMXX Dev Team")
|
|
|
|
register_dictionary("pausecfg.txt")
|
|
|
|
register_dictionary("common.txt")
|
|
|
|
register_dictionary("admincmd.txt")
|
|
|
|
|
2006-11-22 04:13:39 +00:00
|
|
|
register_concmd("amx_pausecfg", "cmdPlugin", ADMIN_CFG, "- list commands for pause/unpause management")
|
2005-09-12 21:06:24 +00:00
|
|
|
register_clcmd("amx_pausecfgmenu", "cmdMenu", ADMIN_CFG, "- pause/unpause plugins with menu")
|
2004-01-31 20:56:22 +00:00
|
|
|
#if defined DIRECT_ONOFF
|
2005-09-12 21:06:24 +00:00
|
|
|
register_concmd("amx_off", "cmdOFF", ADMIN_CFG, "- pauses some plugins")
|
|
|
|
register_concmd("amx_on", "cmdON", ADMIN_CFG, "- unpauses some plugins")
|
2004-01-31 20:56:22 +00:00
|
|
|
#endif
|
2005-09-12 21:06:24 +00:00
|
|
|
register_menucmd(register_menuid("Pause/Unpause Plugins"), 1023, "actionMenu")
|
|
|
|
|
|
|
|
g_coloredMenus = colored_menus()
|
2014-07-29 14:32:32 +00:00
|
|
|
get_configsdir(g_fileToSave, charsmax(g_fileToSave));
|
|
|
|
format(g_fileToSave, charsmax(g_fileToSave), "%s/pausecfg.ini", g_fileToSave);
|
2004-08-05 11:09:16 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
return PLUGIN_CONTINUE
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined DIRECT_ONOFF
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdOFF(id, level, cid)
|
|
|
|
{
|
|
|
|
if (cmd_access(id, level, cid, 1))
|
|
|
|
pausePlugins(id)
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdON(id, level, cid)
|
|
|
|
{
|
|
|
|
if (cmd_access(id, level, cid, 1))
|
|
|
|
unpausePlugins(id)
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_cfg()
|
|
|
|
{
|
|
|
|
loadSettings(g_fileToSave)
|
|
|
|
|
|
|
|
// Put here titles of plugins which you don't want to pause
|
|
|
|
server_cmd(g_addCmd, "Admin Base")
|
|
|
|
server_cmd(g_addCmd, "Admin Base (SQL)")
|
|
|
|
server_cmd(g_addCmd, "Pause Plugins")
|
|
|
|
server_cmd(g_addCmd, "TimeLeft")
|
|
|
|
server_cmd(g_addCmd, "NextMap")
|
|
|
|
server_cmd(g_addCmd, "Slots Reservation")
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public actionMenu(id, key)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
if (file_exists(g_fileToSave))
|
|
|
|
{
|
|
|
|
delete_file(g_fileToSave)
|
|
|
|
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_CLEARED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
client_print(id, print_chat, "* %L", id, "PAUSE_ALR_CLEARED")
|
|
|
|
|
|
|
|
displayMenu(id, g_menuPos[id])
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
if (saveSettings(g_fileToSave))
|
|
|
|
{
|
|
|
|
g_Modified = 0
|
|
|
|
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_SAVED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
client_print(id, print_chat, "* %L", id, "PAUSE_SAVE_FAILED")
|
|
|
|
|
|
|
|
displayMenu(id, g_menuPos[id])
|
|
|
|
}
|
|
|
|
case 8: displayMenu(id, ++g_menuPos[id])
|
|
|
|
case 9: displayMenu(id, --g_menuPos[id])
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
new option = g_menuPos[id] * 6 + key
|
|
|
|
new file[32], status[2]
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(option, file, charsmax(file), status, 0, status, 0, status, 0, status, 1)
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
switch (status[0])
|
|
|
|
{
|
2007-09-09 03:34:52 +00:00
|
|
|
// "running"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 'r': pause("ac", file)
|
2007-09-09 03:34:52 +00:00
|
|
|
|
|
|
|
// "debug"
|
|
|
|
case 'd': pause("ac", file)
|
|
|
|
|
|
|
|
// "paused"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 'p':
|
|
|
|
{
|
|
|
|
g_Modified = 1
|
|
|
|
unpause("ac", file)
|
|
|
|
}
|
2007-09-09 03:34:52 +00:00
|
|
|
|
|
|
|
// "stopped"
|
2007-07-25 17:28:26 +00:00
|
|
|
case 's':
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "%L", id, "CANT_UNPAUSE_PLUGIN", file);
|
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
displayMenu(id, g_menuPos[id])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
getStatus(id, code, &statusCode, lStatus[], lLen)
|
|
|
|
{
|
|
|
|
switch (code)
|
|
|
|
{
|
2007-09-09 03:34:52 +00:00
|
|
|
// "running"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 'r':
|
|
|
|
{
|
|
|
|
statusCode = 'O'
|
|
|
|
format(lStatus, lLen, "%L", id, "ON")
|
|
|
|
}
|
2007-09-09 03:34:52 +00:00
|
|
|
|
|
|
|
// "debug"
|
|
|
|
case 'd':
|
|
|
|
{
|
|
|
|
statusCode = 'O'
|
|
|
|
format(lStatus, lLen, "%L", id, "ON")
|
|
|
|
}
|
|
|
|
|
|
|
|
// "stopped"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 's':
|
|
|
|
{
|
|
|
|
statusCode = 'S'
|
|
|
|
format(lStatus, lLen, "%L", id, "STOPPED")
|
|
|
|
}
|
2007-09-09 03:34:52 +00:00
|
|
|
|
|
|
|
// "paused"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 'p':
|
|
|
|
{
|
|
|
|
statusCode = 'O'
|
|
|
|
format(lStatus, lLen, "%L", id, "OFF")
|
|
|
|
}
|
2007-09-09 03:34:52 +00:00
|
|
|
|
|
|
|
// "bad load"
|
2005-09-12 21:06:24 +00:00
|
|
|
case 'b':
|
|
|
|
{
|
|
|
|
statusCode = 'E'
|
|
|
|
format(lStatus, lLen, "%L", id, "ERROR")
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
statusCode = 'L'
|
|
|
|
format(lStatus, lLen, "%L", id, "LOCKED")
|
|
|
|
}
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
isSystem(id)
|
|
|
|
{
|
|
|
|
for (new a = 0; a < g_systemNum; ++a)
|
|
|
|
if (g_system[a] == id)
|
|
|
|
return 1
|
|
|
|
return 0
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
displayMenu(id, pos)
|
|
|
|
{
|
|
|
|
if (pos < 0) return
|
|
|
|
|
|
|
|
new filename[32], title[32], status[8], statusCode
|
|
|
|
new datanum = get_pluginsnum()
|
|
|
|
new menu_body[512], start = pos * 6, k = 0
|
|
|
|
|
|
|
|
if (start >= datanum)
|
|
|
|
start = pos = g_menuPos[id] = 0
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
new len = format(menu_body, charsmax(menu_body), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "PAUSE_UNPAUSE", pos + 1, ((datanum / 6) + ((datanum % 6) ? 1 : 0)))
|
2005-09-12 21:06:24 +00:00
|
|
|
new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
|
|
|
|
|
|
|
|
if (end > datanum)
|
|
|
|
end = datanum
|
|
|
|
|
|
|
|
for (new a = start; a < end; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, filename, charsmax(filename), title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
|
|
|
getStatus(id, status[0], statusCode, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (isSystem(a) || (statusCode != 'O' && statusCode != 'S'))
|
|
|
|
{
|
|
|
|
if (g_coloredMenus)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menu_body[len], charsmax(menu_body) - len, "\d%d. %s\R%s^n\w", ++k, title, status)
|
2005-09-12 21:06:24 +00:00
|
|
|
} else {
|
|
|
|
++k
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menu_body[len], charsmax(menu_body) - len, "#. %s %s^n", title, status)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
keys |= (1<<k)
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menu_body[len], charsmax(menu_body) - len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++k, title, status)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
len += format(menu_body[len], charsmax(menu_body) - len, "^n7. %L^n", id, "CLEAR_PAUSED")
|
|
|
|
len += format(menu_body[len], charsmax(menu_body) - len, g_coloredMenus ? "8. %L \y\R%s^n\w" : "8. %L %s^n", id, "SAVE_PAUSED", g_Modified ? "*" : "")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (end != datanum)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menu_body[len], charsmax(menu_body) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
2005-09-12 21:06:24 +00:00
|
|
|
keys |= MENU_KEY_9
|
|
|
|
}
|
|
|
|
else
|
2014-07-29 14:32:32 +00:00
|
|
|
format(menu_body[len], charsmax(menu_body) - len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
show_menu(id, keys, menu_body, -1, "Pause/Unpause Plugins")
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdMenu(id, level, cid)
|
|
|
|
{
|
|
|
|
if (cmd_access(id, level, cid, 1))
|
|
|
|
displayMenu(id, g_menuPos[id] = 0)
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
pausePlugins(id)
|
|
|
|
{
|
|
|
|
new filename[32], title[32], status[2]
|
|
|
|
new count = 0, imax = get_pluginsnum()
|
|
|
|
|
|
|
|
for (new a = 0; a < imax; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, filename, charsmax(filename), title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (!isSystem(a) && status[0] == 'r' && pause("ac", filename))
|
|
|
|
{
|
|
|
|
//console_print(id, "Pausing %s (file ^"%s^")", title, filename)
|
|
|
|
++count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console_print(id, "%L", id, (count == 1) ? "PAUSED_PLUGIN" : "PAUSED_PLUGINS", count)
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
unpausePlugins(id)
|
|
|
|
{
|
|
|
|
new filename[32], title[32], status[2]
|
|
|
|
new count = 0, imax = get_pluginsnum()
|
|
|
|
|
|
|
|
for (new a = 0; a < imax; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, filename, charsmax(filename), title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (!isSystem(a) && status[0] == 'p' && unpause("ac", filename))
|
|
|
|
{
|
|
|
|
//console_print(id, "Unpausing %s (file ^"%s^")", title, filename)
|
|
|
|
++count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console_print(id, "%L", id, (count == 1) ? "UNPAUSED_PLUGIN" : "UNPAUSED_PLUGINS", count)
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
findPluginByFile(arg[32], &len)
|
|
|
|
{
|
|
|
|
new name[32], title[32], status[2]
|
|
|
|
new inum = get_pluginsnum()
|
|
|
|
|
|
|
|
for (new a = 0; a < inum; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, name, charsmax(name), title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-02-21 21:03:48 +00:00
|
|
|
if (equali(name, arg, len) && (
|
|
|
|
status[0] == 'r' || /*running*/
|
|
|
|
status[0] == 'p' || /*paused*/
|
|
|
|
status[0] == 's' || /*stopped*/
|
|
|
|
status[0] == 'd' )) /*debug*/
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
len = copy(arg, charsmax(arg), name)
|
2005-09-12 21:06:24 +00:00
|
|
|
return a
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
findPluginByTitle(name[], file[], len)
|
|
|
|
{
|
|
|
|
new title[32], status[2]
|
|
|
|
new inum = get_pluginsnum()
|
|
|
|
|
|
|
|
for (new a = 0; a < inum; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, file, len, title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (equali(title, name))
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public cmdPlugin(id, level, cid)
|
|
|
|
{
|
|
|
|
if (!cmd_access(id, level, cid, 1))
|
|
|
|
return PLUGIN_HANDLED
|
|
|
|
|
|
|
|
new cmds[32]
|
2014-07-29 14:32:32 +00:00
|
|
|
read_argv(1, cmds, charsmax(cmds))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (equal(cmds, "add") && read_argc() > 2)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
read_argv(2, cmds, charsmax(cmds))
|
2005-09-12 21:06:24 +00:00
|
|
|
new file[2]
|
|
|
|
|
|
|
|
if ((g_system[g_systemNum] = findPluginByTitle(cmds, file, 0)) != -1)
|
|
|
|
{
|
|
|
|
if (g_systemNum < MAX_SYSTEM)
|
|
|
|
g_systemNum++
|
|
|
|
else
|
|
|
|
console_print(id, "%L", id, "CANT_MARK_MORE")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "off"))
|
|
|
|
{
|
|
|
|
pausePlugins(id)
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "on"))
|
|
|
|
{
|
|
|
|
unpausePlugins(id)
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "save"))
|
|
|
|
{
|
|
|
|
if (saveSettings(g_fileToSave))
|
|
|
|
{
|
|
|
|
g_Modified = 0
|
|
|
|
console_print(id, "%L", id, "PAUSE_CONF_SAVED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
console_print(id, "%L", id, "PAUSE_SAVE_FAILED")
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "clear"))
|
|
|
|
{
|
|
|
|
if (file_exists(g_fileToSave))
|
|
|
|
{
|
|
|
|
delete_file(g_fileToSave)
|
|
|
|
console_print(id, "%L", id, "PAUSE_CONF_CLEARED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
console_print(id, "%L", id, "PAUSE_ALR_CLEARED")
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "pause"))
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
new arg[32], a, len = read_argv(2, arg, charsmax(arg))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (len && ((a = findPluginByFile(arg, len)) != -1) && !isSystem(a) && pause("ac", arg))
|
|
|
|
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "PAUSED")
|
|
|
|
else
|
|
|
|
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "enable"))
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
new arg[32], a, len = read_argv(2, arg, charsmax(arg))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-02-21 21:03:48 +00:00
|
|
|
if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a))
|
|
|
|
{
|
|
|
|
if (unpause("ac", arg))
|
|
|
|
{
|
|
|
|
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "UNPAUSED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-25 17:28:26 +00:00
|
|
|
console_print(id, "%L", id, "CANT_UNPAUSE_PLUGIN", arg)
|
2007-02-21 21:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
else
|
2007-02-21 21:03:48 +00:00
|
|
|
{
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
|
2007-02-21 21:03:48 +00:00
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
else if (equal(cmds, "stop"))
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
new arg[32], a, len = read_argv(2, arg, charsmax(arg))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a) && pause("dc", arg))
|
|
|
|
{
|
|
|
|
g_Modified = 1
|
|
|
|
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "STOPPED")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
|
|
|
|
}
|
|
|
|
else if (equal(cmds, "list"))
|
|
|
|
{
|
|
|
|
new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
format(lName, charsmax(lName), "%L", id, "NAME")
|
|
|
|
format(lVersion, charsmax(lVersion), "%L", id, "VERSION")
|
|
|
|
format(lAuthor, charsmax(lAuthor), "%L", id, "AUTHOR")
|
|
|
|
format(lFile, charsmax(lFile), "%L", id, "FILE")
|
|
|
|
format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
new arg1[8], running = 0
|
2014-07-29 14:32:32 +00:00
|
|
|
new start = read_argv(2, arg1, charsmax(arg1)) ? str_to_num(arg1) : 1
|
2005-09-12 21:06:24 +00:00
|
|
|
|
|
|
|
if (--start < 0)
|
|
|
|
start = 0
|
|
|
|
|
|
|
|
new plgnum = get_pluginsnum()
|
|
|
|
|
|
|
|
if (start >= plgnum)
|
|
|
|
start = plgnum - 1
|
|
|
|
|
|
|
|
console_print(id, "^n----- %L -----", id, "PAUSE_LOADED")
|
|
|
|
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
|
|
|
|
|
|
|
|
new plugin[32], title[32], version[16], author[32], status[16]
|
|
|
|
new end = start + 10
|
|
|
|
|
|
|
|
if (end > plgnum) end = plgnum
|
|
|
|
|
|
|
|
for (new a = start; a < end; ++a)
|
|
|
|
{
|
2014-07-30 08:19:41 +00:00
|
|
|
get_plugin(a, plugin, charsmax(plugin), title, charsmax(title), version, charsmax(version), author, charsmax(author), status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
if (status[0] == 'r') ++running
|
|
|
|
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", a + 1, title, version, author, plugin, status)
|
|
|
|
}
|
|
|
|
|
|
|
|
console_print(id, "----- %L -----", id, "PAUSE_ENTRIES", start + 1, end, plgnum, running)
|
|
|
|
|
|
|
|
if (end < plgnum)
|
|
|
|
console_print(id, "----- %L -----", id, "PAUSE_USE_MORE", end + 1)
|
|
|
|
else
|
|
|
|
console_print(id, "----- %L -----", id, "PAUSE_USE_BEGIN")
|
|
|
|
} else {
|
|
|
|
console_print(id, "%L", id, "PAUSE_USAGE")
|
|
|
|
console_print(id, "%L:", id, "PAUSE_COMMANDS")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_OFF")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_ON")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_STOP")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_PAUSE")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_ENABLE")
|
2007-07-25 17:28:26 +00:00
|
|
|
console_print(id, "%L", id, "COM_PAUSE_SAVE_PAUSED")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_CLEAR_PAUSED")
|
2005-09-12 21:06:24 +00:00
|
|
|
console_print(id, "%L", id, "COM_PAUSE_LIST")
|
|
|
|
console_print(id, "%L", id, "COM_PAUSE_ADD")
|
|
|
|
}
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
saveSettings(filename[])
|
|
|
|
{
|
|
|
|
if (file_exists(filename))
|
|
|
|
delete_file(filename)
|
|
|
|
|
|
|
|
new text[256], file[32], title[32], status[2]
|
|
|
|
new inum = get_pluginsnum()
|
|
|
|
|
|
|
|
if (!write_file(filename, ";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
|
|
|
|
return 0
|
|
|
|
|
|
|
|
for (new a = 0; a < inum; ++a)
|
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
get_plugin(a, file, charsmax(file), title, charsmax(title), status, 0, status, 0, status, charsmax(status))
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2007-09-09 03:34:52 +00:00
|
|
|
// "paused"
|
|
|
|
if (status[0] == 'p')
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
format(text, charsmax(text), "^"%s^" ;%s", title, file)
|
2005-09-12 21:06:24 +00:00
|
|
|
write_file(filename, text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
loadSettings(filename[])
|
|
|
|
{
|
|
|
|
if (!file_exists(filename))
|
|
|
|
return 0
|
|
|
|
|
|
|
|
new name[256], file[32], i, pos = 0
|
|
|
|
|
2014-07-29 14:32:32 +00:00
|
|
|
while (read_file(filename, pos++, name, charsmax(name), i))
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2014-07-29 14:32:32 +00:00
|
|
|
if (name[0] != ';' && parse(name, name, charsmax(name)) && (i = findPluginByTitle(name, file, charsmax(file)) != -1))
|
2007-09-09 03:34:52 +00:00
|
|
|
pause("ac", file)
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1
|
2004-08-22 04:25:55 +00:00
|
|
|
}
|