【请教】关于关闭重启服务器的插件问题
本帖最后由 homework 于 2010-11-17 11:13 编辑此贴问题已修正,详情请看7楼!!!!
先发源码:这个是聊天区域提示版的/*服务器重起插件。由 by:yzmzx于08年08月28日修改*/
#include <amxmodx>
#include <amxmisc>
public plugin_init() {
register_plugin("Server restart", "1.1", "Remo Williams")
register_concmd("amx_restart","serverrestart",ADMIN_IMMUNITY," - Shuts down server in 10 seconds")
}
public plugin_precache(){
precache_sound( "misc/chongqi.wav")
return PLUGIN_CONTINUE
}
public serverrestart(id) {
if (!(get_user_flags(id)&ADMIN_LEVEL_A)) {
console_print(id,"你沒有权限使用这项指令.")
return PLUGIN_HANDLED
}
set_task(0.0,"alert")
set_task(14.0,"ten")
set_task(15.0,"nine")
set_task(16.0,"eight")
set_task(17.0,"seven")
set_task(18.0,"six")
set_task(19.0,"five")
set_task(20.0,"four")
set_task(21.0,"three")
set_task(22.0,"two")
set_task(23.0,"one")
set_task(24.0,"zero")
set_task(38.0,"restart_server")
return PLUGIN_HANDLED
}
public alert() {
client_print(0,print_chat,"***** 敬請注意!!!本服务器将于 39 秒后重起!!!*****")
client_cmd(0,"spk ^"misc/chongqi.wav^"")
}
public ten() {
client_print(0,print_chat,"..........本服务器重起倒数计时 10 秒..........")
client_cmd(0,"spk ^"fvox/ten.wav^"")
}
public nine() {
client_print(0,print_chat,"..........本服务器重起倒数计时 9 秒..........")
client_cmd(0,"spk ^"fvox/nine.wav^"")
}
public eight() {
client_print(0,print_chat,"..........本服务器重起倒数计时 8 秒..........")
client_cmd(0,"spk ^"fvox/eight.wav^"")
}
public seven() {
client_print(0,print_chat,"..........本服务器重起倒数计时 7 秒..........")
client_cmd(0,"spk ^"fvox/seven.wav^"")
}
public six() {
client_print(0,print_chat,"..........本服务器重起倒数计时 6 秒..........")
client_cmd(0,"spk ^"fvox/six.wav^"")
}
public five() {
client_print(0,print_chat,"..........本服务器重起倒数计时 5 秒..........")
client_cmd(0,"spk ^"fvox/five.wav^"")
}
public four() {
client_print(0,print_chat,"..........本服务器重起倒数计时 4 秒..........")
client_cmd(0,"spk ^"fvox/four.wav^"")
}
public three() {
client_print(0,print_chat,"..........本服务器重起倒数计时 3 秒..........")
client_cmd(0,"spk ^"fvox/three.wav^"")
}
public two() {
client_print(0,print_chat,"..........本服务器重起倒数计时 2 秒..........")
client_cmd(0,"spk ^"fvox/two.wav^"")
}
public one() {
client_print(0,print_chat,"..........本服务器重起倒数计时 1 秒..........")
client_cmd(0,"spk ^"fvox/one.wav^"")
}
public zero() {
client_print(0,print_chat,".......................请稍后,服务器重起中........................")
client_cmd(0,"spk ^"misc/chongqi.wav^"")
}
public restart_server() {
client_cmd(0,"retry",1.5) //服务器重起后,客户机自动连接服务器
server_cmd("restart") //服务器重起命令
//server_cmd("quit")//关闭服务器命令exit也可以。
}问题1:所有声音文件按照插件内容放在相应目录,客户段进入服务器只下载chongqi.wav,其他1-10的声音文件均不下载,当然倒数的时候客户端也没有1-10的语音播报,请问是源码那里不正确还是其他地方有问题呢?
问题2:劳烦哪位热心大哥,发个HUD版的,不胜感激。
备注:服务器使用 心静如水 的1.8.2客户端用timeleftthetime 不语音播报(服务器AMXX.CFG已设置语音播报为开启),也没时间显示,是不是跟这个有关系呢? 先自己顶一下, 要沉了。。。。 估计永远沉下去了!!!呵呵····· precache_sound( "misc/chongqi.wav")
怎么只有一个音频文件 public plugin_precache(){
precache_sound( "misc/chongqi.wav")
precache_sound( "fvox/ten.wav")
precache_sound( "fvox/nine.wav")
…………………………自己添加
return PLUGIN_CONTINUE
} public plugin_precache(){
precache_sound( "misc/chongqi.wav")
precache_sound( "fvox/ten.wav")
precache_sound( "fvox/nine.wav")
…………………………自己添加
return PLU ...
rsdtt 发表于 2010-11-17 02:00 http://www.dt-club.net/forum/images/common/back.gif
非常感谢,不懂源码就是不方便啊,又学到了点东西,谢谢,为他人使用方便我把弄好后的源码,声音文件发出来。
本帖最后由 tooya 于 2010-11-17 17:42 编辑
无聊改写的,寥寥草草的没编译,有错的话自己修改吧
/* 本插件由 AMXX-Studio 中文版自动生成*/
/* UTF-8 func by www.DT-Club.net */
#include <amxmodx>
#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Administrator"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_cvar("shutdown_sec","30")
register_clcmd("amx_shutdown","shutdown_start")
}
public plugin_precache(){
new word
precache_sound( "misc/chongqi.wav")
for(new i=1;i<10;i++){
num_to_word(i,word,31)
precache_sound( "fvox/%s.wav",word)
}
return PLUGIN_CONTINUE
}
public shutdown_start(id){
client_print(0,print_chat,"***** 敬請注意!!!本服务器将于 %d 秒后重起!!!*****",get_cvar_num("shutdown_sec"))
client_cmd(0,"spk ^"misc/chongqi.wav^"")
set_task(1.0,"shutdown_spk",_,_,_,_,"b")
}
public shutdown_spk(){
static second,cd,word
second++
cd = get_cvar_num("shutdown_sec") - second
//每隔2秒显示一次
if(second %= 2){
client_print(0,print_chat,"[信息]服务器将在 %d 秒后关闭",cd)
if(cd <= 10){
num_to_word(cd,word,31)
client_cmd(0,"spk ^"fvox/%s.wav^"",word)
}
}
if(second == get_cvar_num("shutdown_sec"))
server_shutdown()
}
//修改 server shutting down 文字信息
public server_shutdown(){
for(new i=0;i<32;i++)
{
if(!is_user_connected(i))
continue;
message_begin(MSG_ONE, 2, {0,0,0}, i)
write_string("服务器关闭")
message_end()
}
server_cmd("exit")
}
页:
[1]