找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 831|回复: 11

Simen.newbie 大哥,帮我一下

[复制链接]

该用户从未签到

发表于 2008-12-10 13:37:22 | 显示全部楼层 |阅读模式
这个插件该怎么用啊,代码如下:
/*
命令:
amp_mode 0|1|2 Mp3插件的模式, 0=关闭, 1=开启并按照服务器配置的曲目播放, 2=开启按固定数字曲目播放, 默认:1
amp_chat_msg 0|1 播放器的提示信息是否出现在聊天里(左下角), 1=开启, 0=关闭, 默认:1
amp_hud_msg 0|1|2 是否显示hud提示信息, 0=关闭, 1=静止显示, 2=运动显示
amp_hud_colour 0|1 hud信息的颜色, 0=单色, 1=随机色
amp_autoplay 1  死后曲目自动播放, 0=客户端决定, 1=服务器端决定
amp_only_mp3sound 0|1 死后自动播放mp3时, 是否关闭其他声音, 0=不关闭, 1=关闭
amp_connect_music 客户端连接的时候播放的mp3的文件(需要写相对于cstrike的路径)
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
//#define DEBUG
#define MAX_MP3  10 // 曲目最大数量
#define SPEED   0.4 // 定义字符滚动速度
#define MP3_LIST 0 // motd类型, 曲目列表
#define MP3_HELP 1 // motd类型, 帮助
#define MP3_LYRIC 2 // motd类型, 歌词
#define RANDOM  0 // 曲目播放类型, 随机
#define FROM_MENU 0 // 来源类型, 菜单
#define FROM_SAY 1 // 来源类型, 说话
#define FROM_AUTOPLAY 2 // 来源类型, 自动播放
#define FROM_CODE 3 // 来源类型, 程序内部
#define MSG_NORMAL 0 // hud信息类型, 正常信息
#define MSG_WRONG 1 // hud信息类型, 错误提示
#define MSG_AUTOPLAY 2 // hud信息类型, 自动播放
#define MSG_AUTOSTOP 3 // hud信息类型, 自动停止
#define MSG_VOL  4 // hud信息类型, 音量
#define MP3_TASK 654321
#define SHOW_STR 27
new CFG_FILE[] = "mp3_config.cfg"
new INI_FILE[] = "mp3.ini"
new gmsgSayText
new bool:g_playstatu[33]
new bool:g_autoplay_mode[33]
new bool:g_prec_on
new bool:g_mp3_download
new bool:g_fixed_mode
new g_playing_num[33]
new g_playing_vol[33]
new Float:vol[10] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0}
new g_show_str[33]
new g_mp3_num
new g_mp3_file[MAX_MP3][64]
new g_mp3_name[MAX_MP3][128]
new g_mp3_lyric[MAX_MP3][64]
new g_sltmp3_menuPos[33]
public plugin_init() {
gmsgSayText = get_user_msgid("SayText")
register_plugin("Advanced MP3 Player 2","0.1","nwb13")
register_event("DeathMsg","client_die","a")
register_event("ResetHUD","new_round","be")
register_cvar("amp_mode","1")
register_cvar("amp_chat_msg", "1")
register_cvar("amp_hud_msg", "1")
register_cvar("amp_hud_colour", "1")
register_cvar("amp_autoplay", "1")
register_cvar("amp_only_mp3sound","1")
register_cvar("amp_connect_music", "mp3/half-life17.mp3")
register_clcmd("say","check_say")
register_clcmd("say_team","check_say")
register_clcmd("mp3menu","displayMp3PlayMenu",0, " - 显示mp3功能菜单.")
register_menucmd(register_menuid("高级Mp3播放器"),1023,"actionMp3Menu")
register_menucmd(register_menuid("请选择曲目"),1023,"actionMp3PlayMenu")
new configsDir[64]
get_configsdir(configsDir, 63)
format(configsDir,63,"%s/%s",configsDir,CFG_FILE)
server_cmd("exec ^"%s^"",configsDir)
return PLUGIN_CONTINUE
}
chat_msg(id,message[]){
new message_to_send[128]
copy(message_to_send,128,message)
while(containi(message_to_send,"!t") != -1){
  replace(message_to_send,128,"!T","^x03")
}
while(containi(message_to_send,"!g") != -1){
  replace(message_to_send,128,"!G","^x04")
}
while(containi(message_to_send,"!w") != -1){
  replace(message_to_send,128,"!W","^x01")
}
message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id)
write_byte(id)
write_string(message_to_send)
message_end()
return PLUGIN_HANDLED
}
hud_msg(id,type,message[]){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
new messages[32],music_num
copy(messages,32,message)
if (get_cvar_num("amp_hud_msg") == 1){
  new buffer[128],pos,colour_r,colour_g,colour_b
  if (get_cvar_num("amp_hud_colour")){
   colour_r = random_num(50,200)
   colour_g = random_num(50,200)
   colour_b = random_num(50,200)
  }else{
   colour_r = 100
   colour_g = 255
   colour_b = 100
  }
  if (g_playstatu[id])
   music_num = g_playing_num[id]+1
  else
   music_num = 0
  pos += format(buffer[pos],127-pos,"高级MP3播放器^n曲目: %d 音量: %.1f ",music_num,vol[g_playing_vol[id]])
  switch (type) {
   case MSG_WRONG: pos += format(buffer[pos],127-pos,"^n%s",message)
   case MSG_AUTOSTOP: pos += format(buffer[pos],127-pos,"%s",message)
   case MSG_AUTOPLAY: pos += format(buffer[pos],127-pos,"自动播放^n%s",message)
   case MSG_NORMAL: pos += format(buffer[pos],127-pos,"播放^n%s",message)
   case MSG_VOL: pos += format(buffer[pos],127-pos,"%s",message)
  }
  set_hudmessage(colour_r,colour_g,colour_b,0.74, 0.77, 0, 6.0, 10.0, 0.1, 0.2, 1)
  show_hudmessage(id,buffer)
}else if (get_cvar_num("amp_hud_msg") == 2){
  new parm[128]
  parm[0] = id
  parm[1] = type
  copy(parm[2],128,messages)
  /*if (g_playstatu[id])
   AMP_stop(id,FROM_CODE)*/
  if (task_exists(MP3_TASK+id))
   remove_task(MP3_TASK+id)
  g_show_str[id] = 0
  set_task(SPEED,"fly_hud_msg",MP3_TASK+id,parm,127,"a",strlen(parm)+SHOW_STR-3)
}
return PLUGIN_HANDLED
}
public fly_hud_msg(parm[]){
new ids = parm[0]
new type = parm[1]
new buffer[128],temp[SHOW_STR],msg[64],colour_r,colour_g,colour_b,music_num
copy(msg,63,parm[2])
if (g_playstatu[ids])
  music_num = g_playing_num[ids]+1
else
  music_num = 0
format(buffer,128,"高级MP3播放器^n曲目: %d 音量: %.1f",music_num,vol[g_playing_vol[ids]])
switch (type) {
   case MSG_AUTOPLAY: add(buffer,127," 自动播放^n")
   case MSG_NORMAL: add(buffer,128," 播放^n")
   default: add(buffer,128,"^n")
}
if ( g_show_str[ids] > (strlen(parm)+SHOW_STR-3))
  g_show_str[ids] = 0
if (g_show_str[ids] <= SHOW_STR) {
  for (new i=0; i<SHOW_STR-g_show_str[ids]; i++)
   add(temp,SHOW_STR-1," ")
  if (strlen(temp) < SHOW_STR)
   add(temp,SHOW_STR-1,msg,g_show_str[ids])
}else{
  add(temp,SHOW_STR-1,msg[g_show_str[ids]-SHOW_STR],SHOW_STR)
}
add(buffer,128,temp)
g_show_str[ids]++
if (get_cvar_num("amp_hud_colour")){
  colour_r = random_num(50,200)
  colour_g = random_num(50,200)
  colour_b = random_num(50,200)
}else{
  colour_r = 100
  colour_g = 255
  colour_b = 100
}
set_hudmessage(colour_r,colour_g,colour_b, 0.74, 0.77, 0, SPEED, SPEED, 0.05, 0.05, 1)
show_hudmessage(ids,buffer)
return PLUGIN_HANDLED
}

