Shoot At Nades

Shadowless

Пользователь
Регистрация
24 Фев 2019
Сообщения
237
Симпатии
4
Пол
Мужской
Hello...
Please someone help me with Shoot At Nades( KRoT@L)[UPDATE 1.6] - AlliedModders
its works partly, i mean by shooting to nade works with some weapons and does not work with some weapons
...
for example if shot on nade with MP5 nade fusing and if i shoot with M4 nade does not fuse

RU
плагин работает частично
на пример ... если я стреляю из MP5 или пистолетом граната взрывается а если стреляю из M4/AK нет взрывается
(не пробовал на других оружиях)

C++:
/*******************************************************************************
Shoot At Nades(KRoTaL


Author: KRoTaL
Version: 1.2

1.0 release
1.1 now using fakemeta only
1.2 he and flash should explode in the air now
1.3 now you could smoke nades in the air
1.4 You can shoot at nades which are on the ground (dropped, or on aim/he maps for example)
1.5 fixed the ff typo
1.6 renamed the functions...

If you shoot at a nade (HE, FlashBang or SmokeGrenade), it will explode
(whether it is on the ground or in the air).
You can set also change the fuse time of each nade.


Cvars:

amx_shootatnades "1"
0: you can't shoot at nades
1: you can shoot at nades

amx_changenadesfusetime "0"
0: default fuse time
1: fuse time is set according to the values of the following cvars

amx_he_fusetime "5.0"  -  number of seconds before HE eplosion
amx_fb_fusetime "5.0"  -  number of seconds before FlashBang eplosion
amx_sg_fusetime "5.0"  -  number of seconds before Smoke Grenade eplosion


Setup:
download the shoot_at_nades.amxx and put it under addons\amxxmodx\plugins add the line shoot_at_nades.amxx in ur plugins.ini and enable fakemeta and your ready to go


*******************************************************************************/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_stocks>

#define STEP 40.0
#define NADE_RADIUS 20.0

#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)

stock fm_IVecFVec(const IVec[3], Float:FVec[3]) {
    FVec[0] = float(IVec[0])
    FVec[1] = float(IVec[1])
    FVec[2] = float(IVec[2])
    
    return 1
}

stock fm_FVecIVec(const Float:FVec[3], IVec[3]) {
    IVec[0] = floatround(FVec[0])
    IVec[1] = floatround(FVec[1])
    IVec[2] = floatround(FVec[2])
    
    return 1
}
stock fm_radius_damage(Float:orig[3], Float:dmg , Float:rad, bit = DMG_BULLET, wpnName[]="",inflictor = 0)
{
    new Ent,Classname[33],Float:Health
    while((Ent = engfunc(EngFunc_FindEntityInSphere,Ent,orig,rad)) != 0)
    {
        pev(Ent,pev_classname,Classname,32)
        if(!equal(Classname,"player"))
            continue
        
        pev(Ent,pev_health,Health)
        Health -= dmg
        
        if(Health < 1.0)
        {
            createKill(Ent,inflictor < 33 && inflictor > 0 ? inflictor : 1,wpnName)
            continue
        }
        
        fm_fakedamage(Ent,wpnName,dmg,bit)
    }             
}

stock createKill(id, attacker, weaponDescription[])
{
    new FFon = get_cvar_num("mp_friendlyfire")
    
    if (FFon == 1 && get_user_team(id) == get_user_team(attacker))
    {
        set_pev(attacker,pev_frags,pev(attacker,pev_frags) - 1)
        client_print(attacker,print_center,"You killed a teammate")
        
        new money = cs_get_user_money(attacker)
        if (money != 0)
            cs_set_user_money(attacker,money - 150,1)
    }
    else if (get_user_team(id) != get_user_team(attacker))
    {
        set_pev(attacker,pev_frags,pev(attacker,pev_frags) + 1)
        new money = cs_get_user_money(attacker)
        if (money < 16000)
            cs_set_user_money(attacker,money + 300,1)
    }
    
    
    logKill(attacker, id, weaponDescription)
    
    //Kill the victim and block the messages
    set_msg_block(get_user_msgid("DeathMsg"),BLOCK_ONCE)
    set_msg_block(get_user_msgid("ScoreInfo"),BLOCK_ONCE)
    user_kill(id)
    
    //user_kill removes a frag, this gives it back
    set_pev(id,pev_frags,pev(id,pev_frags) + 1)
    
    //Replaced HUD death message
    message_begin(MSG_ALL,get_user_msgid("DeathMsg"),{0,0,0},0)
    write_byte(attacker)
    write_byte(id)
    write_byte(0)
    write_string(weaponDescription)
    message_end()
    
    //Update killers scorboard with new info
    message_begin(MSG_ALL,get_user_msgid("ScoreInfo"))
    write_byte(attacker)
    write_short(get_user_frags(attacker))
    write_short(get_user_deaths(attacker))
    write_short(0)
    write_short(get_user_team(attacker))
    message_end()
    
    //Update victims scoreboard with correct info
    message_begin(MSG_ALL,get_user_msgid("ScoreInfo"))
    write_byte(id)
    write_short(get_user_frags(id))
    write_short(get_user_deaths(id))
    write_short(0)
    write_short(get_user_team(id))
    message_end()
    
}

