搜索
查看: 7285|回复: 12

请前辈们进来帮我加下。投票地图里的声音功能1!

[复制链接]
发表于 2008-5-3 11:45:06 | 显示全部楼层 |阅读模式 来自 中国–浙江–衢州–开化县
在下面地图投票里加下按键的声音效果:选择下幅地图语音提示:是的 ! 不同意:是的


    /* AMX Mod X
*   Nextmap Chooser Plugin
*
* by the AMX Mod X Development Team
*  originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/
#include <amxmodx>
#include <amxmisc>
#define MAX_MAPS    128
#define SELECTMAPS  5
new g_voteforchange,g_voted_map[33]
new g_mapName[MAX_MAPS][32]
new g_mapNums
new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]
new g_voteYN[3]
new Float:g_ori_timelimit=0.0
new g_coloredMenus
new bool:g_selected = false
public plugin_init() {
  register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team")
  register_dictionary("mapchooser.txt")
  register_dictionary("common.txt")
  new MenuName[64]
  format(MenuName,63,"%L","en","CHOOSE_NEXTM")
  register_menucmd(register_menuid(MenuName),(1<<5|1<<6|1<<7|1<<8|1<<9),"countVote")//6-0
  new YNMenuName[64]
  format(YNMenuName,63,"%L","en","SHOULD_CHANGE_MAP")
  register_menucmd(register_menuid(YNMenuName),(1<<7|1<<8|1<<9),"countYN")//我们先提示是否换图
  register_concmd("amx_votechange","cmdVoteChange",ADMIN_VOTE,"- vote for change map")
  register_cvar("amx_extendmap_max","90")
  register_cvar("amx_extendmap_step","15")
//  register_cvar("amx_in_voting","0")
//  set_cvar_num("amx_in_voting",0)
  if ( cstrike_running() )
    register_event("TeamScore", "team_score", "a")
  
  get_localinfo("lastMap",g_lastMap,31)
  set_localinfo("lastMap","")
  new maps_ini_file[64]
  get_configsdir(maps_ini_file, 63);
  format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
  if (!file_exists(maps_ini_file))
   get_cvar_string("mapcyclefile", maps_ini_file, 63)
  if ( loadSettings(maps_ini_file) )
    //set_task(15.0,"voteNextmap",987456,"",0,"b")
    set_task(15.0,"voteShoudChange",987456,"",0,"b")
  g_coloredMenus = colored_menus()
  g_ori_timelimit=0.0
  g_voteforchange=0
}
public change_map(){
server_cmd("changelevel %s",g_voted_map)
}
public checkVotes() {
  new b = 0
  for (new a = 0; a < g_mapVoteNum; ++a)
    if (g_voteCount < g_voteCount[a])
       b = a
/*  if ( g_voteCount[SELECTMAPS] > g_voteCount ) {
    new mapname[32]
    get_mapname(mapname,31)
    new Float:steptime = get_cvar_float("amx_extendmap_step")
    set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
    client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_EXT", steptime )
   
    log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
      mapname , steptime )
    return
  }*/
  //if ( g_voteCount && g_voteCount[SELECTMAPS+1] <= g_voteCount )
  new nxtmapmsg[129]
  new smap[32]
  if(!g_voteforchange){
   if ( g_voteCount) set_cvar_string("amx_nextmap", g_mapName[g_nextName] )
   get_cvar_string("amx_nextmap",smap,31)
   format(nxtmapmsg,128,"%L", LANG_SERVER, "CHO_FIN_NEXT", smap,g_voteCount )
   log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
   //set_cvar_num("amx_in_voting",0)
}else{
   g_voteforchange=0
   format(nxtmapmsg,128,"%L", LANG_SERVER, "CHO_FIN_CHANGEMAP", g_mapName[g_nextName],g_voteCount)
   copy(g_voted_map,32,g_mapName[g_nextName])
   set_task(5.0,"change_map")
   //set_cvar_num("amx_in_voting",1)
}
  while(replace(nxtmapmsg,128,"0x01","^x01")){}
  while(replace(nxtmapmsg,128,"0x02","^x02")){}
  while(replace(nxtmapmsg,128,"0x03","^x03")){}
  while(replace(nxtmapmsg,128,"0x04","^x04")){}
  new id=0
  for(id=1;id<=32;id++){
   if(is_user_connected(id)){
    message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, 1)
    write_byte(1)
    write_string(nxtmapmsg)
    message_end()
    break;
   }
}
  client_cmd(0,"spk events/tutor_msg")
  //client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_NEXT", smap )
}
public checkYN(){
new votemsg[129]
/*if(g_voteforchangemap){
  new g_voteRatio = get_cvar_float("amx_votemap_ratio")
}*/
if(g_voteforchange){
  new Float:g_voteRatio=get_cvar_float("amx_votemap_ratio")
  new votesNum=g_voteYN[0]+g_voteYN[1]//选择换图与不换得总人数
  new iRatio=votesNum?floatround(g_voteRatio * float( votesNum ) ,floatround_ceil) : 1//Need vote count
  if(g_voteYN[0]>=iRatio){//购人了。
   format(votemsg,128,"%L",LANG_SERVER,"CHO_FIN_SUCESS",g_voteYN[0],iRatio)
   set_task(5.0,"voteNextmap")
   log_amx("Vote:Voting Sucess, We will start voting new map")
  }
  else{
   format(votemsg,128,"%L",LANG_SERVER,"CHO_FIN_FAIL",g_voteYN[0],iRatio)
   //set_cvar_num("amx_in_voting",0)//投票结束。
   g_voteforchange=0
   log_amx("Vote:Voteing Fail for Changing Map, Need:%d,Got:%d",iRatio,g_voteYN)
  }
}else
{
  if(g_voteYN[0]>g_voteYN[1]){//换图
   format(votemsg,128,"%L",LANG_SERVER,"CHO_FIN_ANOTHER",g_voteYN[0])
   log_amx("Vote: Voting for if changeing map finished, We will start another Vote.")
   set_task(5.0,"voteNextmap")  
  }
  else //继续延长
  {
     new mapname[32]
      get_mapname(mapname,31)
      new Float:steptime = get_cvar_float("amx_extendmap_step")
      if(g_ori_timelimit==0.0) g_ori_timelimit = get_cvar_float("mp_timelimit")
      set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
      //set_cvar_num("amx_in_voting",0)
      g_selected=false
      log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
        mapname , steptime )
     //client_print(0,print_chat,"%L", LANG_PLAYER, "CHO_FIN_EXT", steptime )
     format(votemsg,128,"%L", LANG_SERVER, "CHO_FIN_EXT", steptime,g_voteYN[1] )
  }
}
while(replace(votemsg,128,"0x01","^x01")){}
while(replace(votemsg,128,"0x02","^x02")){}
while(replace(votemsg,128,"0x03","^x03")){}
while(replace(votemsg,128,"0x04","^x04")){}
new id=0
for(id=1;id<=32;id++){
   if(is_user_connected(id)){
    message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, 1)
    write_byte(1)
    write_string(votemsg)
    message_end()
    break;
   }
}
client_cmd(0,"spk events/tutor_msg")
return
}
public countYN(id,key){//Yes, Or No
if(get_cvar_float("amx_vote_answers")){
  new choose[21],yes[21],no[21],disclaim[21]
  new name[32],votemsg[129]=""
  format(choose,20,"%L",id,"CHOOSE")
  format(yes,20,"%L",id,"YES_MAP")
  format(no,20,"%L",id,"NO_MAP")
  format(disclaim,20,"%L",id,"DISCLAIM")
  get_user_name(id,name,31)
  //client_print(id,print_chat,"%s:%d",name,key)
  if(key==9){
   format(votemsg,128,"^x03%s^x01%s^x04%s",name,choose,disclaim)
  }
  else if(key==8){
   format(votemsg,128,"^x03%s^x01%s^x04%s",name,choose,no)
  }
  else if(key==7){
   format(votemsg,128,"^x03%s^x01%s^x04%s",name,choose,yes)
  }
  message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id)
  write_byte(id)
  write_string(votemsg)
  message_end()
}
g_voteYN[key-7]++
return PLUGIN_HANDLED
}
public countVote(id,key) {
  if ( get_cvar_float("amx_vote_answers") ) {
    new name[32],votemsg[129]
    get_user_name(id,name,31)
//    if ( key == SELECTMAPS )
//     format(votemsg,128,"%L", LANG_PLAYER, "CHOSE_EXT", name )
      //client_print(0,print_chat,"%L", LANG_PLAYER, "CHOSE_EXT", name )
//    else if ( key < SELECTMAPS )
    format(votemsg,128,"%L", LANG_SERVER, "X_CHOSE_X", name, g_mapName[g_nextName[key-5]] )
      //client_print(0,print_chat,"%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName[g_nextName[key]] )
    while(replace(votemsg,128,"0x01","^x01")){}
    while(replace(votemsg,128,"0x02","^x02")){}
    while(replace(votemsg,128,"0x03","^x03")){}
    while(replace(votemsg,128,"0x04","^x04")){}
    message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id)
    write_byte(id)
    write_string(votemsg)
    message_end()
  }
  ++g_voteCount[key-5]
  return PLUGIN_HANDLED
}
bool:isInMenu(id) {
  for (new a=0; a<g_mapVoteNum; ++a)
    if (id==g_nextName[a])
      return true
  return false
}
public cmdVoteChange(id,level,cid){
  if (!cmd_access(id,level,cid,1))
  return PLUGIN_HANDLED
  new Float:voting = get_cvar_float("amx_last_voting")
  if (voting > get_gametime()) {
    console_print(id, "%L", id, "ALREADY_VOTING")
    return PLUGIN_HANDLED
  }
  if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
    console_print(id, "%L", id, "VOTING_NOT_ALLOW")
    return PLUGIN_HANDLED
  }
  new timeleft=get_timeleft()
  if(timeleft<=5){
    console_print(id, "%L", id, "VOTING_NOT_ALLOW")
    return PLUGIN_HANDLED
  }
  VoteChangeMap()
  return PLUGIN_HANDLED
}
public VoteChangeMap(){   
   new timeleft = get_timeleft()
   if(timeleft<3) return PLUGIN_HANDLED
   if(g_selected) return PLUGIN_HANDLED
   g_voteforchange=1//为改变地图投票
   voteShoudChange()
   return PLUGIN_HANDLED
}
public voteShoudChange(){
  new winlimit=get_cvar_num("mp_winlimit")
  new maxrounds = get_cvar_num("mp_maxrounds")
  if(!g_voteforchange){
  if ( winlimit ) {
     new c = winlimit - 2
     if ( (c > g_teamScore[0]) && (c > g_teamScore[1]) ) {
       g_selected = false
       return PLUGIN_HANDLED
     }
  }
  else  if ( maxrounds ) {
     if ( (maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]) ){
       g_selected = false
       return PLUGIN_HANDLED
     }
  }
  else {
     new timeleft = get_timeleft()
     if (timeleft<1||timeleft>129){
       g_selected = false
       return PLUGIN_HANDLED
     }
  }
  if (g_selected) return PLUGIN_HANDLED
  g_selected = true
}
  //g_selected=false
  //判断是否有其他的投票
  new Float:voting = get_cvar_float("amx_last_voting")
  if (voting > get_gametime()) {
    //console_print(id, "%L", id, "ALREADY_VOTING")
    return PLUGIN_HANDLED
  }
  new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
  set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
  if (g_voteforchange||((winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))){//vote for Extended
   new menu[512],mkeys= (1<<7|1<<8|1<<9)
   new pos=format(menu,511,g_coloredMenus? "\y%L:\w^n^n" : "%L:^n^n",LANG_SERVER,"SHOULD_CHANGE_MAP")
   pos+=format(menu[pos],511-pos,"8.%L^n",LANG_SERVER,"YES_MAP")
   pos+=format(menu[pos],511-pos,"9.%L^n",LANG_SERVER,"NO_MAP")
   pos+=format(menu[pos],511-pos,"^n0.%L",LANG_SERVER,"DISCLAIM")
   for(new i=0;i<3;i++)g_voteYN=0//Reset Vote Map
   new MenuName[64]
   format(MenuName,63,"%L","en","SHOULD_CHANGE_MAP")
   show_menu(0,mkeys,menu,15,MenuName)
   set_task(15.0,"checkYN")
   client_cmd(0,"spk Gman/Gman_Choose2")
   log_amx("Vote: Voting for if Changeing map started")
  }else
  {
   voteNextmap()
  }
  return PLUGIN_HANDLED   
}
public voteNextmap() {
  new menu[512], a, mkeys = 0
  new mapname[32]
  new pos = format(menu,511,g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
  new dmax = (g_mapNums-1 > SELECTMAPS) ? SELECTMAPS : g_mapNums-1
  get_mapname(mapname,31)
  for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){
    a=random_num(0,g_mapNums-1)
    for(;;){
     if(isInMenu(a)||equal(g_mapName[a],mapname)) ++a
     else break;
     if(a>=g_mapNums) a=0
    }
    g_nextName[g_mapVoteNum] = a
    new showid=g_mapVoteNum+6
    if (showid>9) showid=0
    pos += format(menu[pos],511-pos,"%d. %s^n",showid,g_mapName[a])//We Start From 6-0
    mkeys |= (1<<g_mapVoteNum+5)
    g_voteCount[g_mapVoteNum] = 0
  }
//  menu[pos++]='^n'
//  g_voteCount[SELECTMAPS] = 0
//  g_voteCount[SELECTMAPS+1] = 0
  for(new i=dmax;i<SELECTMAPS;++i)g_voteCount=0//Clear Unused Maps
// new mapname[32]
// get_mapname(mapname,31)
// if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))) {
//   pos += format(menu[pos],511,"%d. %L^n",SELECTMAPS+1,LANG_SERVER,"EXTED_MAP",mapname)
//   mkeys |= (1<<SELECTMAPS)
// }
// format(menu[pos],511,"%d. %L",SELECTMAPS+2,LANG_SERVER,"NONE")
  new MenuName[64]
  format(MenuName,63,"%L","en","CHOOSE_NEXTM")
  show_menu(0,mkeys,menu,15,MenuName)
  set_task(15.0,"checkVotes")
  client_print(0,print_chat,"%L",LANG_SERVER,"TIME_CHOOSE")
  client_cmd(0,"spk Gman/Gman_Choose2")
  log_amx("Vote: Voting for the nextmap started")
}
loadSettings(filename[]) {
  if (!file_exists(filename)) return 0
  new szText[32]
  new a, pos = 0
  new currentMap[32]
  get_mapname(currentMap,31)
  while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) {
    if ( szText[0] != ';'
    &&  parse(szText, g_mapName[g_mapNums] ,31 )
    &&  is_map_valid( g_mapName[g_mapNums] )
    &&  !equali( g_mapName[g_mapNums] ,g_lastMap)
    &&  !equali( g_mapName[g_mapNums] ,currentMap) )
      ++g_mapNums
  }
  return g_mapNums
}
public team_score() {
  new team[2]
  read_data(1,team,1)
  g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
}
public plugin_end() {
  new current_map[32]
  get_mapname(current_map,31 )
  set_localinfo("lastMap",current_map)
  if(g_ori_timelimit!=0.0) set_cvar_float("mp_timelimit", g_ori_timelimit)
}
发表于 2008-5-3 13:39:41 | 显示全部楼层 来自 中国–广东–深圳–南山区

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