public AMP_play(id,play_num,type){ //type ,0=from menu, 1=from say, 2=from autoplay
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
#if defined DEBUG
client_print(id,print_chat,"seclect play num %d",play_num)
#endif
if (play_num == RANDOM){
  if (g_mp3_num != 0)
   g_playing_num[id] = random_num(0,g_mp3_num-1)
  else{
   if (get_cvar_num("amp_chat_msg") && type == FROM_SAY)
    chat_msg(id,"!G高级MP3播放器 !T曲目列表中没有歌曲")
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_WRONG,"曲目列表中没有歌曲")
   return PLUGIN_HANDLED
  }
}else if (play_num >= 1 && play_num <= g_mp3_num)
  g_playing_num[id] = play_num - 1
else if (play_num > g_mp3_num || play_num < 0){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY)
   chat_msg(id,"!G高级MP3播放器 !T曲目编号错误")
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_WRONG,"曲目编号错误")
  return PLUGIN_HANDLED
}
#if defined DEBUG
client_print(id,print_chat,"transfor to playing num is %d",g_playing_num[id])
#endif
client_cmd(id,"mp3 play ^"%s^"",g_mp3_file[g_playing_num[id]])
#if defined DEBUG
client_print(id,print_chat,"start to play mp3 file %s",g_mp3_file[g_playing_num[id]])
#endif
#if defined DEBUG
client_print(id,print_chat,"mp3 statu now is %s",g_playstatu[id]?"ON":"OFF")
#endif
if (!g_playstatu[id])
  g_playstatu[id] = true