// ------- LOG KILL------------

stock logKill(id, victim, weaponDescription[] )
{
    new namea[32],namev[32],authida[35],authidv[35],teama[16],teamv[16]
    
    //Info On Attacker
    get_user_name(id,namea,31)
    get_user_team(id,teama,15)
    get_user_authid(id,authida,34)
    
    //Info On Victim
    get_user_name(victim,namev,31)
    get_user_team(victim,teamv,15)
    get_user_authid(victim,authidv,34)
    
    //Log This Kill
    if(id != victim)
    {
        log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
        namea,get_user_userid(id),authida,teama,namev,get_user_userid(victim),authidv,teamv, weaponDescription )
    }
    else
    {
        log_message("^"%s<%d><%s><%s>^" committed suicide with ^"%s^"",
        namea,get_user_userid(id),authida,teama, weaponDescription )
    }
}


stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
    new class[] = "trigger_hurt"
    new entity = engfunc(EngFunc_CreateEntity,engfunc(EngFunc_AllocString,class))
    if (!entity)
        return 0
    
    new value[16],kvbuffer = engfunc(EngFunc_GetInfoKeyBuffer,entity)
    format(value, 15, "%f", takedmgdamage * 2)
    engfunc(EngFunc_SetKeyValue, kvbuffer, "dmg", value)
    
    format(value, 15, "%i", damagetype)
    engfunc(EngFunc_SetKeyValue, kvbuffer, "damagetype", value)
    
    engfunc(EngFunc_SetKeyValue, kvbuffer, "origin", "8192 8192 8192")
    dllfunc(DLLFunc_Spawn,entity)
    
    set_pev(entity, pev_classname, classname)
    dllfunc(DLLFunc_Touch,entity,victim)
    engfunc(EngFunc_RemoveEntity,entity)
    
    return 1
}


new explosion1, explosion2, smoke
new oldff

new g_lastwpn[33]
new g_lastammo[33]

new g_iStart[3], g_iEnd[3]
new Float:g_fStart[3], Float:g_fEnd[3]
new Float:g_distance
new Float:g_fVel[3]
new g_enableEntityThink

new cvar_enabled
new cvar_fuse
new cvar_HG_fuse
new cvar_SG_fuse
new cvar_FB_fuse
new cvar_HE_dmg
new cvar_HE_radius

new g_heModel[] = "models/w_hegrenade.mdl"
new g_fbModel[] = "models/w_flashbang.mdl"
new g_sgModel[] = "models/w_smokegrenade.mdl"

public plugin_init() {
    
    register_plugin("Shoot At Nades", "1.6", "KRoTaL")
    
    cvar_enabled        =       register_cvar("amx_shootatnades",        "1",    FCVAR_SERVER)
    cvar_fuse          =          register_cvar("amx_changenadesfusetime",    "0")
    cvar_HG_fuse        =       register_cvar("amx_he_fusetime",            "3.0")
    cvar_FB_fuse        =    register_cvar("amx_fb_fusetime",           "3.0")   
    cvar_SG_fuse        =       register_cvar("amx_sg_fusetime",            "3.0")
    cvar_HE_dmg        =    register_cvar("amx_he_dmg",             "100.0")
    cvar_HE_radius        =     register_cvar("amx_he_radius",             "150.0")
    
    register_event("CurWeapon", "eventCurWeapon", "be", "1=1", "3>0")
    
    register_forward(FM_SetModel, "fw_set_model");
    register_forward(FM_Think, "fw_entity_think");
    
    g_enableEntityThink = 0
}


public fw_set_model(entity, const model[]) {
    g_enableEntityThink = get_pcvar_num(cvar_enabled)
    
    if(get_pcvar_num(cvar_fuse) == 1) {
        if(pev_valid(entity) && pev(entity, pev_movetype) == MOVETYPE_BOUNCE) {
            
            if(equal(model, g_heModel)) {
                set_pev(entity, pev_dmgtime, get_gametime() + get_pcvar_float(cvar_HG_fuse))
            }
            else if(equal(model, g_fbModel)) {
                set_pev(entity, pev_dmgtime, get_gametime() + get_pcvar_float(cvar_FB_fuse))
            }
            else if(equal(model, g_sgModel)) {
                set_pev(entity, pev_dmgtime, get_gametime() + get_pcvar_float(cvar_SG_fuse))
            }
        }
    }
    return FMRES_IGNORED
}

public fw_entity_think(entity) {
    if(g_enableEntityThink == 0) return FMRES_IGNORED
    
    if(pev_valid(entity)) {
        
        new model[64]
        pev(entity, pev_model, model, 63)
        
        if(equal(model, g_sgModel)) {
            set_pev(entity, pev_flags, FL_ONGROUND)
        }
    }
    return FMRES_IGNORED
}

