搜索
查看: 4218|回复: 13

nwb13请进 !(源码修改)

[复制链接]
发表于 2005-2-11 10:46:28 | 显示全部楼层 |阅读模式 来自 日本
以下内容为amx0.99的mapconfig.sma的源码,我想在amxx1.0下使用这个插件。
请您抽空帮忙修改一下 !

/* AMX Mod script.
*
* Custom Map Configs 0.8
*  Set map-specific variables and commands
*
* by JustinHoMi (justin@justinmitchell.net)
*  http://www.modkillers.com
*  #modkillers in irc.gamesnet.net
*
* Place your custom configs in the designated folder
*  (addons/amx/map_configs by default)
* Configs should be in the format "mapname.cfg"
* Insert any cvar or cmd to be executed at map change
*
* Changelog:
*  0.9.9 - Added translations support for AMX Mod 0.9.9
*  0.61  - Changes load delay to 6s (to work better with SQL ServerCfg)
*  0.6   - Execs configs rather than loading file
*        - Delays execution for 5s after map changes
*  0.5   - Initial release
*
*/

#include <translator>
#include <amxmod>
#include <amxmisc>

new currentmap[32]

public plugin_init(){
        load_translations("mapconfig")
        register_plugin(_T("Custom Map Configs"),"0.9.9","JustinHoMi")

        new filename[128], filepath[64]

        get_basedir(filepath, 63)
        get_mapname(currentmap,31)
        new len = format(filename,127,"%s/config/maps/%s.cfg",filepath,currentmap)

        if (file_exists(filename))
        {
                set_task(6.1,"delayed_load",0,filename,len+1)
        }
}

public delayed_load(filename[])
{
        server_print(_T("Loading custom map config for %s"), currentmap)
        server_cmd("exec %s",filename)
}


谢谢 !期待你的回复 。。。。
发表于 2005-2-11 13:15:33 | 显示全部楼层 来自 中国–陕西–西安
授人之鱼不如授人之渔

来看看怎么修改吧

#include <translator> 这个是0.99专用的,在amxx里是不存在的,于是删掉
#include <amxmod> 这个修不修改都一样,amxx里可兼容大部分的amx代码
#include <amxmisc> amx和amxx基本相似,可以不用改

new currentmap[32]

public plugin_init(){
load_translations("mapconfig") 0.99专用,在amxx里是register_dictionary来实现的
register_plugin(_T("Custom Map Configs"),"0.9.9","JustinHoMi") 注意标红色的部分,这是0.99专用的,于是删掉

new filename[128], filepath[64]

get_basedir(filepath, 63) 可以不修改,但是下面的路径要修改,建议修改为get_configsdir这样更方便
get_mapname(currentmap,31)
new len = format(filename,127,"%s/config/maps/%s.cfg",filepath,currentmap) 这个取决于文件的路径了,可以按自己的需要修改

if (file_exists(filename))
{
set_task(6.1,"delayed_load",0,filename,len+1)
}
}

public delayed_load(filename[])
{
server_print(_T("Loading custom map config for %s"), currentmap) 同理,去掉0.99专用的多语言函数
server_cmd("exec %s",filename)
}

下面是修改好的,复制回去自己编译吧,配置文件在configs/maps目录下
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. new currentmap[32]
  4. public plugin_init(){
  5. register_plugin("Custom Map Configs","0.9.9","JustinHoMi | nwb13")
  6. new filename[128], filepath[64]
  7. get_configsdir(filepath, 63)
  8. get_mapname(currentmap,31)
  9. new len = format(filename,127,"%s/maps/%s.cfg",filepath,currentmap)
  10. if (file_exists(filename))
  11. {
  12.         set_task(6.1,"delayed_load",0,filename,len+1)
  13. }
  14. }
  15. public delayed_load(filename[])
  16. {
  17. server_print("Loading custom map config for %s", currentmap)
  18. server_cmd("exec %s",filename)
  19. }
复制代码
回复

使用道具 举报

发表于 2005-2-11 14:48:36 | 显示全部楼层 来自 中国–吉林–长春
嗯,不错,这样的老师难找哦,支持
回复

