ccgcdh 发表于 2008-5-9 22:38:10

[求助]可以帮小弟做这样一个小插件吗?

是这样的……我们单位有自己的局域网,中午时间大家一起玩CS。服务器用计划任务设置每天中午12:00开启,想要在14:30自己关闭服务器,希望在游戏中每隔30分钟在屏幕左下角提醒“服务器将在__关闭!!离服务器关闭还有__小时__分钟.!!”关键是在最后30秒来个倒计时(最好在屏幕中间以随机颜色的大字体显示)提醒玩家退出游戏!

服务器版本为:DT-HLS3647纯净版
1.AMXMODX v1.7.6.3187
2.MetaMod v1.19
3.booster_mm v1.7.0

小弟在此先谢了!!

ccgcdh 发表于 2008-5-10 20:36:29

回复: [求助]可以帮小弟做这样一个小插件吗?

在坛里有找到(服务器定时关机)可是加载后,不会倒计时就直接关闭服务器了!!

下面是该插件的源码,谁帮忙改改

#include <amxmod>
#include <amxmisc>
#define READ_FROM_FILE
#if defined READ_FROM_FILE
new g_motdFile
#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
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
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
param = 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, 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
get_time("%H",THETIME,5)
new LIMITER
LIMITER = str_to_num(THETIME)
new THEMIN
get_time("%M",THEMIN,5)
new minutes
minutes = str_to_num(THEMIN)
new THESEC
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
get_time("%H",THETIME,5)
new LIMITER
LIMITER = str_to_num(THETIME)
new THEMIN
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, print_chat, "服务器将在 %d:%d 关闭.",ster,minster)
client_print(param, print_chat, "离服务器关闭还有 %d 小时 %d 分钟.",nokori,minnokori)
server_cmd("echo ^"服务器将在 %d:%d 关闭.^"",ster,minster)
server_cmd("echo ^"离服务器关闭还有 %d 小时 %d 分钟.^"",nokori,minnokori)
set_task(float(get_cvar_num( "check" )), "limited", param, param, 1, "b")
return PLUGIN_CONTINUE
}
页: [1]
查看完整版本: [求助]可以帮小弟做这样一个小插件吗?