public eventCurWeapon(id)
{
    new wpn = read_data(2)
    new ammo = read_data(3)
    if(get_pcvar_num(cvar_enabled) == 1 && (fm_find_ent_by_class(id, "grenade") > 0 || fm_find_ent_by_class(id, "armoury_entity") > 0) && g_lastwpn[id] == wpn && g_lastammo[id] > ammo)
    {
        get_user_origin(id, g_iStart, 1)
        get_user_origin(id, g_iEnd, 4)
        fm_IVecFVec(g_iStart, g_fStart)
        fm_IVecFVec(g_iEnd, g_fEnd)
        new model[64]
        new Float:fDamageTime
        new ent = fm_find_ent_in_sphere(id, g_fEnd, NADE_RADIUS)
        while(ent > 0) {
            
            model[0] = '^0'
            pev(ent, pev_model, model, 63)
            
            pev(ent, pev_dmgtime, fDamageTime);
            
            if(equal(model, g_heModel) && fDamageTime == 0.0) {
                nade_explosion(ent)
                g_lastwpn[id] = wpn
                g_lastammo[id] = ammo
                return PLUGIN_CONTINUE
            }
            if(fDamageTime > get_gametime()) {
                if(equal(model, g_heModel) || equal(model, g_fbModel) || equal(model, g_sgModel)) {
                    set_pev(ent, pev_dmgtime, get_gametime()-0.1)
                    g_lastwpn[id] = wpn
                    g_lastammo[id] = ammo
                    return PLUGIN_CONTINUE
                }
            }
            ent = fm_find_ent_in_sphere(ent, g_fEnd, NADE_RADIUS)
        }
        g_distance = vector_distance(g_fStart, g_fEnd)
        if(g_distance > STEP) {
            velocity_by_aim(id, floatround(STEP), g_fVel)
            new iStop=0
            do {
                g_fStart[0] += g_fVel[0]
                g_fStart[1] += g_fVel[1]
                g_fStart[2] += g_fVel[2]
                ent = fm_find_ent_in_sphere(id, g_fStart, NADE_RADIUS)
                
                while(ent > 0) {
                    
                    if(pev(ent, pev_dmgtime) > get_gametime()) {
                        model[0] = '^0'
                        
                        pev(ent, pev_model, model, 63)
                        if(equal(model, g_heModel) || equal(model, g_fbModel) || equal(model, g_sgModel)) {
                            
                            set_pev(ent, pev_dmgtime, get_gametime()-0.1)
                            g_lastwpn[id] = wpn
                            g_lastammo[id] = ammo
                            return PLUGIN_CONTINUE
                        }
                    }
                    ent = fm_find_ent_in_sphere(ent, g_fEnd, NADE_RADIUS)
                }
                iStop++
            } while(vector_distance(g_fStart, g_fEnd) > (STEP*1.5) && (iStop < 100))
        }
    }
    g_lastwpn[id] = wpn
    g_lastammo[id] = ammo
    return PLUGIN_CONTINUE
}

nade_explosion(nade)
    {
    new Float:fexplosion[3], explosion[3]
    pev(nade, pev_origin, fexplosion)
    fm_FVecIVec(fexplosion, explosion)
    
    new Float: HE_DMG = get_pcvar_float(cvar_HE_dmg)
    new Float: HE_RDS = get_pcvar_float(cvar_HE_radius)

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(explosion[0])
    write_coord(explosion[1])
    write_coord(explosion[2])
    write_short(explosion1)
    write_byte(30)
    write_byte(30)
    write_byte(0)
    message_end()

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(explosion[0])
    write_coord(explosion[1])
    write_coord(explosion[2])
    write_short(explosion2)
    write_byte(25)
    write_byte(30)
    write_byte(0)
    message_end()

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(116)
    write_coord(explosion[0])
    write_coord(explosion[1])
    write_coord(explosion[2])
    write_byte(46)
    message_end()

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY, explosion)
    write_byte(5)
    write_coord(explosion[0])
    write_coord(explosion[1])
    write_coord(explosion[2])
    write_short(smoke)
    write_byte(39)
    write_byte(5)
    message_end()
    
    oldff = get_cvar_num("mp_friendlyfire")
    if(oldff != 1) set_cvar_num("mp_friendlyfire", 1)
    fm_radius_damage(fexplosion, HE_DMG,HE_RDS , DMG_BLAST,"grenade",0)
    if(oldff != 1) set_cvar_num("mp_friendlyfire", oldff)

    engfunc(EngFunc_RemoveEntity, nade)
}

public plugin_precache()
{
    explosion1 = precache_model("sprites/zerogxplode.spr")
    explosion2 = precache_model("sprites/explode1.spr")
    smoke = precache_model("sprites/steam1.spr")
}
 

cpCTRL

bruh
Скриптер
Постоялец
Регистрация
20 Фев 2018
Сообщения
263
Симпатии
65
Пол
Мужской
Открываю спойлер с исходником вылетает бровзер хмм. Проверил с другими такими спойлерами все норм, не судьба в общем
 

perfectblood0

Команда форума
Администратор
Регистрация
29 Окт 2017
Сообщения
2.578
Симпатии
914
Пол
Женский
Сверху Снизу