PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_restart","admin_restart", ADMIN_CVAR,"<seconds> [optional message]");
}
public admin_restart(id,level,cid)
{
if(!cmd_access(id,level,cid,3)) //<-- Here you have to specify the number of arguments that you want to take from the command.
//In this case you want to take the command (0) , the value (1) and optional message (2) = 3 arguments.
{
return PLUGIN_HANDLED
}
new name[32]
new arg[32]
new msg[64]
read_argv(0,name,31) //With this you are read the command, why?
read_argv(1,arg,31)
read_args(msg,63)// Here you are reading the parameter.. Why? You have read that with "read_argv(1,arg,31). This you can use to hook a say.
remove_quotes(msg)// With this you are removing quotes from the parameter..
//-----------------------------------------------------------
//Add by me
read_argv(2, msg, 63)
if(equali(arg1,"") //arg1 ? You must changed it to arg
|| equali(arg1," "))
{
console_print(id,"^"sv_restart^" is ^"%d^"",get_cvar_num("sv_restart")) //get_cvar_num() is for cvars, this is a command. You must replace it by arg (in arg you have read the second argument). And you must replace %d by %s. Or you can do this:
//console_print(id, "^"sv_restart^" is ^"%d^"", str_to_num(arg))
return PLUGIN_HANDLED
}
set_cvar_num("sv_restart",str_to_num(arg)) //Again cvars..
get_user_name(id,name,31)
client_print(0,print_chat,"ADMIN %s: amx_restart %d %s",name,str_to_num(arg),msg) // You have to add the server_cmd() line to restart the server..
server_cmd("sv_restart %d", str_to_num(arg))
return PLUGIN_HANDLED
}