#if defined DEBUG
client_print(id,print_chat,"mp3 statu now is %s",g_playstatu[id]?"ON":"OFF")
#endif
if (type == FROM_SAY || type == FROM_MENU){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W正在播放 !T%s",g_mp3_name[g_playing_num[id]])
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_NORMAL,g_mp3_name[g_playing_num[id]])
}else if (type == FROM_AUTOPLAY){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W自动播放 !T%s",g_mp3_name[g_playing_num[id]])
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_AUTOPLAY,g_mp3_name[g_playing_num[id]])
}
#if defined DEBUG
client_print(id,print_console,"g_playstatu[%d]:%s  g_playing_num[%d]:%d  g_autoplay_mode[%d]:%s",id,g_playstatu[id]?"ON":"OFF",id,g_playing_num[id],id,g_autoplay_mode[id]?"ON":"OFF")
#endif
return PLUGIN_HANDLED
}
public AMP_stop(id,type){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (!g_playstatu[id]){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY)
   chat_msg(id,"")
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_WRONG,"播放器已经是关闭的")
  return PLUGIN_HANDLED
}
#if defined DEBUG
client_print(id,print_chat,"mp3 statu now is %s",g_playstatu[id]?"ON":"OFF")
#endif
client_cmd(id,"mp3 stop")
if (g_playstatu[id])
  g_playstatu[id] = false