Post by wangyang5008
在下面地图投票里加下按键的声音效果:选择下幅地图语音提示:是的 ! 不同意:是的


/* AMX Mod X
* Nextmap Chooser Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the G...

你都发了这么多同样主题的帖子,说实话,加这样的功能一点技术含量都没有。
我就给你一个吧。对应的文件放到对应的目录下去。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

 楼主| 发表于 2008-5-3 15:32:50 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

我按照对应文件加了,怎么还是没有发出声音啊。声音文件是下载到客户端了,能不能把源码发上来或者提示我下,谢谢!我原来的那个投票插件是不是要关掉的,谢谢前辈再次帮助
回复

使用道具 举报

发表于 2008-5-3 16:03:48 | 显示全部楼层 来自 中国–广东–深圳–南山区

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

Post by wangyang5008
我按照对应文件加了,怎么还是没有发出声音啊。声音文件是下载到客户端了,能不能把源码发上来或者提示我下,谢谢!我原来的那个投票插件是不是要关掉的,谢谢前辈再次帮助

把你的mapchooser.amxx关掉。用mapchooser2.amxx
回复

使用道具 举报

 楼主| 发表于 2008-5-3 18:42:09 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

OK ,  我还是想知道具体加什么代码上去。因为我还有热门投票要加这样的效果。晚辈向前辈学习!
回复

使用道具 举报

 楼主| 发表于 2008-5-3 20:46:59 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

Cr@zyTreE 前辈请问下。,你这个插件:是改选择了,这个语音好像没有了。
回复

使用道具 举报

 楼主| 发表于 2008-5-3 20:56:15 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

这个文件是不是这样的gman/gman_choose2.wav的路径!
回复

使用道具 举报

发表于 2008-5-3 21:26:59 | 显示全部楼层 来自 中国–广东–深圳–南山区

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

Post by wangyang5008
这个文件是不是这样的gman/gman_choose2.wav的路径!
我的没问题。是这个。
回复

使用道具 举报

 楼主| 发表于 2008-5-3 21:30:08 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

我原来的也是这样的,可是为什么他没有语音是改选择了!
回复

使用道具 举报

 楼主| 发表于 2008-5-3 21:31:51 | 显示全部楼层 来自 中国–浙江–衢州–开化县

回复: 请前辈们进来帮我加下。投票地图里的声音功能1!

只有按键的声音了。没有提示:是改选择了!请你再帮忙看看!
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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