搜索
楼主: L*Y*Y*

CT和T不能互相攻击该如何写代码?

[复制链接]
发表于 2009-6-24 12:54:24 | 显示全部楼层 来自 香港
register_forward(FM_TraceLine,"ForwardTraceLine",1)
register_forward(FM_TraceHull,"ForwardTraceHull",1)

public ForwardTraceLine(Float:v1[3],Float:v2[3],EntToSkip,NoMonsters,TR)
{
        if(!get_pcvar_num(p_Godmode) || !g_SurfMap || !get_pcvar_num(p_On))
                return FMRES_IGNORED
       
        new id = get_tr(TR_pHit)
        if(!is_user_alive(id))
                return FMRES_IGNORED
               
        new Attacker
        while((Attacker = engfunc(EngFunc_FindEntityInSphere,Attacker,v1,10.0)) != 0)
                if(Attacker < 33 && Attacker > 0)
                        break
       
        if(!is_user_alive(Attacker))
                return FMRES_IGNORED
       
        new Button = pev(Attacker,pev_button)
        if(!(Button & IN_ATTACK) && !(Button & IN_ATTACK2))
                return FMRES_IGNORED
       
        set_tr(TR_flFraction,1.0)
       
        return FMRES_IGNORED
}

public ForwardTraceHull(Float:v1[3],Float:v2[3],NoMonsters,Hull,EntToSkip,TR)
{
        if(!g_SurfMap || !get_pcvar_num(p_On) || !get_pcvar_num(p_Godmode))
                return FMRES_IGNORED
       
        new Button = pev(EntToSkip,pev_button)
        if(!(Button & IN_ATTACK) && !(Button & IN_ATTACK2))
                return FMRES_IGNORED
       
        set_tr(TR_flFraction,1.0)
       
        return FMRES_IGNORED
}
回复

使用道具 举报

 楼主| 发表于 2009-6-24 12:55:31 | 显示全部楼层 来自 内蒙古巴彦淖尔
我研究的插件是出现母体僵尸,当然是变成T,可是原来的CT 和 T都能互相攻击,可以互相杀害对方!研究了几天没解决!楼主的QQ多少,想和你细聊!!
回复

使用道具 举报

 楼主| 发表于 2009-6-24 13:50:03 | 显示全部楼层 来自 内蒙古巴彦淖尔
你看看这段有什么问题?
public doDamage(id){
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
       
        new plrWeap
        new plrPartHit
        new plrAttacker = get_user_attacker(id, plrWeap, plrPartHit)
       
           if(zombies[id] == 0 && zombies[plrAttacker] == 1){
                        if ( get_cvar_float("bullet_damage") ) {
                                  new aIndex = get_user_attacker(id)
                        new damage = read_data(2)
                        set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, 7)
                        show_hudmessage(aIndex,"%i", damage)       
                              }
                            return PLUGIN_CONTINUE
                       }
        if(zombies[id] == 1 && zombies[plrAttacker] == 0){
                if ( get_cvar_float("bullet_damage") ) {
                        new aIndex = get_user_attacker(id)
                        new damage = read_data(2)
                        set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, 7)
                        show_hudmessage(aIndex,"%i", damage)       
                }
                return PLUGIN_CONTINUE
        }
        new plrDmg = read_data(2)
        if (!is_user_alive(id)){
                return PLUGIN_CONTINUE
        }
        if (!is_user_alive(plrAttacker)){
                return PLUGIN_CONTINUE
        }
        if (get_user_userid (id) == get_user_userid (plrAttacker)){
                return PLUGIN_CONTINUE
        }
        new plrHealth = get_user_health(id)
        new plrNewDmg
        plrDmg = floatround(float(plrDmg))
        if (plrDmg <= 0){
                return PLUGIN_CONTINUE
        }
        plrNewDmg = (plrHealth + plrDmg)
        set_user_health(id, plrNewDmg)
        return PLUGIN_CONTINUE
}
public event_damage() {
        if (zombie_enabled != 1)
                return PLUGIN_CONTINUE
        new id = read_data(0)
        new damage = read_data(1)
        new attacker

        if ((!id) || !is_user_connected(id))
                return PLUGIN_CONTINUE

        new weapon,body
        attacker = get_user_attacker(id,weapon,body)
        if ((!attacker) || (attacker == id))
                return PLUGIN_CONTINUE
        if ((zombies[attacker] == 1) && (weapon == CSW_HEGRENADE))
                return PLUGIN_CONTINUE
        if (zombies[attacker] != 1) {
                if (zombies[id] != 1) {
                        set_user_health(id,get_user_health(id)+damage)
                        return PLUGIN_CONTINUE
                } else {
                        new ids[5]
                        ids[0] = id
                        ids[1] = attacker
                        ids[2] = damage
                        ids[3] = body
                        ids[4] = weapon
                        set_task(0.1, "do_team_dmg", 0, ids, 5)
                }
        }
        if (zombies[id] == 1) {
                entity_set_vector(id, EV_VEC_velocity, Float:{0.0, 0.0, 0.0})
                return PLUGIN_CONTINUE
        }
        new health = get_user_health(attacker)
        health += 15
        if (health < get_cvar_num("amx_zombie_health"))
                set_user_health(attacker, health)
        if ((id > 0) && (id < 34) && (zombies[id] == 0) && (weapon == CSW_KNIFE)) {
                zombies[id] = 2
                new ids[2]
                ids[0] = id
                ids[1] = attacker
                set_task(get_cvar_float("amx_zombie_infecttime"), "start_zombie", 0, ids, 2)
                client_print(attacker, print_chat, "You have consumed the brains of a human!")
        }

        return PLUGIN_CONTINUE
}
回复

使用道具 举报

发表于 2009-6-24 19:21:46 | 显示全部楼层 来自 福建漳州
骂人的两位各禁言一周处罚。希望以后不要再发生这种情况。
回复

使用道具 举报

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

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