|
此插件为在指定时间关闭服务器。
amx_limit_hours 指定关闭的时间单位
amx_limit_minutes 指定关闭的分单位
比如
amx_limit_hours 22
amx_limit_minutes 45
为晚间10时25分关闭服务器。
在configs目录下建立一个quitmessage.txt文件,里面记录向用户发送的信息。
我在amxx1.6下无法编译通过,请知道的稍作修改使用。
#include <amxmod>
#include <amxmisc>
#define READ_FROM_FILE
#if defined READ_FROM_FILE
new g_motdFile[64]
#endif
public plugin_init(){
register_plugin("Server End Timer","1.0","+ARUKARI-")
register_cvar("amx_limit_hours","0")
register_cvar("amx_limit_minutes","00")
register_cvar("amx_limit_check","1")
if ( get_cvar_num( "amx_limit_check" ) <= 0 ) set_cvar_num( "amx_limit_check" , 1 )
get_configsdir(g_motdFile, 63);
format(g_motdFile, 63, "%s/quitmessage.txt", g_motdFile);
set_task(float(get_cvar_num( "check" )), "limited")
return PLUGIN_CONTINUE
}
public amx_limit_hours(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[8]
read_argv(1,arg,7)
if (strtonum(arg) > 23){
console_print(id,"/*php Invalid parameter. Must be a number between 0 - 23")
return PLUGIN_HANDLED
}
set_cvar_string("amx_limit_hours",arg)
return PLUGIN_HANDLED
}
public amx_limit_minutes(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[8]
read_argv(1,arg,7)
if (strtonum(arg) > 59){
console_print(id,"/*php Invalid parameter. Must be a number between 0 - 59")
return PLUGIN_HANDLED
}
set_cvar_string("amx_limit_minutes",arg)
return PLUGIN_HANDLED
}
public client_putinserver(id) {
if (!is_user_bot(id)) {
new param[1]
param[0] = id
set_task(30.0, "showEndTime", id, param, 1)
}
return PLUGIN_CONTINUE
}
TheEnd(id,level,cid) {
if (!cmd_access(id,level,cid,1))
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^" ^"")
client_cmd(0, "echo ^"==============================================================^"")
#if defined READ_FROM_FILE
if (file_exists(g_motdFile)) {
new message[192], len, line = 0
while(read_file(g_motdFile,line++,message,191,len))
server_cmd("echo ^"%s^"",message)
client_cmd(0,"echo ^"%s^"",message)
}
#endif
client_cmd(0, "echo ^"==============================================================^"")
client_cmd(0, "echo ^" ^"") server_cmd("quit")
return PLUGIN_CONTINUE
}
public limited(){
new ster = get_cvar_num("amx_limit_hours")
new minster = get_cvar_num("amx_limit_minutes")
new THETIME[6]
get_time("%H",THETIME,5)
new LIMITER
LIMITER = str_to_num(THETIME)
new THEMIN[6]
get_time("%M",THEMIN,5)
new minutes
minutes = str_to_num(THEMIN)
new THESEC[6]
get_time("%S",THESEC,5)
new seconds
seconds = str_to_num(THESEC)
if(LIMITER == ster && minutes == minster && seconds == 0){
new id,level,cid
TheEnd(id,level,cid)
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 1 && (minster - minutes) == 0 && seconds == 0){
client_print(0, print_chat, "To the server end, the rest 1 hours 0 minutes.")
client_cmd(0, "spk ^"fvox/vitalsigns_on communications_on time_remaining one hours^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 3 && seconds == 0){
client_print(0, print_chat, "To the server end, the rest 0 hours 3 minutes.")
client_cmd(0, "spk ^"fvox/ time_remaining three minutes^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 10){
client_print(0, print_chat, "*************************************10")
client_cmd(0, "spk ^"fvox/ten^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 9){
client_print(0, print_chat, "**************************************9")
client_cmd(0, "spk ^"fvox/nine^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 8 ){
client_print(0, print_chat, "**************************************8")
client_cmd(0, "spk ^"fvox/eight^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 7){
client_print(0, print_chat, "**************************************7")
client_cmd(0, "spk ^"fvox/seven^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 6){
client_print(0, print_chat, "**************************************6")
client_cmd(0, "spk ^"fvox/six^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 5){
client_print(0, print_chat, "**************************************5")
client_cmd(0, "spk ^"fvox/five^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 4){
client_print(0, print_chat, "**************************************4")
client_cmd(0, "spk ^"fvox/four^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 3){
client_print(0, print_chat, "**************************************3")
client_cmd(0, "spk ^"fvox/three^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 2){
client_print(0, print_chat, "**************************************2")
client_cmd(0, "spk ^"fvox/two^"")
return PLUGIN_HANDLED
}else if((ster - LIMITER) == 0 && (minster - minutes) == 0 && (60 - seconds) == 1){
client_print(0, print_chat, "**************************************1")
client_cmd(0, "spk ^"fvox/one^"")
client_cmd(0, "toggleconsole")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public showEndTime(param[]) {
new ster = get_cvar_num("amx_limit_hours")
new minster = get_cvar_num("amx_limit_minutes")
new THETIME[6]
get_time("%H",THETIME,5)
new LIMITER
LIMITER = str_to_num(THETIME)
new THEMIN[6]
get_time("%M",THEMIN,5)
new minutes
minutes = str_to_num(THEMIN)
new nokori = (ster - LIMITER)
new minnokori = (minster - minutes)
if(nokori < 0 && minnokori < 0){
nokori = (((ster - LIMITER) + 24) -1)
minnokori = ((60 - minutes) + minster)
}else if(nokori < 0 && minnokori >= 0){
nokori = ((ster - LIMITER) + 24)
}else if(nokori >= 0 && minnokori < 0){
nokori = ((ster - LIMITER) -1)
minnokori = ((60 - minutes) + minster)
}
client_print(param[0], print_chat, "This server is in the end at %d:%d o'clock.",ster,minster)
client_print(param[0], print_chat, "It is the rest %d hours %d minutes.",nokori,minnokori)
server_cmd("echo ^"This server is in the end at %d:%d o'clock.^"",ster,minster)
server_cmd("echo ^"It is the rest %d hours %d minutes.^"",nokori,minnokori)
set_task(float(get_cvar_num( "check" )), "limited", param[0], param, 1, "b")
return PLUGIN_CONTINUE
} |
|