wangyang5008 发表于 2008-5-21 18:57:50

请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

如何让玩家用刀攻击人的时候右上角不是 显示玩家A 刀 玩家B 而是让他显示成 玩家A 骷髅 玩B

还有如何让第1人称视角观看玩家实现HLTV的功能 比如放包 拆包 不显示出来线条还有 换弹夹 也不显示出来拉弹夹的效果 丢雷 也不显示出来拉手雷环的效果

jim_yang 发表于 2008-5-21 19:50:13

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了


#include <amxmodx>
#define PLUGIN "Test"
#define AUTHOR "Jim"
#define VERSION "1.0"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_message(get_user_msgid("DeathMsg"), "msg_death")
}
public msg_death(msg_id, msg_dest, msg_entity)
{
static weapon
get_msg_arg_string(4, weapon, 19)
if(weapon == 'k')
{
//set_msg_arg_int(3, ARG_BYTE, 0) //不显示爆头
set_msg_arg_string(4, "world")
}
return PLUGIN_CONTINUE
}

wangyang5008 发表于 2008-5-21 19:58:38

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

jim_yang 前辈很感谢你的帮助,点通有你更精彩!

wangyang5008 发表于 2008-5-21 19:59:24

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

对了如何才能实现如何让第1人称视角观看玩家实现HLTV的功能 比如放包 拆包 不显示出来线条 还有 换弹夹 也不显示出来拉弹夹的效果 丢雷 也不显示出来拉手雷环的效果

jim_yang 发表于 2008-5-21 20:01:23

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

没研究过,等别人给你回答吧。从来没用过观察模式,也不让任何人观察,除了我自己。。。

wangyang5008 发表于 2008-5-21 20:07:35

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

引用: 作者: wangyang5008
顺便在问下,能不能把投票里的原来的地图,后面再加中文的地图名称,我是好奇,我看见过这样的服务器



这个也不难,你留意一下这个函数的用法。
parse - Splits parameters into strings.

Syntax:

parse ( const text[], ... )
Type:

Native
Notes:

Example: to split text: "^"This is^" the best year",
parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
You will get: "This is", "the", "best", "year"
Function returns number of parsed parameters.

你可以从官方的mapchooser.sma或者其他修改过的类似的mapchooser.sma中的
PHP 代码:
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
}



如果我改成
PHP 代码:
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) {
if ( szText[0] != ';'
&& parse(szText, g_mapName[g_mapNums] ,31,map_description[g_mapNums],256 )
&& is_map_valid( g_mapName[g_mapNums] )
&& !equali( g_mapName[g_mapNums] ,g_lastMap)
&& !equali( g_mapName[g_mapNums] ,currentMap) )
++g_mapNums
}



就可以获取地图名字以外的变量,这时只要开头自定义了
PHP 代码:
new map_description[MAX_MAPS][256]



来储存,便可以取得地图描述。
剩下你便可在你想要的地方读取此数组变量。

这个插件的代码我试过不对,请前辈帮忙看下他的问下,谢谢!

wangyang5008 发表于 2008-5-21 20:09:03

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