#if defined DEBUG
client_print(id,print_chat,"mp3 statu now is %s",g_playstatu[id]?"ON":"OFF")
#endif
if (type == FROM_SAY || type == FROM_MENU){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W播放停止")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_AUTOSTOP,"播放停止")
}else if (type == FROM_AUTOPLAY){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W自动停止播放")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_AUTOSTOP,"自动停止播放")
}
return PLUGIN_HANDLED
}
public AMP_next(id,type){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (!g_playstatu[id]){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !T播放器现在是关闭的, 请先开启播放")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_WRONG,"播放器现在是关闭的, 请先开启播放")
  return PLUGIN_HANDLED
}
if (g_playing_num[id] == g_mp3_num - 1)
  g_playing_num[id] = 0
else
  g_playing_num[id]++
client_cmd(id,"mp3 loop ^"%s^"",g_mp3_file[g_playing_num[id]])
if (type == FROM_SAY || type == FROM_MENU){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W正在播放 !T%s",g_mp3_name[g_playing_num[id]])
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_NORMAL,g_mp3_name[g_playing_num[id]])
}
return PLUGIN_HANDLED
}
public AMP_pre(id,type){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (!g_playstatu[id]){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !T播放器现在是关闭的, 请先开启播放")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_WRONG,"播放器现在是关闭的, 请先开启播放")
  return PLUGIN_HANDLED
}
if (g_playing_num[id] == 0)
  g_playing_num[id] = g_mp3_num - 1
else
  g_playing_num[id]--
client_cmd(id,"mp3 loop ^"%s^"",g_mp3_file[g_playing_num[id]])
if (type == FROM_SAY || type == FROM_MENU){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !W正在播放 !T%s",g_mp3_name[g_playing_num[id]])
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_NORMAL,g_mp3_name[g_playing_num[id]])
}
return PLUGIN_HANDLED
}
public AMP_vol_up(id,type){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (g_playing_vol[id] == 9){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !T音量已经是最大了")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_VOL,"音量已经是最大了")
}else{
  g_playing_vol[id]++
  client_cmd(id,"MP3Volume %.2f",vol[g_playing_vol[id]])
  if (type == FROM_SAY || type == FROM_MENU){
   if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
    new msg[128]
    format(msg,127,"!G高级MP3播放器 !T音量大小 !W%.1f",vol[g_playing_vol[id]])
    chat_msg(id,msg)
   }
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_VOL,"音量增大")
  }
}
return PLUGIN_HANDLED
}
public AMP_vol_down(id,type){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (g_playing_vol[id] == 0){
  if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
   new msg[128]
   format(msg,127,"!G高级MP3播放器 !T音量已经是最小了")
   chat_msg(id,msg)
  }
  if (get_cvar_num("amp_hud_msg") != 0)
   hud_msg(id,MSG_VOL,"音量已经是最小了")
}else{
  g_playing_vol[id]--
  client_cmd(id,"MP3Volume %.2f",vol[g_playing_vol[id]])
  if (type == FROM_SAY || type == FROM_MENU){
   if (get_cvar_num("amp_chat_msg") && type == FROM_SAY){
    new msg[128]
    format(msg,127,"!G高级MP3播放器 !T音量大小 !W%.1f",vol[g_playing_vol[id]])
    chat_msg(id,msg)
   }
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_VOL,"音量减小")
  }
}
return PLUGIN_HANDLED
}
AMP_auto(id,type){
if (get_cvar_num("amp_autoplay")){
  if (type == FROM_SAY || type == FROM_MENU){
   if (get_cvar_num("amp_chat_msg") && (type == FROM_SAY || type == FROM_MENU)){
    new msg[128]
    format(msg,127,"!G高级MP3播放器 !T服务器锁定玩家必须开启自动播放")
    chat_msg(id,msg)
   }
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_WRONG,"服务器强制玩家开启自动播放")
  }
}else if (g_autoplay_mode[id]){
  if (type == FROM_SAY || type == FROM_MENU){
   if (get_cvar_num("amp_chat_msg") && (type == FROM_SAY || type == FROM_MENU)){
    new msg[128]
    format(msg,127,"!G高级MP3播放器 !T自动播放 !W关闭")
    chat_msg(id,msg)
   }
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_WRONG,"自动播放关闭")
  }
  g_autoplay_mode[id] = false
}else if (!g_autoplay_mode[id]){
  if (type == FROM_SAY || type == FROM_MENU){
   if (get_cvar_num("amp_chat_msg") && (type == FROM_SAY || type == FROM_MENU)){
    new msg[128]
    format(msg,127,"!G高级MP3播放器 !T自动播放 !W开启")
    chat_msg(id,msg)
   }
   if (get_cvar_num("amp_hud_msg") != 0)
    hud_msg(id,MSG_WRONG,"自动播放开启")
  }
  g_autoplay_mode[id] = true
}
return PLUGIN_HANDLED
}
public AMP_motd(id,type){ //type: 0=list mp3 file, 1=help, 2=lyric
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
new buffer[1024]
new pos = 0
if (type == MP3_LIST){
  pos += format(buffer[pos],1023-pos,"<meta http-equiv='content-type' content='text/html; charset=UTF-8'><body bgcolor=#000000><font color=#FFB000><pre>^n")
  pos += format(buffer[pos],1023-pos,"播放曲目列表^n^n")
  if (get_cvar_num("amp_mode") == 1){
   for (new i=0; i<g_mp3_num; i++)
    pos += format(buffer[pos],1023-pos,"#%d  %s^n",i+1,g_mp3_name)
   show_motd(id,buffer,"播放列表")
  }else if (get_cvar_num("amp_mode") == 2){
   pos += format(buffer[pos],1023-pos,"请在游戏目录下自己添加你喜欢的MP3曲目^n文件名分别是1.mp3至%d.mp3",MAX_MP3)
  }
}else if (type == MP3_HELP){
  pos += format(buffer[pos],1023-pos,"<meta http-equiv='content-type' content='text/html; charset=UTF-8'><body bgcolor=#000000><font color=#FFB000><pre>^n")
  pos += format(buffer[pos],1023-pos,"高级MP3播放器使用说明:^n^n")
  pos += format(buffer[pos],1023-pos,"在说话模式下输入^n")
  pos += format(buffer[pos],1023-pos,"playmp3 或者 /playmp3 开启MP3播放^n")
  pos += format(buffer[pos],1023-pos,"stopmp3 或者 /stopmp3 关闭MP3播放^n")
  pos += format(buffer[pos],1023-pos,"nextmp3 或者 /nextmp3 播放下一首MP3^n")
  pos += format(buffer[pos],1023-pos,"premp3 或者 /premp3 播放前一首MP3^n")
  pos += format(buffer[pos],1023-pos,"volup 或者 /volup 增大播放的音量^n")
  pos += format(buffer[pos],1023-pos,"voldown 或者 /voldown 减小播放的音量^n")
  pos += format(buffer[pos],1023-pos,"autoplay 或者 /autoplay 开启或者关闭自动播放功能^n")
  pos += format(buffer[pos],1023-pos,"lyric 或者 /lyric 显示当前播放曲目的歌词^n")
  pos += format(buffer[pos],1023-pos,"listmp3 或者 /listmp3 查看曲目列表^n^n")
  pos += format(buffer[pos],1023-pos,"自定义播放某一首曲目, 在开启播放的命令后加上#曲目编号^n")
  pos += format(buffer[pos],1023-pos,"例如: playmp3 #1^n^n")
  pos += format(buffer[pos],1023-pos,"开启播放器的功能菜单, 请在控制台里输入 mp3menu")
  show_motd(id,buffer,"帮助")
}else if (type == MP3_LYRIC && get_cvar_num("amp_mode") == 1){
  if (!g_playstatu[id])
   chat_msg(id,"!G高级MP3播放器 !T没有正在播放的曲目")
  else if (contain(g_mp3_lyric[g_playing_num[id]],"#NONE#") != -1)
   chat_msg(id,"!G高级MP3播放器 !T没有找到该首曲目的歌词")
  else if (contain(g_mp3_lyric[g_playing_num[id]],".txt"))
   show_motd(id,g_mp3_lyric[g_playing_num[id]],"歌词")
}
return PLUGIN_HANDLED
}
public client_connect(id){
new loading_music[16]
g_playing_vol[id] = 3
g_playing_num[id] = 0
if (get_cvar_num("amp_autoplay"))
  g_autoplay_mode[id] = true
else
  g_autoplay_mode[id] = false
#if defined DEBUG
client_print(id,print_console,"connectd and set g_autoplay_mode[%d] %s",id,g_autoplay_mode[id]?"ON":"OFF")
#endif
client_cmd(id,"MP3Volume %.2f",vol[g_playing_vol[id]])
if (get_cvar_num("amp_only_mp3sound"))
  client_cmd(id,"nosound 0")
get_cvar_string("amp_connect_music",loading_music,15)
if (strlen(loading_music) > 0)
  client_cmd(id,"mp3 loop ^"%s^"",loading_music)
return PLUGIN_CONTINUE
}
public client_putinserver(id){
new parm[1]
parm[0] = id
set_task(10.0,"welcome_help",MP3_TASK+id,parm,1)
return PLUGIN_CONTINUE
}
public welcome_help(parm[]){
new parms[64],ids
ids = parm[0]
parms[0] = parm[0]
parms[1] = MSG_WRONG
add(parms,64,"查看使用帮助请说 mp3help")
set_task(0.5,"fly_hud_msg",MP3_TASK+ids,parms,64,"a",strlen(parms)+SHOW_STR-3)
return PLUGIN_HANDLED
}
public client_disconnect(id){
if (task_exists(MP3_TASK+id))
  remove_task(MP3_TASK+id)
g_playing_num[id] = 0
g_autoplay_mode[id] = false
g_playstatu[id] = false
return PLUGIN_CONTINUE
}
public client_die(){
new ids = read_data(2)
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (g_autoplay_mode[ids] && !g_playstatu[ids]){
  AMP_play(ids,random_num(1,g_mp3_num),FROM_AUTOPLAY)
  if (get_cvar_num("amp_only_mp3sound"))
   client_cmd(ids,"nosound 1")
}
return PLUGIN_CONTINUE
}
public new_round(id){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (g_autoplay_mode[id] && g_playstatu[id]){
  AMP_stop(id,FROM_AUTOPLAY)
  if (get_cvar_num("amp_only_mp3sound"))
   client_cmd(id,"nosound 0")
}
return PLUGIN_CONTINUE
}
public check_say(id) {
new cmd[32],words[32],chose[16],num[3]
read_argv(0,cmd,31)
read_args(words,31)
engclient_cmd(id,cmd,words)
remove_quotes(words)
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (parse(words,chose,16,num,3) < 3) {
  if (equali(chose,"/playmp3") || equali(chose,"playmp3")){
   if (num[0] == '#')
    AMP_play(id,str_to_num(num[1]),FROM_SAY)
   else if (strlen(num) == 0)
    AMP_play(id,RANDOM,FROM_SAY)
   #if defined DEBUG
   client_print(id,print_chat,"amp cmd playmp3")
   #endif
  }else if (equali(chose,"/stopmp3") || equali(chose,"stopmp3"))
   AMP_stop(id,FROM_SAY)
  else if (equali(chose,"/nextmp3") || equali(chose,"nextmp3"))
   AMP_next(id,FROM_SAY)
  else if (equali(chose,"/premp3") || equali(chose,"premp3"))
   AMP_pre(id,FROM_SAY)
  else if (equali(chose,"/volup") || equali(chose,"volup"))
   AMP_vol_up(id,FROM_SAY)
  else if (equali(chose,"/voldown") || equali(chose,"voldown"))
   AMP_vol_down(id,FROM_SAY)
  else if (equali(chose,"/mp3help") || equali(chose,"mp3help"))
   AMP_motd(id,MP3_HELP)
  else if (equali(chose,"/listmp3") || equali(chose,"listmp3"))
   AMP_motd(id,MP3_LIST)
  else if (equali(chose,"/lyric") || equali(chose,"lyric"))
   AMP_motd(id,MP3_LYRIC)
  else if (equali(chose,"/autoplay") || equali(chose,"autoplay"))
   AMP_auto(id,FROM_SAY)
}
return PLUGIN_CONTINUE
}
public plugin_precache(){
new configsDir[64],iniDir[64],a,nextline,temp1[64],temp2[256]
get_configsdir(configsDir, 63)
format(configsDir,63,"%s/%s",configsDir,CFG_FILE)
if (file_exists(configsDir)){
  new cvar[16],arg[3]
  while((nextline=read_file(configsDir,nextline,temp1,64,a))!=0){
   if (temp1[0] == ';')
    continue
   else if (temp1[0] == '/' && temp1[1] == '/')
    continue
   else if (parse(temp1,cvar,16,arg,3) != 2)
    continue
   else if (equal(cvar,"amp_download") && str_to_num(arg) == 1)
    g_mp3_download = true
   else if (equal(cvar,"amp_mode") && str_to_num(arg) == 2)
    g_fixed_mode = true
  }
}
get_configsdir(iniDir, 63)
format(iniDir,63,"%s/%s",iniDir,INI_FILE)
nextline = 0
new ThisMap[32]
get_mapname(ThisMap, 32)
if (g_fixed_mode){
  g_mp3_download = false
  for (new i=0; i<MAX_MP3; i++){
   format(g_mp3_name,127,"曲目 %d",i+1)
   format(g_mp3_file,63,"mp3/%d.mp3",i+1)
   format(g_mp3_lyric,63,"mp3/lyric/#NONE#")
  }
  g_mp3_num = MAX_MP3
}
#if defined DEBUG
server_print("[AMP] Mp3 download set to %s",g_mp3_download?"ON":"OFF")
#endif
if (!g_mp3_download)
  return PLUGIN_HANDLED
if (file_exists(iniDir) && g_mp3_download){
  while((nextline=read_file(iniDir,nextline,temp2,256,a))!=0){
   if (temp2[0] == ';')
    continue
   else if (temp2[0] == '#'){
    if (g_prec_on == true)
     g_prec_on = false
    if (equali(temp2[1],ThisMap) || equali(temp2[1],"ALL",3))
     g_prec_on = true
   }else if (containi(temp2,".mp3") != -1 && g_prec_on){
    if (parse(temp2,g_mp3_file[g_mp3_num],64,g_mp3_name[g_mp3_num],128,g_mp3_lyric[g_mp3_num],64) != 3)
     continue
    format(g_mp3_file[g_mp3_num],63,"mp3/%s",g_mp3_file[g_mp3_num])
    format(g_mp3_lyric[g_mp3_num],63,"mp3/lyric/%s",g_mp3_lyric[g_mp3_num])
    precache_generic(g_mp3_file[g_mp3_num])
    #if defined DEBUG
    server_print("[AMP] #%d mp3[%s] name[%s] lyric[%s]",g_mp3_num+1,g_mp3_file[g_mp3_num],g_mp3_name[g_mp3_num],g_mp3_lyric[g_mp3_num])
    #endif
    g_mp3_num++
   }
  }
  #if defined DEBUG
  server_print("[AMP] Load %d mp3 files into resource",g_mp3_num)
  #endif
}
return PLUGIN_CONTINUE
}
public displayMp3PlayMenu(id) {
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
new menuBody[1024],pos
new key
pos += format(menuBody[pos], 1023-pos, "\y高级Mp3播放器^n^n\r1. 选择播放 Mp3^n\w2. 随机播放 Mp3^n\w3. 停止播放 Mp3^n\w4. 下一首 Mp3^n\w5. 上一首 Mp3^n\w6. 增大音量^n\w7. 减小音量^n\w8. 自动播放切换^n")
key = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)
if (get_cvar_num("amp_mode") == 1){
  pos += format(menuBody[pos], 1023-pos, "\w9. 查看歌词^n")
  key |= (1<<8)
}
pos += format(menuBody[pos], 1023-pos, "^n\w0. 退出")
key |= (1<<9)
show_menu(id, key, menuBody)
return PLUGIN_HANDLED
}
public actionMp3Menu(id, key1) {
switch(key1) {
  case 0: seclect_mp3_menu(id,0)
  case 1: {
   AMP_play(id,RANDOM,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 2: {
   AMP_stop(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 3: {
   AMP_next(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 4: {
   AMP_pre(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 5: {
   AMP_vol_up(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 6: {
   AMP_vol_down(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 7: {
   AMP_auto(id,FROM_MENU)
   displayMp3PlayMenu(id)
  }
  case 8: {
   AMP_motd(id,MP3_LYRIC)
   displayMp3PlayMenu(id)
  }
  case 9: return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public seclect_mp3_menu(id,pos){
if (get_cvar_num("amp_mode") == 0)
  return PLUGIN_HANDLED
if (pos < 0)
  return PLUGIN_HANDLED
new menuBody[512]
new b = 0
new start = pos * 8
if (g_sltmp3_menuPos[id]<0)
  g_sltmp3_menuPos[id] = 0
   if (start >= g_mp3_num)
      start = pos = g_sltmp3_menuPos[id] = 0
   new len = format(menuBody,511,"\y请选择曲目\R%d/%d^n^n\w",pos+1,(  g_mp3_num / 8 + ((g_mp3_num % 8) ? 1 : 0)) )
new end = start + 8
new keys = (1<<9)
if (end > g_mp3_num)
  end = g_mp3_num
for (new a = start; a < end; ++a) {
  keys |= (1<<b)
  len += format(menuBody[len],511-len,"%d. %s^n\w",b+1,g_mp3_name[a])
  b++
}
#if defined DEBUG
client_print(id,print_chat,"menu num b is %d",b)
#endif
if (end != g_mp3_num) {
  format(menuBody[len],511-len,"^n9. %s^n0. %s", "下一页",pos ? "返回" : "退出")
  keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s",pos ? "返回" : "退出")
show_menu(id,keys,menuBody,-1,"请选择曲目")
return PLUGIN_HANDLED
}
public actionMp3PlayMenu(id,key){
switch (key) {
  case 8: seclect_mp3_menu(id,++g_sltmp3_menuPos[id])
  case 9: seclect_mp3_menu(id,--g_sltmp3_menuPos[id])
  default: {
   new num = g_sltmp3_menuPos[id] * 8 + key +1
   AMP_play(id,num,FROM_MENU)
  }
}
seclect_mp3_menu(id,g_sltmp3_menuPos[id])
//displayMp3PlayMenu(id)
return PLUGIN_HANDLED
}

该用户从未签到

发表于 2008-12-10 13:43:48 | 显示全部楼层
同意LS的观点,我已经看到过好多次了,
貌似newbie已经跟你说过了!

该用户从未签到

发表于 2008-12-10 14:35:32 | 显示全部楼层
LZ是做什么的?
晕,头好晕。

该用户从未签到

发表于 2008-12-10 14:44:33 | 显示全部楼层
一看下去头晕眼花一塌糊涂

该用户从未签到

发表于 2008-12-10 15:59:30 | 显示全部楼层
看的头痛

该用户从未签到

发表于 2008-12-10 16:07:18 | 显示全部楼层
老大。。。别找我。。。找作者吧

该用户从未签到

发表于 2008-12-10 16:13:01 | 显示全部楼层
怎么这代码跟C的一样?

该用户从未签到

 楼主| 发表于 2008-12-10 18:38:15 | 显示全部楼层
我是学习软件的

该用户从未签到

 楼主| 发表于 2008-12-10 18:39:00 | 显示全部楼层
在校大学生

该用户从未签到

 楼主| 发表于 2008-12-10 18:41:24 | 显示全部楼层
newbie老大,我为什么找你,因为别的论坛的版主太让人伤心了,不会还保守。
我觉得你很热心啦!!!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表