时间提示带源码
/*server_chime_plugin.sma
Server Clock Chime Plugin
服务器时间报时插件
Coded by Jack9
"Powered by AMX Mod"
Custom Alterations to original by Jack9 11/24/02
Custom Alterations to original by Jack9 02/14/03
**** Updates by Vantage aka Mouse ****
1.9 Fixed offset bug (don't ask...)
1.9 **** New Cvar and All Cvars have changed names and act different! *******
1.8 Fixed very poor coding bugs. 12am as 0 fix. Offset code fixed(ok maybe not)
1.8 Added Option for Center Color Time display like in SM.
1.8 Commented my code better
*/
/* COMMANDS
Client:
say "time" in chat (wo quotes)
Server:
"time" in console (wo quotes)
******** When not using default cvars, must set cvars, before server start, in server/listenserver cfg file. ********
cvar - j9_time_display "abc" is default. "a" displays chat time. "b" displays chat date.
"c" displays time in color on top center of screen like in SM.
cvar - j9_time_speak - 2 is default. 0 = No sound, 1 = Just Beep, 2 = Beep and Time Speak
cvar - j9_time_interval - 1 is default. 0 = Every Hour, 1 = Half Hour, 2 = 15 Minutes
cvar - j9_time_offset - 0 is default. Can set negative or positive the number of hours to offset time by.
*/
//命令变量
//j9_time_display "abc"是默认设置。a显示时间,b显示日期,c象SM一样,在屏幕中上方显示有颜色的时间。
//j9_time_speak 2是默认值。0无声,1只有嘟嘟声,2嘟嘟声和发出时间声
//j9_time_interval 1是默认值。0每小时,1半个小时,2是15分钟
//j9_time_offset 0是默认值。 可以抵消正负时间数值。
#include <amxmod>
new CENTER_TIME_COLOR = {255,0,125}
new MONTHS[] = {"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}
new WEEK[] = {"日","一","二","三","四","五","六"}
new DAY[] = {"一","二","三","四","五","六","七","八","九","十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十","三十一"}
new Float:Time_Interval = 180.0 // Interval client "say time" command can be used in seconds多少秒时间间隔才能用say time命令.
new cant_time
new cvar_display
new cvar_speak
new cvar_interval
new cvar_offset
public SpeakTime(id)
{
if(id){
if(cant_time){
client_print(id, print_chat,"*** 你只能每 %.0f 分钟使用一次这个命令. ***", Time_Interval/60.0)
return PLUGIN_HANDLED
}
cant_time = 1
new a_id
a_id = id
set_task(Time_Interval,"remove_cant_time",0, a_id,1)
}
new w_Hour, w_Minutes1, w_Minutes2, am_pm, apm
new ns_Hour, ns_Minutes,ns_Month,ns_Day,ns_Year, ns_Week
get_time("%H",ns_Hour, 2)
get_time("%M", ns_Minutes, 2)
get_time("%m", ns_Month, 2)
get_time("%d", ns_Day, 2)
get_time("%Y", ns_Year, 4)
get_time("%w", ns_Week, 4)
new num_Hour = str_to_num(ns_Hour) + cvar_offset
if(num_Hour > 23) // To fix offset
num_Hour = num_Hour - 24
if(num_Hour < 0)
num_Hour = 24 + num_Hour
/*以下是增加显示“凌晨、早晨、上午、中午、下午、黄昏、晚上、午夜”时间段功能代码 By Undoer*/
switch(num_Hour)
{
case 0: copy(am_pm,8,"凌晨")
case 1: copy(am_pm,8,"凌晨")
case 2: copy(am_pm,8,"凌晨")
case 3: copy(am_pm,8,"凌晨")
case 4: copy(am_pm,8,"凌晨")
case 5: copy(am_pm,8,"凌晨")
case 6: copy(am_pm,8,"早晨")
case 7: copy(am_pm,8,"早晨")
case 8: copy(am_pm,8,"上午")
case 9: copy(am_pm,8,"上午")
case 10: copy(am_pm,8,"上午")
case 11: copy(am_pm,8,"上午")
case 12: copy(am_pm,8,"中午")
case 13: copy(am_pm,8,"下午")
case 14: copy(am_pm,8,"下午")
case 15: copy(am_pm,8,"下午")
case 16: copy(am_pm,8,"下午")
case 17: copy(am_pm,8,"下午")
case 18: copy(am_pm,8,"黄昏")
case 19: copy(am_pm,8,"晚上")
case 20: copy(am_pm,8,"晚上")
case 21: copy(am_pm,8,"晚上")
case 22: copy(am_pm,8,"晚上")
case 23: copy(am_pm,8,"午夜")
case 24: copy(am_pm,8,"凌晨")
} /*增加止2005-04-11*/
/*由于报时声音文件的原因,当时间大于20点时就无法报出时间声音!
为了可以正常报时,还是使用原代码发音代码,但显示已改了实际时间。*/
new u_Hour = num_Hour
if(u_Hour > 11){// If it's pm save as such but correct time so its 0-11 o'clock (0 = 11) instead of 12-23 pm
u_Hour -= 12
copy(apm,2,"pm")
}
else
copy(apm,2,"am")
if(!u_Hour) // If = to 0 it's really 12 o'clock am/pm
u_Hour = 12
if (cvar_speak == 2){
num_to_word(u_Hour,w_Hour,10) // vox "hour" real/wave file name
if(ns_Minutes == '1'){ // for speech if minutes are teens, vox has all teens as wav files so...
num_to_word(str_to_num(ns_Minutes),w_Minutes1,10) // turn teens in to their real/wav names
}
else{
if(ns_Minutes == '0'){ // Minutes = 0
if(ns_Minutes != '0')
copy(w_Minutes1,10,"boop")
}
else{// Minutes = 20 30 40 50
new PH[] = "00"
PH = ns_Minutes
num_to_word(str_to_num(PH),w_Minutes1,10)
}
if(ns_Minutes != '0'){ // Minutes = 21,22,23... 31,32,33... etc
num_to_word(str_to_num(ns_Minutes),w_Minutes2,10)
}
}
client_cmd(id,"speak ^"misc/fvox/blip _comma blip _comma blip _comma blip _comma bell2 time_is_now %s %s %s _comma %s^"", w_Hour, w_Minutes1, w_Minutes2, apm)
}
else if(cvar_speak == 1)
client_cmd(id,"speak misc/fvox/blip _comma blip _comma blip _comma blip _comma bell2")
strtoupper(apm)
if(1 & cvar_display){
client_print(id, print_chat, "【日期: %s年 %s %s日 星期%s】", ns_Year, MONTHS, DAY, WEEK)
client_print(id, print_chat, "【时间: %s%d点 %s分】", am_pm, num_Hour, ns_Minutes)
}
if(4 & cvar_display){
set_hudmessage(CENTER_TIME_COLOR, CENTER_TIME_COLOR, CENTER_TIME_COLOR, -1.0, 0.2, 0, 0.5, 6.0 , 2.0, 2.0, 17)
show_hudmessage(id,"【北京时间】^n %s %d点 %s分",am_pm, num_Hour,ns_Minutes)
}
if(!id){
server_print("【日期: %s年 %s %s日 星期%s】", ns_Year, MONTHS, DAY, WEEK)
server_print("【时间: %s%d点 %s分】", am_pm, num_Hour, ns_Minutes)
}
return PLUGIN_HANDLED
}
public chime_check()
{
// Set cvars
new cvar_Sdisplay
get_cvar_string("j9_time_display",cvar_Sdisplay,3)
cvar_display = read_flags(cvar_Sdisplay)
cvar_offset = get_cvar_num("j9_time_offset")
cvar_speak = get_cvar_num("j9_time_speak")
cvar_interval = get_cvar_num("j9_time_interval")
new s_Minutes, s_Seconds
get_time("%M", s_Minutes, 2)
get_time("%S", s_Seconds, 2)
new num_Minutes = str_to_num(s_Minutes)
new num_Seconds = str_to_num(s_Seconds)
new Float:exec_time
if(num_Seconds > 30) // seconds to add to exec time so we don't cut it close
exec_time = 30.0
else
exec_time = 60.0
exec_time += float(get_exec_time(num_Minutes))
set_task(exec_time, "exec_time_chime",1014)
}
public remove_cant_time(a_id[])
{
cant_time] = 0
}
public exec_time_chime()
{
SpeakTime(0) // Display/Speech the time
new s_Minutes, s_Seconds
get_time("%M", s_Minutes, 2)
get_time("%S", s_Seconds, 2)
new num_Minutes = str_to_num(s_Minutes)
new num_Seconds = str_to_num(s_Seconds)
new Float:exec_time
if(num_Seconds > 30) // seconds to add to exec time so we don't cut it close
exec_time = 30.0
else
exec_time = 60.0
exec_time += float(get_exec_time(num_Minutes)) // get next exec time for diplay/speaking the time
set_task(exec_time, "exec_time_chime",1015)
}
public get_exec_time(num_Minutes) // return number of seconds to exec the time display/speech function
{
new seconds
if(cvar_interval == 0){
seconds = (59 - num_Minutes) * 60
}
else if(cvar_interval == 2){
if(num_Minutes < 15){
seconds = (14 - num_Minutes) * 60
}
else if(num_Minutes < 30){
seconds = (29 - num_Minutes) * 60
}
else if(num_Minutes < 45){
seconds = (44 - num_Minutes) * 60
}
else{
seconds = (59 - num_Minutes) * 60
}
}
else{
if(num_Minutes < 30)
seconds = (29 - num_Minutes) * 60
else
seconds = (59 - num_Minutes) * 60
}
return seconds
}
public plugin_init()
{
register_plugin("Server Chime Plugin", "0.9 AMX", "Edited By Undoer")
register_cvar("j9_time_display","abc")
register_cvar("j9_time_speak","2")
register_cvar("j9_time_interval", "1")
register_cvar("j9_time_offset","0")
register_srvcmd("time","SpeakTime")
register_clcmd("say time","SpeakTime")
set_task(5.0,"chime_check",1013)
return PLUGIN_CONTINUE
} 不错········ 怎么用 给说下不 顶了。。。先下了收藏! 学习了不错的插件啊 server_chime_plugin.sma
这都拿出来发
还是支持了。 顶了 替换我那个时间报错的东西 要不了。。。。 根据源码编译修改了个适合自己的
好东西,收下了
页:
[1]
2