为什么按照那个shinyrose说的增加新的判断可以显示中文地图名字。怎么按照他的代码加进去无法检测
/* 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    800
#define SELECTMAPS5
new g_voteforchange,g_voted_map
new g_mapName
new g_mapNums
new g_nextName
new g_voteCount
new g_mapVoteNum
new g_teamScore
new g_lastMap
new g_voteYN
new Float:g_ori_timelimit=0.0
new g_coloredMenus
new bool:g_selected = false
new map_description
public plugin_init() {
register_plugin("Nextmap Chooser",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("mapchooser.txt")
register_dictionary("common.txt")
new MenuName
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
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
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)
       b = a
/*if ( g_voteCount > g_voteCount ) {
    new mapname
    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 <= g_voteCount )
new nxtmapmsg
new smap
if(!g_voteforchange){
   if ( g_voteCount) set_cvar_string("amx_nextmap", g_mapName] )
   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_voteCount)
   copy(g_voted_map,32,g_mapName])
   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
/*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+g_voteYN//选择换图与不换得总人数
new iRatio=votesNum?floatround(g_voteRatio * float( votesNum ) ,floatround_ceil) : 1//Need vote count
if(g_voteYN>=iRatio){//购人了。
   format(votemsg,128,"%L",LANG_SERVER,"CHO_FIN_SUCESS",g_voteYN,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,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>g_voteYN){//换图
   format(votemsg,128,"%L",LANG_SERVER,"CHO_FIN_ANOTHER",g_voteYN)
   log_amx("Vote: Voting for if changeing map finished, We will start another Vote.")
   set_task(5.0,"voteNextmap")
}
else //继续延长
{
   new mapname
      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 )
}
}
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,yes,no,disclaim
new name,votemsg=""
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++
return PLUGIN_HANDLED
}
public countVote(id,key) {
if ( get_cvar_float("amx_vote_answers") ) {
    new name,votemsg
    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] )
      //client_print(0,print_chat,"%L", LANG_PLAYER, "X_CHOSE_X", name, g_mapName] )
    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
return PLUGIN_HANDLED
}
bool:isInMenu(id) {
for (new a=0; a<g_mapVoteNum; ++a)
    if (id==g_nextName)
      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) && (c > g_teamScore) ) {
       g_selected = false
       return PLUGIN_HANDLED
   }
}
elseif ( maxrounds ) {
   if ( (maxrounds - 2) > (g_teamScore + g_teamScore) ){
       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,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,511-pos,"8.%L^n",LANG_SERVER,"YES_MAP")
   pos+=format(menu,511-pos,"9.%L^n",LANG_SERVER,"NO_MAP")
   pos+=format(menu,511-pos,"^n0.%L",LANG_SERVER,"DISCLAIM")
   for(new i=0;i<3;i++)g_voteYN=0//Reset Vote Map
   new MenuName
   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, a, mkeys = 0
new mapname
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,mapname)) ++a
   else break;
   if(a>=g_mapNums) a=0
    }
    g_nextName = a
    new showid=g_mapVoteNum+6
    if (showid>9) showid=0
    pos += format(menu,511-pos,"%d. %s^n",showid,g_mapName)//We Start From 6-0
    mkeys |= (1<<g_mapVoteNum+5)
    g_voteCount = 0
}
//menu='^n'
//g_voteCount = 0
//g_voteCount = 0
for(new i=dmax;i<SELECTMAPS;++i)g_voteCount=0//Clear Unused Maps
// new mapname
// get_mapname(mapname,31)
// if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))) {
//   pos += format(menu,511,"%d. %L^n",SELECTMAPS+1,LANG_SERVER,"EXTED_MAP",mapname)
//   mkeys |= (1<<SELECTMAPS)
// }
// format(menu,511,"%d. %L",SELECTMAPS+2,LANG_SERVER,"NONE")
new MenuName
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
new a, pos = 0
new currentMap
get_mapname(currentMap,31)
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) ) {
    if ( szText != ';'
    &&parse(szText, g_mapName ,31,map_description,256 )
    &&is_map_valid( g_mapName )
    &&!equali( g_mapName ,g_lastMap)
    &&!equali( g_mapName ,currentMap) )
      ++g_mapNums
}
return g_mapNums
}
public team_score() {
new team
read_data(1,team,1)
g_teamScore[ (team=='C') ? 0 : 1 ] = read_data(2)
}
public plugin_end() {
new current_map
get_mapname(current_map,31 )
set_localinfo("lastMap",current_map)
if(g_ori_timelimit!=0.0) set_cvar_float("mp_timelimit", g_ori_timelimit)
}

public plugin_precache(){
precache_sound( "gman/gman_choose2.wav")
return PLUGIN_CONTINUE
}

jim_yang 发表于 2008-5-21 20:11:37

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

加中文有必要吗,为了加个大家都知道的名字浪费内存和cpu

wangyang5008 发表于 2008-5-21 20:13:34

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

不知道为什么就是判断不出来中文地图名字

wangyang5008 发表于 2008-5-21 20:14:30

回复: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了

我是觉得很好奇,希望自己能长多点见识,请前辈多多指点。
页: [1]
查看完整版本: 请前辈进来看下,这两个插件如何写编写,请高手指点下!先谢了