使用道具 举报

 楼主| 发表于 2005-2-11 17:42:37 | 显示全部楼层 来自 日本
nwb13,回复好快,万分感激中。。。。。。。。 ! :79:  :79:
回复

使用道具 举报

发表于 2005-2-12 04:38:02 | 显示全部楼层 来自 中国–广西–玉林
Post by olol
嗯,不错,这样的老师难找哦,支持


恩`我们DT的骄傲~ :78:
回复

使用道具 举报

发表于 2005-2-12 04:47:22 | 显示全部楼层 来自 中国–广东–深圳–罗湖区
详细、直观,呵呵。好老师呀。。。下次我就不愁会为一个函数的某个参数而为难了。
回复

使用道具 举报

发表于 2005-2-12 16:04:20 | 显示全部楼层 来自 中国–湖南–株洲
佩服  真是强人我要好好学习
回复

使用道具 举报

发表于 2005-2-12 16:06:28 | 显示全部楼层 来自 中国–北京–北京
来上课了,来上课了,快坐好
回复

使用道具 举报

发表于 2005-2-17 01:14:18 | 显示全部楼层 来自 中国–广西
呵呵~~看见难得的好贴了!
我改了一个,想用于CS1.5用的,但是有三处错误,能帮指教一下吗?

) return PLUGIN_HANDLED
                slay_player(id,player,type)
        }
        return PLUGIN_HANDLED
}

explode(vec1[3]) {
        // blast circles
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
        write_byte( 21 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2] + 16)
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2] + 1936)
        write_short( s2white )
        write_byte( 0 ) // startframe
        write_byte( 0 ) // framerate
        write_byte( 2 ) // life
        write_byte( 16 ) // width
        write_byte( 0 ) // noise
        write_byte( 188 ) // r
        write_byte( 220 ) // g
        write_byte( 255 ) // b
        write_byte( 255 ) //brightness
        write_byte( 0 ) // speed
        message_end()
        //Explosion2
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
        write_byte( 12 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2])
        write_byte( 188 ) // byte (scale in 0.1's)
        write_byte( 10 ) // byte (framerate)
        message_end()
        //s2smoke
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)        write_byte( 5 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2])
        write_short( s2smoke )
        write_byte( 2 )
        write_byte( 10 )
        message_end()
}

blood(vec1[3]) {
        //LAVASPLASH
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
        write_byte( 10 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2])
        message_end()
}

lightning(vec1[3],vec2[3]) {
        //Lightning
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
        write_byte( 0 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2])
        write_coord(vec2[0])
        write_coord(vec2[1])
        write_coord(vec2[2])
        write_short( light )
        write_byte( 1 ) // framestart
        write_byte( 5 ) // framerate
        write_byte( 2 ) // life
        write_byte( 20 ) // width
        write_byte( 30 ) // noise
        write_byte( 200 ) // r, g, b
        write_byte( 200 ) // r, g, b
        write_byte( 200 ) // r, g, b
        write_byte( 200 ) // brightness
        write_byte( 200 ) // speed
        message_end()
        //Sparks
        message_begin( MSG_PVS, SVC_TEMPENTITY,vec2)
        write_byte( 9 )
        write_coord( vec2[0] )
        write_coord( vec2[1] )
        write_coord( vec2[2] )
        message_end()
        //s2smoke
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec2)
        write_byte( 5 )
        write_coord(vec2[0])
        write_coord(vec2[1])
        write_coord(vec2[2])
        write_short( s2smoke )
        write_byte( 10 )
        write_byte( 10 )
        message_end()
}

//ADMIN FIRE v1.0.0 by f117bomb
//=========================================================
new gmsgDamage,smoke,mflash
new onfire[33]

public ignite_effects(skIndex[])   {
        new kIndex = skIndex[0]
        gmsgDamage = get_user_msgid("Damage")
       
        if (is_user_alive(kIndex) && onfire[kIndex] )    {
                new korigin[3]
                get_user_origin(kIndex,korigin)
                               
                //TE_SPRITE - additive sprite, plays 1 cycle
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
                write_byte( 17 )
                write_coord(korigin[0])  // coord, coord, coord (position)
                write_coord(korigin[1])  
                write_coord(korigin[2])
                write_short( mflash ) // short (sprite index)
                write_byte( 20 ) // byte (scale in 0.1's)  
                write_byte( 200 ) // byte (brightness)
                message_end()
               
                //Smoke
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY,korigin)
                write_byte( 5 )
                write_coord(korigin[0])// coord coord coord (position)
                write_coord(korigin[1])
                write_coord(korigin[2])
                write_short( smoke )// short (sprite index)
                write_byte( 20 ) // byte (scale in 0.1's)
                write_byte( 15 ) // byte (framerate)
                message_end()
               
                set_task(0.2, "ignite_effects" , 0 , skIndex, 2)               
        }       
        else    {
                if( onfire[kIndex] )   {
                        emit_sound(kIndex,CHAN_AUTO, "scientist/scream21.wav", 0.6, ATTN_NORM, 0, PITCH_HIGH)
                        onfire[kIndex] = 0
                }
        }       
        return PLUGIN_CONTINUE
}

public ignite_player(skIndex[])   {
        new kIndex = skIndex[0]
               
        if (is_user_alive(kIndex) && onfire[kIndex] )    {
                new korigin[3]
                new players[32], inum = 0
                new pOrigin[3]               
                new kHeath = get_user_health(kIndex)
                get_user_origin(kIndex,korigin)
               
                //create some damage
                set_user_health(kIndex,kHeath - 10)
                message_begin(MSG_ONE, gmsgDamage, {0,0,0}, kIndex)
                write_byte(30) // dmg_save
                write_byte(30) // dmg_take
                write_long(1<<21) // visibleDamageBits
                write_coord(korigin[0]) // damageOrigin.x
                write_coord(korigin[1]) // damageOrigin.y
                write_coord(korigin[2]) // damageOrigin.z
                message_end()
                               
                //create some sound
                emit_sound(kIndex,CHAN_ITEM, "ambience/flameburst1.wav", 0.6, ATTN_NORM, 0, PITCH_NORM)
                               
                //Ignite Others                               
                get_players(players,inum,"a")
                for(new i = 0 ;i < inum; ++i)   {                                                                       
                        get_user_origin(players,pOrigin)                               
                        if( get_distance(korigin,pOrigin) < 100  )   {
                                if( !onfire[players] )   {
                                        new spIndex[2]
                                        spIndex[0] = players
                                        new pName[32], kName[32]                                       
                                        get_user_name(players,pName,31)
                                        get_user_name(kIndex,kName,31)
                                        emit_sound(players,CHAN_WEAPON ,"scientist/scream07.wav", 1.0, ATTN_NORM, 0, PITCH_HIGH)
                                        client_print(0,3,"* [AMXX] OH! NO! fire   %s let %s give !",kName,pName)
                                        onfire[players] =1
                                        ignite_player(players)
                                        ignite_effects(players)       
                                }                                       
                        }
                }                       
                players[0] = 0
                pOrigin[0] = 0                                       
                korigin[0] = 0               
               
                //Call Again in 2 seconds               
                set_task(2.0, "ignite_player" , 0 , skIndex, 2)               
        }       
        return PLUGIN_CONTINUE
}


public fire_player(id,level,cid) {
        if (!cmd_access(id,level,cid,2))
                return PLUGIN_HANDLED
       
        new arg[32]
        read_argv(1,arg,31)
       
        new victim = cmd_target(id,arg,7)
        if (!victim)
                return PLUGIN_HANDLED

        new skIndex[2]
        skIndex[0] = victim       
        new name[32]
        get_user_name(victim,name,31)
       
        onfire[victim] = 1
        ignite_effects(skIndex)
        ignite_player(skIndex)
               
        new adminname[32]  
            get_user_name(id,adminname,31)  
        switch(get_cvar_num("amx_show_activity"))   {
                 case 2:   client_print(0,print_chat,"[AMXX] OP %s: 对 %s fire.",adminname,name)
                 case 1:   client_print(0,print_chat,"[AMXX] OP: 对 %s fire.",name)
        }
        console_print(id,"Client ^"%s^" has been set on fire...",name)
        log_amx("ADMIN FIRE - this command was issued by %s. Admin has set fire to %s",adminname,name)
        return PLUGIN_HANDLED
}

//ADMIN ROCKET v1.3 by f117bomb
//=========================================================
new  m_blueflare2,rmflash,rgmsgDamage,white,rsmoke,rocket_z[33]

public rocket_liftoff(svictim[])   {
        new victim = svictim[0]

        set_user_gravity(victim,-0.50)
        client_cmd(victim,"+jump;wait;wait;-jump")
        emit_sound(victim, CHAN_VOICE, "weapons/rocket1.wav", 1.0, 0.5, 0, PITCH_NORM)
        rocket_effects(svictim)

        return PLUGIN_CONTINUE
}

public rocket_effects(svictim[])   {
        new victim = svictim[0]

        if ( is_user_alive(victim) )   {
                new vorigin[3]
                get_user_origin(victim,vorigin)

                message_begin(MSG_ONE, rgmsgDamage, {0,0,0}, victim)
                write_byte(30) // dmg_save
                write_byte(30) // dmg_take
                write_long(1<<16) // visibleDamageBits
                write_coord(vorigin[0]) // damageOrigin.x
                write_coord(vorigin[1]) // damageOrigin.y
                write_coord(vorigin[2]) // damageOrigin.z
                message_end()

                if(rocket_z[victim] == vorigin[2])
                        rocket_explode(svictim)

                rocket_z[victim] = vorigin[2]

                //Draw Trail and effects

                //TE_SPRITETRAIL - line of moving glow sprites with gravity, fadeout, and collisions
                message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte( 15 )
                write_coord( vorigin[0]) // coord, coord, coord (start)
                write_coord( vorigin[1])
                write_coord( vorigin[2])
                write_coord( vorigin[0]) // coord, coord, coord (end)
                write_coord( vorigin[1])
                write_coord( vorigin[2] - 30)
                write_short( m_blueflare2 ) // short (sprite index)
                write_byte( 5 ) // byte (count)
                write_byte( 1 ) // byte (life in 0.1's)
                write_byte( 1 )  // byte (scale in 0.1's)
                write_byte( 10 ) // byte (velocity along vector in 10's)
                write_byte( 5 )  // byte (randomness of velocity in 10's)
                message_end()

                //TE_SPRITE - additive sprite, plays 1 cycle
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
                write_byte( 17 )
                write_coord(vorigin[0])  // coord, coord, coord (position)
                write_coord(vorigin[1])
                write_coord(vorigin[2] - 30)
                write_short( rmflash ) // short (sprite index)
                write_byte( 15 ) // byte (scale in 0.1's)
                write_byte( 255 ) // byte (brightness)
                message_end()

                set_task(0.2, "rocket_effects" , 0 , svictim, 2)
        }

        return PLUGIN_CONTINUE
}

public rocket_explode(svictim[])   {
        new victim = svictim[0]

        if ( is_user_alive(victim) )   {   /*If user is alive create effects and user_kill */
                new vec1[3]
                get_user_origin(victim,vec1)

                // blast circles
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
                write_byte( 21 )
                write_coord(vec1[0])
                write_coord(vec1[1])
                write_coord(vec1[2] - 10)
                write_coord(vec1[0])
                write_coord(vec1[1])
                write_coord(vec1[2] + 1910)
                write_short( white )
                write_byte( 0 ) // startframe
                write_byte( 0 ) // framerate
                write_byte( 2 ) // life
                write_byte( 16 ) // width
                write_byte( 0 ) // noise
                write_byte( 188 ) // r
                write_byte( 220 ) // g
                write_byte( 255 ) // b
                write_byte( 255 ) //brightness
                write_byte( 0 ) // speed
                message_end()

                //Explosion2
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
                write_byte( 12 )
                write_coord(vec1[0])
                write_coord(vec1[1])
                write_coord(vec1[2])
                write_byte( 188 ) // byte (scale in 0.1's)
                write_byte( 10 ) // byte (framerate)
                message_end()

                //rsmoke
                message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
                write_byte( 5 )
                write_coord(vec1[0])
                write_coord(vec1[1])
                write_coord(vec1[2])
                write_short( rsmoke )
                write_byte( 2 )
                write_byte( 10 )
                message_end()

                user_kill(victim,1)
        }


        //stop_sound
        emit_sound(victim, CHAN_VOICE, "weapons/rocket1.wav", 0.0, 0.0, (1<<5), PITCH_NORM)

        set_user_maxspeed(victim,1.0)
        set_user_gravity(victim,1.00)

        return PLUGIN_CONTINUE
}


public rocket_player(id,level,cid) {
        if (!cmd_access(id,level,cid,2))
                return PLUGIN_HANDLED
        new arg[32],arg2[3]
        read_argv(1,arg,31)
        read_argv(2,arg2,2)
        if (arg[0]=='@') {
                new players[32], inum , name[32]
                get_players(players,inum,"ae",arg[1])
                if (inum==0){
                        console_print(id,"[AMXX] No clients in such team")
                        return PLUGIN_HANDLED
                }
                for(new a=0;a<inum;++a){
                        if (get_user_flags(players[a])&ADMIN_IMMUNITY){
                                get_user_name(players[a],name,31)
                                console_print(id,"[AMXX] Skipping ^"%s^" because client has immunity",name)
                                continue
                        }
                        new sPlayer[2]
                        sPlayer[0] = players[a]
                        emit_sound(players[a],CHAN_WEAPON ,"weapons/rocketfire1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
                        set_user_maxspeed(players[a],0.01)
                        set_task(1.2, "rocket_liftoff" , 0 , sPlayer, 2)
                }
        }
        else {
                new player = cmd_target(id,arg,7)
                if (!player)
                        return PLUGIN_HANDLED
                new sPlayer[2]
                sPlayer[0] = player
                emit_sound(player,CHAN_WEAPON ,"weapons/rocketfire1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
                set_user_maxspeed(player,0.01)
                set_task(1.2, "rocket_liftoff" , 0 , sPlayer, 2)

                new playername[32]
                get_user_name(player,playername,31)
                new name[32]
                get_user_name(id,name,31)
                switch(get_cvar_num("amx_show_activity")){
                case 2:        client_print(0,print_chat,"[AMXX] OP %s: let %s rocket",name,playername)
                case 1:        client_print(0,print_chat,"[AMXX] OP: let %s rocket",playername)
        }
                console_print(id,"[AMXX] Client ^"%s^" has been set to explode...",playername)
                log_amx("ADMIN ROCKET - this command was issued by %s. Admin has created a rocket out of %s",name,playername)
        }
        rgmsgDamage = get_user_msgid("Damage")
        return PLUGIN_HANDLED
}

public plugin_precache()   {
        mflash = precache_model("sprites/muzzleflash.spr")
        smoke = precache_model("sprites/steam1.spr")
        rmflash = precache_model("sprites/muzzleflash.spr")
        m_blueflare2 = precache_model( "sprites/blueflare2.spr")
        rsmoke = precache_model("sprites/steam1.spr")
        white = precache_model("sprites/white.spr")
        light = precache_model("sprites/lgtning.spr")
        s2smoke = precache_model("sprites/steam1.spr")
        s2white = precache_model("sprites/white.spr")

        precache_sound( "ambience/thunder_clap.wav")
        precache_sound( "weapons/headshot2.wav")
        precache_sound("ambience/flameburst1.wav")
        precache_sound("scientist/scream21.wav")
        precache_sound("scientist/scream07.wav")
        precache_sound("weapons/rocketfire1.wav")
        precache_sound("weapons/rocket1.wav")
        return PLUGIN_CONTINUE
}
回复

使用道具 举报

 楼主| 发表于 2005-2-25 14:16:39 | 显示全部楼层 来自 日本
nwb13,再问一个问题。
默认为换地图之后的5秒载入指定mapconfig,请问如何修改这个默认的载入时间?我想把这个时间修改一下。
谢谢 !
回复

使用道具 举报

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

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