Пользователи, просматривающие тему (Пользователей: 0, Гостей: 0)

  1. KoPa6JIuK

    Регистрация:
    27.02.15
    Сообщения:
    675
    Симпатии:
    54
    Пол:
    Мужской
    Парни помоги исправить ошибку в плагине, и подскажите как его оптимизировать(Для Re-ветки)...Плагин взят из паблика(в свободном доступе)

    Код:
    L 12/24/2016 - 01:41:19: [AMXX] Displaying debug trace (plugin "deathrun_knife.amxx", version "1.2")
    L 12/24/2016 - 01:41:19: [AMXX] Run time error 4: index out of bounds 
    L 12/24/2016 - 01:41:19: [AMXX]    [0] deathrun_knife.sma::fw_EmitSound (line 344)
    
    
    Код:
    #include <amxmodx>
    #include <fun>
    #include <engine>
    #include <fakemeta>
    #include <hamsandwich>
    
    #define PLUGIN "[DR]Ножи"
    #define VERSION "1.2"
    #define AUTHOR "Dimk"
    #pragma tabsize 0
    #define TASK_INTERVAL 4.0
    #define MAX_HEALTH 99
    
    new knife_model[33]
    new g_Menu
    new SayText;
    new CVAR_LOWGRAV
    new CVAR_NORMGRAV
    new CVAR_HEALTH_ADD
    new CVAR_HEALTH_MAX
    new CVAR_DAMAGE
    
    public plugin_init() {
      
        register_plugin(PLUGIN, VERSION, AUTHOR)
      
        register_event( "Damage", "event_damage", "be" )
        register_event("CurWeapon","CurWeapon","be","1=1")
      
        g_Menu = register_menuid("Knife Mod")
        register_menucmd(g_Menu, 1023, "knifemenu")
      
        SayText = get_user_msgid("SayText")
      
        register_clcmd("say /knife", "display_knife")
        CVAR_HEALTH_ADD = register_cvar("km_addhealth", "4")
        CVAR_HEALTH_MAX = register_cvar("km_maxhealth", "99")
        CVAR_DAMAGE = register_cvar("km_damage", "2")
        CVAR_LOWGRAV = register_cvar("lowgravity" , "400")
        CVAR_NORMGRAV = get_cvar_pointer("sv_gravity")
        register_forward(FM_EmitSound, "fw_EmitSound")
      
        set_task(30.0, "kmodmsg", 0, _, _, "b")
    }
    
    public plugin_precache() {
            precache_model("models/drknife/v_combat_knife.mdl")
            precache_model("models/drknife/p_combat_knife.mdl")
            precache_model("models/drknife/v_admin_knife.mdl")
            precache_model("models/drknife/p_admin_knife.mdl")
            precache_model("models/drknife/v_tixon.mdl")
            precache_model("models/drknife/p_tixon.mdl")
            precache_model("models/drknife/v_crowbars.mdl")
            precache_model("models/v_knife.mdl")
            precache_model("models/p_knife.mdl")
            precache_sound("drknife/current1.wav")
            precache_sound("drknife/current3.wav")
            precache_sound("drknife/current4.wav")
            precache_sound("drknife/knife1/1.wav")
            precache_sound("drknife/knife1/2.wav")
            precache_sound("drknife/knife1/3.wav")
            precache_sound("drknife/knife1/4.wav")
            precache_sound("drknife/knife2/1.wav")
            precache_sound("drknife/knife2/2.wav")
            precache_sound("drknife/knife2/3.wav")
            precache_sound("drknife/knife2/4.wav")
            precache_sound("drknife/knife3/1.wav")
            precache_sound("drknife/knife3/2.wav")
            precache_sound("drknife/knife3/3.wav")
            precache_sound("drknife/knife3/4.wav")
            precache_sound("drknife/knife4/1.wav")
            precache_sound("drknife/knife4/2.wav")
            precache_sound("drknife/knife4/3.wav")
            precache_sound("drknife/knife4/4.wav")
            precache_sound("drknife/heal.wav")
    }
    
    public display_knife(id) {
        new menuBody[512]
    
            add(menuBody, 511, "\yВыбирете нож!\w^n^n")
    
            if((get_user_flags(id) & ADMIN_BAN))
           {
    
            add(menuBody, 511, "\w1. \wСерп \d(\yАдмин\r/\yVIP\d)^n")
    
            }else{
    
            add(menuBody, 511, "\d1. \dСерп (\yАдмин\r/\yVIP\d)^n")
    
            }
    
            add(menuBody, 511, "\w2. \wКросбарс \d(\rНе слышно шагов\d)\w^n")
            add(menuBody, 511, "\w3. \wСтронг \d(\rСкорость \y+++\d)\w^n")
            add(menuBody, 511, "\w4. \wКомбат \d(\rГравити \y++\d)\w^n")
            add(menuBody, 511, "\w5. \wСтандартный нож \d(\rРеген ХП \y++\d)\w^n^n")
            add(menuBody, 511, "\w0. Выход")
      
        new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<9 )
        show_menu(id, keys, menuBody, -1, "Knife Mod")
    }
    
    public knifemenu(id, key) {
        switch(key)
        {
            case 0:
                    if(get_user_flags(id) & ADMIN_LEVEL_G)
                      {
                    SetKnife(id , 4)
                     }else{
                    display_knife(id)
            }
            case 1: SetKnife(id , 2)
            case 2:SetKnife(id , 3)
            case 3:SetKnife(id , 1)
            case 4: SetKnife(id , 0)
            default: return PLUGIN_HANDLED
        }
        SaveData(id)
        return PLUGIN_HANDLED
    }
    
    public SetKnife(id , Knife) {
        knife_model[id] = Knife
      
        new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
        if ( Weapon != CSW_KNIFE )
            return PLUGIN_HANDLED
      
        new vModel[56],pModel[56]
      
        switch(Knife)
        {
            case 0: {
                format(vModel,55,"models/v_knife.mdl")
                format(pModel,55,"models/p_knife.mdl")
            }
            case 1: {
                            format(vModel,55,"models/drknife/v_combat_knife.mdl")
                            format(pModel,55,"models/drknife/p_combat_knife.mdl")
            }
            case 2: {
                            format(vModel,55,"models/drknife/v_tixon.mdl")
                            format(pModel,55,"models/drknife/p_tixon.mdl")
            }
            case 3: {
                            format(vModel,55,"models/drknife/v_crowbars.mdl")
    
            }
            case 4: {
                            format(vModel,55,"models/drknife/v_admin_knife.mdl")
                            format(pModel,55,"models/drknife/p_admin_knife.mdl")
            }
        }
      
        entity_set_string(id, EV_SZ_viewmodel, vModel)
        entity_set_string(id, EV_SZ_weaponmodel, pModel)
      
        return PLUGIN_HANDLED;
    }
    
    public event_damage( id ) {
      
        new victim_id = id;
        if( !is_user_connected( victim_id ) ) return PLUGIN_CONTINUE
        new dmg_take = read_data( 2 );
        new dmgtype = read_data( 3 );
        new Float:multiplier = get_pcvar_float(CVAR_DAMAGE);
        new Float:damage = dmg_take * multiplier;
        new health = get_user_health( victim_id );
      
        new iWeapID, attacker_id = get_user_attacker( victim_id, iWeapID );
      
        if( !is_user_connected( attacker_id ) || !is_user_alive( victim_id ) ) {
            return PLUGIN_HANDLED
        }
      
        if( iWeapID == CSW_KNIFE && knife_model[attacker_id] == 4 ) {
          
            if( floatround(damage) >= health ) {
                if( victim_id == attacker_id ) {
                    return PLUGIN_CONTINUE
                    }else{
                    log_kill( attacker_id, victim_id, "knife", 0 );
                }
              
                return PLUGIN_CONTINUE
                }else {
                if( victim_id == attacker_id ) return PLUGIN_CONTINUE
              
                fakedamage( victim_id, "weapon_knife", damage, dmgtype );
            }
        }
        return PLUGIN_CONTINUE
    }
    
    public CurWeapon(id)
        {
        new Weapon = read_data(2)
      
        // Set Knife Model
        SetKnife(id, knife_model[id])
    //адмтн нож
    
            if(knife_model[id] == 4 && get_user_weapon(id) == CSW_KNIFE)
            {
            set_pev(id, pev_gravity, 0.5);
            set_user_maxspeed(id, 350.0);
        set_user_footsteps(id , ( (knife_model[id] == 4 && Weapon == CSW_KNIFE) ? 1 : 0) )
        if(knife_model[id] == 4 && !task_exists(id) && Weapon == CSW_KNIFE)
        set_task(TASK_INTERVAL , "task_healing",id,_,_,"b")
        else if(task_exists(id))
        remove_task(id)
            return PLUGIN_HANDLED;
    }
        // хп
      
        if(knife_model[id] == 0 || knife_model[id] == 4 && !task_exists(id) && Weapon == CSW_KNIFE)
        set_task(TASK_INTERVAL , "task_healing",id,_,_,"b")
        else if(task_exists(id))
        remove_task(id)
      
        // шаги
        set_user_footsteps(id , ( (knife_model[id] == 2 && Weapon == CSW_KNIFE) ? 1 : 0) )
        // грава
        new Float:Gravity = ((knife_model[id] == 1 && Weapon == CSW_KNIFE)? get_pcvar_float(CVAR_LOWGRAV) : get_pcvar_float(CVAR_NORMGRAV)) / 800.0
        set_user_gravity(id , Gravity )
        // спид
    //       new Float:Speed
        if(Weapon != CSW_KNIFE || knife_model[id] < 3)
            return HAM_IGNORED ;
        else if(knife_model[id] == 4)
        set_user_maxspeed(id, 350.0)
        else if(knife_model[id] == 3)
        set_user_maxspeed(id, 340.0)
      
        return HAM_IGNORED 
      
    }
    
    stock log_kill(killer, victim, weapon[],headshot) {
        user_silentkill( victim );
      
        message_begin( MSG_ALL, get_user_msgid( "DeathMsg" ), {0,0,0}, 0 );
        write_byte( killer );
        write_byte( victim );
        write_byte( headshot );
        write_string( weapon );
        message_end();
      
        new kfrags = get_user_frags( killer );
        set_user_frags( killer, kfrags++ );
        new vfrags = get_user_frags( victim );
        set_user_frags( victim, vfrags++ );
      
        return  PLUGIN_CONTINUE
    }
    
    
    public task_healing(id) {
        new addhealth = get_pcvar_num(CVAR_HEALTH_ADD)
        if (!addhealth)
            return
      
        new maxhealth = get_pcvar_num(CVAR_HEALTH_MAX)
        if (maxhealth > MAX_HEALTH) {
            set_pcvar_num(CVAR_HEALTH_MAX, MAX_HEALTH)
            maxhealth = MAX_HEALTH
        }
      
        new health = get_user_health(id) 
        if (is_user_alive(id) && (health < maxhealth)) {
            set_user_health(id, health + addhealth)
            set_hudmessage(0, 255, 0, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.1, 4)
                    client_cmd ( id, "spk drknife/heal.wav" )
            show_hudmessage(id,"+Жизни")
            message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
            write_short(1<<10)
            write_short(1<<10)
            write_short(0x0000)
            write_byte(0)
            write_byte(200)
            write_byte(0)
            write_byte(75)
            message_end()
        }
      
        else {
            if (is_user_alive(id) && (health > maxhealth))
                remove_task(id)
        }
    }
    
    public client_disconnected(id) {
        if(task_exists(id)) remove_task(id)
    }
    
    
    public kmodmsg(id) {
      
        print_col_chat( id, "^1[^4Ножи^1]^3Пиши ^4/knife ^3для выбора ножей.")
    }
    
    SaveData(id)
    {
      
        new authid[32]
        get_user_authid(id, authid, 31)
      
        new vaultkey[64]
        new vaultdata[64]
      
        format(vaultkey, 63, "KMOD_%s", authid)
        format(vaultdata, 63, "%d", knife_model[id])
        set_vaultdata(vaultkey, vaultdata)
    }
    
    
    stock print_col_chat(const id, const input[], any:...)
    {
        new count = 1, players[32];
        static msg[191];
        vformat(msg, 190, input, 3);
        replace_all(msg, 190, "!g", "^4"); // Green Color
        replace_all(msg, 190, "!y", "^1"); // Default Color (у©°  湫)
        replace_all(msg, 190, "!t", "^3"); // Team Color
        if (id) players[0] = id; else get_players(players, count, "ch");
        {
            for ( new i = 0; i < count; i++ )
            {
                if ( is_user_connected(players[i]) )
                {
                    message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
                    write_byte(players[i]);
                    write_string(msg);
                    message_end();
                }
            }
        }
    }
    public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
    {          
        if(knife_model[id] == 4 && equal(sample[8], "kni", 3))
        {
            volume = 0.6;
          
            if(equal(sample[14], "sla", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife4/4.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
            if(equal(sample,"weapons/knife_deploy1.wav"))
            {
    engfunc(EngFunc_EmitSound, id, channel, "drknife/current4.wav", volume, attn, flags, pitch);
    return FMRES_SUPERCEDE;
            }
            if(equal(sample[14], "hit", 3))
            {
                if(sample[17] == 'w')
                {
                    engfunc(EngFunc_EmitSound, id, channel,"drknife/knife4/3.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
                else
                {
                    engfunc(EngFunc_EmitSound, id, channel, "drknife/knife4/1.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
            }
            if(equal(sample[14], "sta", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife4/2.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
             }
    }
    
        if(knife_model[id] == 2 && equal(sample[8], "kni", 3))
        {
            volume = 0.6;
          
            if(equal(sample[14], "sla", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife2/4.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
            if(equal(sample[14], "hit", 3))
            {
                if(sample[17] == 'w')
                {
                    engfunc(EngFunc_EmitSound, id, channel,"drknife/knife2/3.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
                else
                {
                    engfunc(EngFunc_EmitSound, id, channel, "drknife/knife2/1.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
            }
            if(equal(sample[14], "sta", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife2/2.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
               }
         }
        if(knife_model[id] == 3 && equal(sample[8], "kni", 3))
        {
            volume = 0.6;
          
            if(equal(sample[14], "sla", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife3/4.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
            if(equal(sample,"weapons/knife_deploy1.wav"))
            {
    engfunc(EngFunc_EmitSound, id, channel, "drknife/current3.wav", volume, attn, flags, pitch);
    return FMRES_SUPERCEDE;
            }
            if(equal(sample[14], "hit", 3))
            {
                if(sample[17] == 'w')
                {
                    engfunc(EngFunc_EmitSound, id, channel,"drknife/knife3/3.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
                else
                {
                    engfunc(EngFunc_EmitSound, id, channel, "drknife/knife3/1.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
            }
            if(equal(sample[14], "sta", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife3/2.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
    }
        if(knife_model[id] == 1 && equal(sample[8], "kni", 3))
        {
            volume = 0.6;
          
            if(equal(sample[14], "sla", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife1/4.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
            if(equal(sample,"weapons/knife_deploy1.wav"))
            {
    engfunc(EngFunc_EmitSound, id, channel, "drknife/current1.wav", volume, attn, flags, pitch);
    return FMRES_SUPERCEDE;
            }
            if(equal(sample[14], "hit", 3))
            {
                if(sample[17] == 'w')
                {
                    engfunc(EngFunc_EmitSound, id, channel,"drknife/knife1/3.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
                else
                {
                    engfunc(EngFunc_EmitSound, id, channel, "drknife/knife1/1.wav", volume, attn, flags, pitch);
                    return FMRES_SUPERCEDE;
    
                }
            }
            if(equal(sample[14], "sta", 3))
            {
                engfunc(EngFunc_EmitSound, id, channel, "drknife/knife1/2.wav", volume, attn, flags, pitch);
                return FMRES_SUPERCEDE;
            }
    }
        return FMRES_IGNORED;
    }
     
    Последнее редактирование: 24.12.16
  2. Fablo

    Регистрация:
    23.03.16
    Сообщения:
    392
    Симпатии:
    73
    Пол:
    Мужской
    VKcom:
    pro_iskan
    debug включи для начала
     
  3. KoPa6JIuK

    Регистрация:
    27.02.15
    Сообщения:
    675
    Симпатии:
    54
    Пол:
    Мужской
    @Fablo, Пардонте, исправил 1 пост