|
楼主 |
发表于 2010-9-7 09:47:22
|
显示全部楼层
来自 中国–浙江–杭州
源代码:
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
#include <fun>
#define PLUGIN_NAME "自动开启SXE"
#define PLUGIN_VERSION "0.1"
#define PLUGIN_AUTHOR "DNA"
#define CHECK_FREQ 60
new sxe_start_time //强制SXE开启的开始时间
new sxe_end_time //强制SXE开启的结束时间
public plugin_init() {
sxe_start_time = register_cvar("amx_sxe_start_time", "0700")
sxe_end_time = register_cvar("amx_sxe_end_time", "2359")
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
set_task(float(CHECK_FREQ), "checkSxe", _, _, _, "b")
}
public checkSxe() {
new msg_buffer[100+1]
new CurrentTime[5]
new iSxe = get_cvar_num("__sxei_required")
get_time("%H%M", CurrentTime, 4)
format(msg_buffer, 100, "__sxei_required 当前值 %d", iSxe)
new iTime = str_to_num(CurrentTime)
if ( iTime >= get_pcvar_num(sxe_start_time) && iTime <= get_pcvar_num(sxe_end_time)) {
if (iSxe != 1) {
set_cvar_num("__sxei_required", 1)
format(msg_buffer, 100, "每天娱乐高峰期,强制要求开启SXE!当前时间 %s", CurrentTime)
log_amx(msg_buffer)
client_print(0, print_chat, msg_buffer)
}
} else {
if ( iSxe != 0 ) {
set_cvar_num("__sxei_required", 0)
format(msg_buffer, 100, "非高峰期,不强制要求SXE!当前时间 %s", CurrentTime)
log_amx(msg_buffer)
client_print(0, print_chat, msg_buffer)
}
}
return PLUGIN_HANDLED
} |
|